Godot 4: Shader debugging (tutorial)

preview_player
Показать описание

#godot #godot4 #godotengine #shaders

Hi everyone! I think every shader developer has at some point found themselves in a situation where they needed to determine certain values in the fragment function, especially when the shader wasn't behaving as expected. The problem is that the shader runs on the GPU, so we don't have anything like an output console available. So, how can we solve that? There are some options, and I’ll demonstrate one of them in this tutorial.
Рекомендации по теме
Комментарии
Автор

This video came out at the perfect time ❤

koyomojo
Автор

This is incredibly useful. Thank you very much for taking the time to create this tutorial. FYI there appears to be some floating point precision errors that get really bad when dealing with negative numbers. I think this code deals with it better, if it helps any one else.
// print_number() between and -29999.99 without floating point percision
// errors, if you go beyond these values in either direction we will incur inaccuracies.
float print_number(vec2 uv, float value) {
float result = 0.0;
float int_part = 0.0;
float fract_part = 0.0;
bool negative_number = false;
if (value < 0.0) {
negative_number = true;
int_part = + floor(value);
fract_part = 1.0 - fract(value);
}
else {
int_part = floor(value);
fract_part = fract(value);
}
result += print_part(uv, int_part, true);
// Below we handle the decimal portion of the number.
if (fract_part > 0.0001){
result += square(uv - vec2(-0.22, 0.3));
uv.x -= 0.1;
result += print_part(uv, fract_part * false);
}
return result;
}

wolfrage
Автор

Have you consider other options/shops for selling your content, like Itch?

krzysztfus
Автор

Or, you know, just output a flat debug color. It's not as readable of course, but requires literally just one line of code.

thegameissimple
join shbcf.ru