Scaling the effects of a shader

Godot Version

4.3

Question

Hello,
I’ve made a compute shader that works on a pixel by pixel basis, and does effects based on a given pixel’s neighbors.
The problem is when I scale up the resolution the effect appears much smaller.

Is there a recommended way to approach this? I was thinking maybe downscaling the texture just for shader calculations, but I think it would just look low resolution…

Thank you!

Could you provide more information, what are you computing? Can you share screenshots of the effect? Is this part of 2D, 3D, or Control nodes?

1 Like

Here’s the basic glsl code, I’m trying to create a texture that holds the gradient change of color in the red and green channels

vec4 u_color_image = imageLoad(color_image, uv+ ivec2(0,1));
float u_color =  u_color_image.r + u_color_image.g + u_color_image.b;

vec4 b_color_image = imageLoad(color_image, uv+ ivec2(0,-1));
float b_color =  b_color_image.r + b_color_image.g + b_color_image.b;

vec4 l_color_image = imageLoad(color_image, uv+ ivec2(-1,0));
float l_color =  l_color_image.r + l_color_image.g + l_color_image.b;

vec4 r_color_image = imageLoad(color_image, uv+ ivec2(1,0));
float r_color =  r_color_image.r + r_color_image.g + r_color_image.b;

float up_down = u_color - b_color;
float left_right = l_color - r_color;

color = vec4(up_down, left_right, 0.0,0.0);
imageStore(setter_image, uv, color);

The problem is it looks directly at the 4 pixels neighboring the given pixel it’s running on - it looks good on low resolutions, but on high resolutions that relative gradient is much less as compared to the whole screen.

I’m using it as a CompositorEffect attached to a Camera3D

Thanks

1 Like