Skip to content

Commit

Permalink
Calculate fog opacity in terrain raster fragment shader when zero exa…
Browse files Browse the repository at this point in the history
…ggeration is used
  • Loading branch information
endanke committed Nov 30, 2022
1 parent d12e8f9 commit 5914011
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/shaders/terrain_raster.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ void main() {
#endif

#ifdef FOG
#ifdef ZERO_EXAGGERATION
color = fog_dither(fog_apply_premultiplied(color, v_fog_pos));
#else
color = fog_dither(fog_apply_from_vert(color, v_fog_opacity));
#endif
#endif
gl_FragColor = color;
#ifdef TERRAIN_WIREFRAME
Expand Down
4 changes: 4 additions & 0 deletions src/shaders/terrain_raster.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ void main() {
gl_Position = u_matrix * vec4(decodedPos, elevation, 1.0);

#ifdef FOG
#ifdef ZERO_EXAGGERATION
v_fog_pos = fog_position(decodedPos);
#else
v_fog_opacity = fog(fog_position(vec3(decodedPos, elevation)));
#endif
#endif

#ifdef RENDER_SHADOWS
vec3 pos = vec3(decodedPos, elevation);
Expand Down

0 comments on commit 5914011

Please sign in to comment.