Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | tyo |
I’m writing a simple shader that changes a single color based on interpolation. It works in-editor but not at runtime and I’m not sure why.
Even if I am mistaken about how editor changes for shaders work at runtime, I made an animation using an AnimationPlayer that modifies the interpolation field at runtime as well with no noticeable changes, and I know I did that right because it works in-editor as well.
I’ve only found a couple really old issues for Godot 2.x that were similar, and the solutions either didn’t seem applicable (largely due to 2.0 deprecation) or I didn’t quite understand how I could apply it to my particular case.
I’m sure I’m missing something minuscule based on that nobody seems to have this issue but any help sorting this out would be appreciated.
Edit: my shader code for reference:
shader_type canvas_item;
uniform float eye_cutoff : hint_range(0.0, 1.0);
uniform vec4 curr_eye_color : hint_color;
vec4 changeEyes(vec4 curr_color)
{
if(curr_eye_color == curr_color)
{
float r = 12.0/255.0;
float g = 123.0/255.0;
float b = 30.0/255.0;
float r2 = 90.0/255.0;
float g2 = 145.0/255.0;
float b2 = 255.0/255.0;
float r_int = r * (1.0 - eye_cutoff) + r2 * eye_cutoff;
float g_int = g * (1.0 - eye_cutoff) + g2 * eye_cutoff;
float b_int = b * (1.0 - eye_cutoff) + b2 * eye_cutoff;
return vec4(r_int,g_int,b_int,1);
}
else
return curr_color;
}
void fragment() {
vec4 curr_color = texture(TEXTURE,UV); // Get current color of pixel
COLOR = changeEyes(curr_color);
}
What are you talking about?
karlessayhelp | 2019-12-24 06:59
I’m not sure how to elucidate further. The colors I’m trying to switch are the eyes if that wasn’t clear. I show how it’s working in the linked video.
tyo | 2019-12-24 13:23