Better snow cover

This commit is contained in:
Joshua Barretto 2022-05-09 14:20:48 +01:00
parent 79ce90a2e4
commit a9b2018383
2 changed files with 10 additions and 1 deletions

View File

@ -21,6 +21,7 @@
layout(location = 0) in vec3 f_pos;
layout(location = 1) in vec3 f_norm;
layout(location = 2) in vec4 f_col;
layout(location = 3) in float snow_cover;
layout(location = 0) out vec4 tgt_color;
@ -123,6 +124,10 @@ void main() {
//max_light += lights_at(f_pos, voxel_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, voxel_norm, 1.0, emitted_light, reflected_light);
vec3 side_color = mix(surf_color, vec3(1), snow_cover);
vec3 top_color = mix(surf_color, surf_color * 0.3, snow_cover);
surf_color = mix(side_color, top_color, 1.0 - fract((f_pos.z + focus_off.z) * 0.1));
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light);
// Temporarily disable particle transparency to avoid artifacts

View File

@ -28,6 +28,7 @@ const uint FLAG_SNOW_COVERED = 1;
layout(location = 0) out vec3 f_pos;
layout(location = 1) out vec3 f_norm;
layout(location = 2) out vec4 f_col;
layout(location = 3) out float snow_cover;
void main() {
vec3 tree_pos = inst_pos - focus_off.xyz;
@ -40,7 +41,10 @@ void main() {
f_col = vec4(vec3(0.02, 0.1, 0.01) * (sin(inst_pos.xyy) * 0.33 + 0.66), 1.0);//vec4(v_col, 1.0);
if ((inst_flags & FLAG_SNOW_COVERED) > 0u) {
f_col.rgb = mix(f_col.rgb, vec3(1), pow(max(f_norm.z, 0.0), 0.5));
snow_cover = 1.0;
//f_col.rgb = mix(f_col.rgb, vec3(1), pow(max(f_norm.z, 0.0), 0.5));
} else {
snow_cover = 0.0;
}
gl_Position =