Change Color with Shader
Posted: Tue May 16, 2017 8:58 pm
Hello,
I like to change the color of my character with a shader. I try to modify the glow.glsl shader for löve
Original Code
My current Changings:
the effect of my "improvement" is, that my hero pulsates constantly instead of each color on its own... but how i change the color??
I like to change the color of my character with a shader. I try to modify the glow.glsl shader for löve
Original Code
Code: Select all
extern Image glowImage;
extern float glowTime;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) {
vec3 glowInfo = Texel(glowImage, texture_coords).rgb;
if(glowInfo.r != glowInfo.g) {
float glowStrength = glowTime + glowInfo.b;
if(mod(glowStrength, 2.0) < 1.0) {
glowInfo.b = mod(glowStrength, 1.0);
} else {
glowInfo.b = 1.0 - mod(glowStrength, 1.0);
}
return Texel(texture, texture_coords) * (glowInfo.g + glowInfo.b * (glowInfo.r - glowInfo.g));
}
return vec4(Texel(texture, texture_coords).rgb * glowInfo.r, 1.0);
}
Code: Select all
extern Image glowImage;
extern float glowTime;
extern vec3 Color;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) {
vec3 glowInfo = Color;
if(glowInfo.r != glowInfo.g) {
float glowStrength = glowTime + glowInfo.b;
if(mod(glowStrength, 2.0) < 1.0) {
glowInfo.b = mod(glowStrength, 1.0);
} else {
glowInfo.b = 1.0 - mod(glowStrength, 1.0);
}
return Texel(glowImage, texture_coords) * (glowInfo.g + glowInfo.b * (glowInfo.r - glowInfo.g));
}
return vec4(Texel(texture, texture_coords).rgb * glowInfo.r, 1.0);
}
the effect of my "improvement" is, that my hero pulsates constantly instead of each color on its own... but how i change the color??