I want to get the color of a pixel of a texture in a shader.
This is my first time using shaders, i have seen some tutorials to understand abit of the shading lenguaje in unity.
Basically the idea would be;
-
Accessing a texture in the shader
-
Check the color of the texture at a pixel as if it was a Color32 in c# instead of a float4, something like;
if(col == (125,55,35,255))
{
//do something
}
i have tried
fixed4 frag (v2f i) : SV_Target
{
fixed4 col2 = tex2D(_MainTex, i.uv);
if(col2.r == .6)
{
col2.g = .1;
}
return col2
}
So this will change the color, but i don’t want to check a float but the color as if it was a Color32(range from 0-255 instead of 0-1), since i can easily check the color value (for example 125,55,35,255 in that specific pixel) i have in a predetermined texture in a program like aseprite, to use as a some sort of color coded texture to do something when i’m checking a specific color in that texture.
I appreciate any suggestions since i have no idea how shaders work.