~ | First denoising attempt

This commit is contained in:
RedShip
2025-02-07 20:17:43 +01:00
parent 2b879218ed
commit 47bf193752
4 changed files with 44 additions and 3 deletions

View File

@ -239,6 +239,10 @@ void main()
if (pixel_coords.x >= int(u_resolution.x) || pixel_coords.y >= int(u_resolution.y)) if (pixel_coords.x >= int(u_resolution.x) || pixel_coords.y >= int(u_resolution.y))
return; 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)) if (u_pixelisation != 1 && (uint(pixel_coords.x) % u_pixelisation != 0 || uint(pixel_coords.y) % u_pixelisation != 0))
return; return;

View File

@ -5,5 +5,41 @@ out vec4 FragColor;
uniform sampler2D screenTexture; uniform sampler2D screenTexture;
void main() { void main() {
FragColor = texture(screenTexture, TexCoords); vec2 uv = TexCoords;
float incr_x = 1.0 / 1920.0 ;
float incr_y = 1.0 / 1080.0 ;
int iteration = 5;
if (iteration == 0) {FragColor = texture(screenTexture, uv);return;}
vec4 color = vec4(vec3(0.), 1.0);
float totalWeight = 0.;
float kernel[5] = float[5](1.0/16.0, 1.0/4.0, 3.0/8.0, 1.0/4.0, 1.0/16.0);
for (int i = 0; i < iteration; i++)
{
int holes = int(pow(2, i));
for (int x = -2; x <= 2; x++)
{
for (int y = -2; y <= 2; y++)
{
vec2 current_uv = uv + vec2(x * holes * incr_x, y * holes * incr_y);
// if (current_uv.x < 0. || current_uv.y < 0. || current_uv.x > 1. || current_uv.y > 1.)
// continue ;
// current_uv = clamp(current_uv, vec2(0.), vec2(1.));
float weight = kernel[x+2] * kernel[y+2];
totalWeight += weight;
color += texture(screenTexture, current_uv) * weight;
}
}
}
FragColor = color / totalWeight;
} }

View File

@ -16,6 +16,7 @@ Ray portalRay(Ray ray, hitInfo hit)
if (dot(portal_1.normal, portal_2.normal) > 0.0) if (dot(portal_1.normal, portal_2.normal) > 0.0)
{ {
mat3 reflection = mat3(1.0) - 2.0 * outerProduct(portal_2.normal, portal_2.normal); mat3 reflection = mat3(1.0) - 2.0 * outerProduct(portal_2.normal, portal_2.normal);
reflection *= inverse(mat3(1));
rotation *= reflection; rotation *= reflection;
} }

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */ /* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/15 14:00:38 by TheRed #+# #+# */ /* Created: 2024/10/15 14:00:38 by TheRed #+# #+# */
/* Updated: 2025/02/06 02:07:47 by tomoron ### ########.fr */ /* Updated: 2025/02/07 18:35:33 by ycontre ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */