What are the Debug Tools for GD-Shader?

Godot Version

4.3

Question

I’ve created a GD Shader, and it compiles fine but when I set the albedo of the object it doesn’t do what I expect. This is fine, I’m more than happy to debug it myself - but I can’t figure out how? You can’t insert break points into the gdshader code to run it step by step, and you can’t insert print statements to see what values you’re getting at certain steps. How do people figure out what their shaders are doing at every step?

debug shaders by viewing what you want to debug as a texture, on ALBEDO, or COLOR

I’ve already done that, and that’s how I know it’s broken because the albedo in the editor isn’t doing what it’s supposed to. That’s why I want to look at the values being passed in the code before I set it as albedo.

Can you post the shader here (and a screenshot of its output)?

shader_type spatial;

uniform sampler2D screen_texture : hint_screen_texture;

// Apply the magnify affect here.
float distort_position(float normalised_position) {
float adjustment = normalised_position * normalised_position;
return normalised_position < 0.0 ? normalised_position + adjustment : normalised_position - adjustment;
}

void fragment() {
// Find the distance relative to the objects centre.
vec2 distance_from_centre = vec2(0.5, 0.5) - vec2(NORMAL.x, NORMAL.y);

// Find the position of the adjusted pixel, in terms of the normalised position
vec2 relative_normalised = vec2(distort_position(distance_from_centre.x),
							 distort_position(distance_from_centre.y)) + vec2(0.5, 0.5);

vec2 distorted_pixel = (MODEL_MATRIX * vec4(relative_normalised, NORMAL.z, 1.0)).xy;

// Sample the pixture from the screen texture.
vec3 c = textureLod(screen_texture, distorted_pixel, 0.0).rgb;

// Set the albedo of this pixel. If you want to apply further modifications,
// do it to c here.
ALBEDO = c;

}

Meant to be doing a magnify effect for the lens, but instead its setting to a solid colour (that changes as the camera moves).

image

Even if you can fix the problem with my code, my question is HOW can I debug my code myself? I want to write a bunch more, more complicated shaders, and if they aren’t working, I don’t want to have to rely on asking forums.

Bumping this as I’ve made no progress on figuring out debugging tools.