This commit is contained in:
MihailRis 2025-06-10 22:50:04 +03:00
parent d030fbc3d5
commit 11283f9a33

View File

@ -5,7 +5,6 @@ uniform sampler2DShadow u_shadows[2];
uniform mat4 u_shadowsMatrix[2]; uniform mat4 u_shadowsMatrix[2];
uniform int u_shadowsRes; uniform int u_shadowsRes;
uniform bool u_blurShadows;
float calc_shadow() { float calc_shadow() {
float shadow = 1.0; float shadow = 1.0;
@ -22,39 +21,32 @@ float calc_shadow() {
shadow = 0.0; shadow = 0.0;
// TODO: optimize
if (dot(a_realnormal, u_sunDir) < 0.0) { if (dot(a_realnormal, u_sunDir) < 0.0) {
if (u_blurShadows || true) { if (a_distance > 128) {
if (a_distance > 64) { for (int y = -1; y <= 1; y++) {
for (int y = -1; y <= 1; y++) { for (int x = -1; x <= 1; x++) {
for (int x = -1; x <= 1; x++) { shadow += texture(
shadow += texture( u_shadows[1],
u_shadows[1], wprojCoords.xyz +
wprojCoords.xyz + vec3(x, y, -(abs(x) + abs(y))) /
vec3(x, y, -(abs(x) + abs(y))) / u_shadowsRes
u_shadowsRes );
);
}
} }
shadow /= 9;
} else {
for (int y = -2; y <= 2; y++) {
for (int x = -2; x <= 2; x++) {
shadow += texture(
u_shadows[0],
projCoords.xyz +
vec3(x, y, -(abs(x) + abs(y))) /
u_shadowsRes * 1.0
);
}
}
shadow /= 25;
} }
shadow /= 9;
} else { } else {
if (a_distance > 32.0) { for (int y = -2; y <= 2; y++) {
shadow = texture(u_shadows[1], wprojCoords.xyz); for (int x = -2; x <= 2; x++) {
} else { shadow += texture(
shadow = texture(u_shadows[0], projCoords.xyz); u_shadows[0],
projCoords.xyz +
vec3(x, y, -(abs(x) + abs(y))) /
u_shadowsRes * 1.0
);
}
} }
shadow /= 25;
} }
shadow = shadow * 0.5 + 0.5; shadow = shadow * 0.5 + 0.5;
} else { } else {