Hi, how I can blend multiple textures in CG CODE ?
Shader properties:
_MainTex ("Base Texture", 2D) = "white" {}
_Texture2 ("Blend Texture 1", 2D) = "white" {}
_Blend1 ("Blend between Base and Blend 1 textures", Range (0, 1) ) = 0
SubShader {
Tags { "RenderType"="Opaque" }
LOD 400
CGPROGRAM
#pragma surface surf BlinnPhong
I need bleed _MainTex nad _Texture2 by _Blend1 here in CG CODE
#pragma target 3.0
ENDCG
}
Simple:
// make sure you declare _MainTex and your other variables under CGPROGRAM
sampler2D _MainTex;
sampler2D _Texture2;
float _Blend1;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 mainCol = tex2D(_MainTex, IN.uv_MainTex);
fixed4 texTwoCol = tex2D(_Texture2, IN.uv_MainTex);
fixed4 output = lerp(mainCol, texTwoCol, _Blend1);
o.Albedo = output.rgb;
o.Alpha = output.a;
}
Have a look at the CGScript standard library- if you’re familiar with all of those functions (and there’s not that many of them), you’ll be able to do quite a lot with simple shaders.