vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
{
vec4 c = Texel(texture, texture_coords); // This reads a color from our texture at the coordinates LOVE gave us (0-1, 0-1)
return vec4(vec3(1.0, 1.0, 1.0) * (max(c.r, max(c.g, c.b))), 0.2); // This just returns a white color that's modulated by the brightest color channel at the given pixel in the texture. Nothing too complex, and not exactly the prettiest way to do B&W :P
}
I've not been able to find out how to make a shader that just goes:
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
{
vec4 c = Texel(texture, texture_coords) * color;
if (c.r == 1.0 && c.g == 1.0 && c.b == 1.0) { // if white, if you want more tolerancy, use something like c.r >= 0.9
c.r = 0.0; c.b = 0.0; // set red and blue component to 0, so only green component is left
}
return c;
}
Edit: decimals for colors
Last edited by Andlac028 on Tue Nov 22, 2022 7:07 pm, edited 1 time in total.
if (c.r + c.g + c.b >= 3.0) { // you can set a threshold by changing 3.0 to a lower value like 2.7 or so
c.r = 0.0; c.g = 0.0; c.b = 1.0; // don't forget decimal notation for color values! And it's a good idea to set green if you're using a threshold less than 3.0
}
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.