Skip to content

Commit

Permalink
fix clouds and fog for translucent
Browse files Browse the repository at this point in the history
  • Loading branch information
Godlander committed Jun 22, 2024
1 parent 41f2998 commit ccaa5e4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion assets/minecraft/shaders/core/render/clouds.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ void main() {
color *= vertexColor * ColorModulator * vec4(1,1,1,0.6);
color.rgb = mix(color.rgb, pow(FogColor.rgb, vec3(2)), 0.5 * (1.0 - yval));
if (color.a < 0.1) discard;
fragColor = linear_fog_translucent(color, fogDistance, clamp(FogStart*0.8, 0, 256-64), clamp(FogEnd*1.5, 16, 512-64), FogColor);
fragColor = linear_fog_translucent(color, fogDistance, 24, 32, FogColor);
}
2 changes: 1 addition & 1 deletion assets/minecraft/shaders/core/render/clouds.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() {
gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0);

texCoord0 = UV0;
fogDistance = fog_distance(pos, FogShape);
fogDistance = fog_distance(pos, 2);

// try the flatten the cloud shading as much as possible
vec4 col = Color;
Expand Down
15 changes: 9 additions & 6 deletions assets/minecraft/shaders/include/fog.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ float linear_fog_fade(float fogDistance, float fogStart, float fogEnd) {
}

float fog_distance(vec3 pos, int shape) {
if (shape == 0) {
return length(pos);
} else {
float distXZ = length(pos.xz);
float distY = abs(pos.y);
return max(distXZ, distY);
switch (shape) {
case 0:
return length(pos);
case 1:
float distXZ = length(pos.xz);
float distY = abs(pos.y);
return max(distXZ, distY);
case 2:
return length(pos.xz);
}
}

Expand Down
5 changes: 5 additions & 0 deletions assets/minecraft/shaders/include/render/block.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ else {
if (color.a < 0.1) discard;
color = color * vertexColor * ColorModulator;
color = emissive(color, lightColor, Distance);

#ifdef TRANSLUCENT
fragColor = linear_fog_translucent(color, fogDistance, FogStart, FogEnd, FogColor);
#else
fragColor = linear_fog(color, fogDistance, FogStart, FogEnd, FogColor);
#endif
}
}
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
v++
3.3
Shaders:
+Fix clouds shader
+Fix fog for translucent blocks



3.2
+Update to 1.21

Expand Down

0 comments on commit ccaa5e4

Please sign in to comment.