This is a devlog with much time because first i forgot to devlog and second because i had one huge problem and i was working on it for like two and a half hour (also much with ai on that problem, ill admit that i was furious after 1,5 hours) So yeah.
Whats new: Shadow Rewrite, Color Grading, Lighting, Wave update.
Starting Small: I made Waves faster to make them more visible.
Before:
float wave = sin(p.x * 1.20 + frameTimeCounter * 2.50) * 0.01;
Now:
float wave = sin(p.x * 1.20 + frameTimeCounter * 2.50) * 0.05;
Like seen in the last Devlogs, the shadow never really looked nice. Before i used like manual 5 samplig grid to soften the shadows which is okay for performance but it looks weird.
In the new version i completely threw that out. Instead I decided to move over to PCF Percentage Closer FIltering (was claudes idea). It makes the shadow look soft and way smoother.
vec3 pcf(vec4 clip) {
ivec2 s = ivec2(texcoord * vec2(viewWidth, viewHeight)) % 64;
float a = texelFetch(noisetex, s, 0).r * 6.2831853;
mat2 r = mat2(cos(a), -sin(a), sin(a), cos(a));
vec3 sum = vec3(0.0);
float n = 0.0;
for (int x = -PCF_RANGE; x <= PCF_RANGE; x++) {
for (int y = -PCF_RANGE; y <= PCF_RANGE; y++) {
vec4 p = clip + vec4(r * (vec2(x, y) * (PCF_RADIUS / 8092.0)), -0.002, 0.0);
p.xyz = warpShadowClipPos(p.xyz);
p.xyz = p.xyz / p.w * 0.5 + 0.5;
if (all(greaterThanEqual(p.xy, vec2(0.0))) && all(lessThanEqual(p.xy, vec2(1.0)))) {
sum += sh(p.xyz);
n += 1.0;
}
}
}
return n > 0.0 ? sum / n : vec3(1.0);
}
While rewriting the composite I had multiple transparent bugs (seen in the pictures below). Basically my palyer hand and mobs were see through.
The mob bug was pretty easy fix. gbuffers_entities.vsh wasnt actually passing down normal vectors to the fragment shader. (This was also found by gemini not me)
For the Hand fix, i ran into a problem becuase it was the fault of composite.fsh. I was doing some weird depth buffer checks that basically told the shader to ignore the hand and draw the world behind it. (And again this was found by gemini)
In the composite shader, I had this depth check to filter out water and sky:
if (d0 != d2) {
color = albedo;
return;
}
By using if (d0 == 1.0 || d0 < d1 || d0 != d2) the shader now correctly renders it. The Problem was becase how Miencraft renders the hand. The hand renders into depthtex2 but it usually doesnt render into depthtex0. Because the hand depth in d2 was different freom the sky block depthh in d0 it triggered and the composite shader skipped drawing the hand. ( I hope I understood it right).
Then came the 2.5 hour problem 😩:
Random blocky shadows appeated on water (seen in pictures). Because the problem didnt occured before and because I just reworked the composite i tried everything. I changed things back to old. asked AI nothing helped. In the end it was because gbuffers_water.vsh was calcuilating the shadow coordiantes without applying the shadow map distorion. It was trying to read warped shadow map using undistoreted coordinates. nce I added the #include “libs/distort.glsl” it worked… (again found by gemini, i troubleshooted ALOT with it).
Lasty i addewd Color Grading tweaks in final.fsh. Just more vibrance and contras.