feat: deferred lighting (WIP)

This commit is contained in:
MihailRis
2025-06-14 22:43:18 +03:00
parent 2ad076bec3
commit e849d5e9b7
10 changed files with 105 additions and 12 deletions
+1
View File
@@ -5,6 +5,7 @@ uniform sampler2D u_screen;
uniform sampler2D u_position;
uniform sampler2D u_normal;
uniform sampler2D u_noise;
uniform sampler2D u_ssao;
uniform sampler2D u_shadows;
uniform ivec2 u_screenSize;
-1
View File
@@ -1,4 +1,3 @@
vec4 effect() {
//return vec4(vec3(pow(texture(u_shadows, v_uv).r, 5.0) * 1000.0), 1.0);
return texture(u_screen, v_uv);
}
@@ -0,0 +1,11 @@
vec4 effect() {
float ssao = 0.0;
for (int y = -1; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
vec2 offset = vec2(x, y) / u_screenSize;
ssao += texture(u_ssao, v_uv + offset * 2.0).r;
}
}
ssao /= 9.0;
return vec4(texture(u_screen, v_uv).rgb * mix(1.0, ssao, 1.0), 1.0);
}
+4 -5
View File
@@ -1,13 +1,12 @@
#param vec3 u_ssaoSamples[64]
#param int u_kernelSize = 16
#param float u_radius = 0.25
#param float u_bias = 0.025
#param float u_radius = 0.2
#param float u_bias = 0.006
vec4 effect() {
vec2 noiseScale = u_screenSize / 4.0;
vec3 position = texture(u_position, v_uv).xyz;
vec3 color = texture(u_screen, v_uv).rgb;
vec3 normal = texture(u_normal, v_uv).xyz;
vec3 randomVec = normalize(texture(u_noise, v_uv * noiseScale).xyz);
@@ -31,7 +30,7 @@ vec4 effect() {
}
occlusion = min(1.0, 1.05 - (occlusion / u_kernelSize));
float z = -position.z * 0.02;
float z = -position.z * 0.01;
z = max(0.0, 1.0 - z);
return vec4(color * mix(1.0, occlusion, z), 1.0);
return vec4(occlusion, 0.0, 0.0, 1.0);
}