hello everyone, i'm trying to do something basic in a custom shader script, but am unable to do so. Basically, when i apply a texture, the black colored part of the texture is transparent or not rendered by the shader ( standard behavior ). Now, I want another color to show/render on the black/unseen part. In this I want the " Color 2 " which is dark red to show up on the texture blacks. I've tried searching it up, but there's nothing proper or some thread from years ago, any help will be appreciated. Thank you.
Hi @mouusrusai, Thanks for the reply but i am unable to implement it in my code. Right now, this is what applies the "blue" color to the white part of the texture in the above image. How would i go about to add your line to this? void surf (Input IN, inout SurfaceOutputStandard o) { fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; o.Alpha = c.a; }
void surf (Input IN, inout SurfaceOutputStandard o) { fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; c.rgb=lerp(c.rgb, fixed3(1,0,0), 1-Luminance(c.rgb)); o.Albedo = c.rgb; o.Alpha = c.a; } Also you may use "if" or "step" if(c.r<0.1) c.rgb = fixed3(1,0,0); or c.rgb=lerp(c.rgb, fixed3(1,0,0), step(1-Luminance(c.rgb), 0.1)); or c.rgb+=fixed3(1,0,0)*step(1-Luminance(c.rgb), 0.1);
Wasn't working with the texture I was testing this with, used the actual texture that i'll be working upon and it works perfectly! Thank you for you time & knowledge.