mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 10:48:34 +02:00
~ | Pass system shader
This commit is contained in:
20
shaders/denoising.glsl
Normal file
20
shaders/denoising.glsl
Normal file
@ -0,0 +1,20 @@
|
||||
#version 430 core
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16) in;
|
||||
layout(binding = 0, rgba32f) uniform image2D read_texture;
|
||||
layout(binding = 2, rgba32f) uniform image2D write_texture;
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
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;
|
||||
|
||||
vec4 color = imageLoad(read_texture, pixel_coords);
|
||||
|
||||
color *= 0.5;
|
||||
|
||||
imageStore(write_texture, pixel_coords, color);
|
||||
}
|
@ -5,41 +5,5 @@ out vec4 FragColor;
|
||||
uniform sampler2D screenTexture;
|
||||
|
||||
void main() {
|
||||
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;
|
||||
FragColor = texture(screenTexture, TexCoords);
|
||||
}
|
Reference in New Issue
Block a user