+ | Imgui denoise

This commit is contained in:
TheRedShip
2025-02-08 23:38:49 +01:00
parent 39196a00ff
commit ee95d9954a
9 changed files with 88 additions and 28 deletions

View File

@ -198,8 +198,8 @@ vec3 pathtrace(Ray ray, inout uint rng_state)
if (i == 0)
{
imageStore(normal_texture, ivec2(gl_GlobalInvocationID.xy), vec4(hit.normal, 1.0));
imageStore(position_texture, ivec2(gl_GlobalInvocationID.xy), vec4(hit.position, 1.0));
imageStore(normal_texture, ivec2(gl_GlobalInvocationID.xy), vec4(normalize(hit.normal), 1.0));
imageStore(position_texture, ivec2(gl_GlobalInvocationID.xy), vec4(normalize(hit.position), 1.0));
}
float p = max(color.r, max(color.g, color.b));
@ -248,10 +248,6 @@ void main()
if (pixel_coords.x >= int(u_resolution.x) || pixel_coords.y >= int(u_resolution.y))
return;
// if (pixel_coords.x % 50 == 0 || pixel_coords.y % 50 == 0)
// imageStore(output_image, pixel_coords, vec4(1.,0.,0., 0.));
// return ;
if (u_pixelisation != 1 && (uint(pixel_coords.x) % u_pixelisation != 0 || uint(pixel_coords.y) % u_pixelisation != 0))
return;
@ -260,7 +256,7 @@ void main()
vec2 jitter = randomPointInCircle(rng_state) * 1;
vec2 uv = ((vec2(pixel_coords) + jitter) / u_resolution) * 2.0 - 1.0;;
vec2 uv = ((vec2(pixel_coords) + jitter) / u_resolution) * 2.0 - 1.0;
uv.x *= u_resolution.x / u_resolution.y;
Ray ray = initRay(uv, rng_state);

View File

@ -11,15 +11,15 @@ layout(binding = 4, rgba32f) uniform image2D normal_texture;
uniform vec2 u_resolution;
uniform int u_pass;
uniform float u_c_phi;
uniform float u_p_phi;
uniform float u_n_phi;
void main()
{
ivec2 pixel_coords = ivec2(gl_GlobalInvocationID.xy);
if (pixel_coords.x >= int(u_resolution.x) || pixel_coords.y >= int(u_resolution.y))
return;
float c_phi = 1.0;
float p_phi = 1.0;
float n_phi = 1.0;
int holes = int(pow(2, u_pass));
@ -49,16 +49,15 @@ void main()
// Color weight
float colorDist = distance(color_center, color_sample);
float w_c = exp(-colorDist / c_phi);
float w_c = exp(-colorDist / u_c_phi);
// Position weight
float posDist = distance(position_center, position_sample);
float w_p = exp(-posDist / p_phi);
float w_p = exp(-posDist / u_p_phi);
// Normal weight
float normalDist = distance(normal_center, normal_sample);
float w_n = exp(-normalDist / n_phi);
float w_n = exp(-normalDist / u_n_phi);
float weight = kernel[x+2] * kernel[y+2] * w_c * w_p * w_n;