Hi there.
Just starting with ShaderLab and I want to make a shader that:
- you giva a colour
- you give a texture with a with a transparent background
- and that multiplies these two with each other and the background.
I’m currently at a loss because I don’t really get how to multiply with the rendered background.
I found a thread on a nice and simple multiply effect without texture (http://forum.unity3d.com/threads/52831-Multiply-Shader-with-tint-colour), but as I said I would like to use a texture to define a shape that is to be rendered with a multiply effect.
Currently I have a simply alpha diffuse shader. Now I want to multiply it on the rendered background.
Who would like to help me out?
Shader "Custom/MultiplyColourFromAlphaTexture" {
Properties {
_MainColor ("Color", Color) = (1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
fixed4 _MainColor;
struct Input {
float2 uv_MainTex;
fixed4 _MainColor;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 tex = tex2D (_MainTex, IN.uv_MainTex);
tex.rgb *= _MainColor;
o.Albedo = tex.rgb;
o.Alpha = tex.a;
}
ENDCG
}
}