Skip to content

Commit

Permalink
Merge pull request #2097 from embeddedt/fog-fix
Browse files Browse the repository at this point in the history
Improve fog shader parity to match vanilla
  • Loading branch information
IMS212 authored Oct 6, 2023
2 parents 81b3e6e + 1b866ee commit dff676d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/resources/assets/sodium/shaders/include/fog.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const int FOG_SHAPE_CYLINDRICAL = 1;

vec4 _linearFog(vec4 fragColor, float fragDistance, vec4 fogColor, float fogStart, float fogEnd) {
#ifdef USE_FOG
float factor = smoothstep(fogStart, fogEnd, fragDistance * fogColor.a); // alpha value of fog is used as a weight
vec3 blended = mix(fragColor.rgb, fogColor.rgb, factor);
if (fragDistance <= fogStart) {
return fragColor;
}
float factor = fragDistance < fogEnd ? smoothstep(fogStart, fogEnd, fragDistance) : 1.0; // alpha value of fog is used as a weight
vec3 blended = mix(fragColor.rgb, fogColor.rgb, factor * fogColor.a);

return vec4(blended, fragColor.a); // alpha value of fragment cannot be modified
#else
Expand Down

0 comments on commit dff676d

Please sign in to comment.