- Home /
Shader.SetGlobalTexture() seems not working in Unity 3.1
I wrote simple shader (see below) and I want to set second texture (WarFog) via Shader.SetGlobalTexture("_WarFog", someTexture). I tried to call this inside Update(), Start() or OnPreRender() methods of script, attached to camera. This doesn't work, while SetGlobalColor() working well. And I saw some snippets of code, where people are using SetGlobalTexture(). So, what's wrong?
Shader "BO/WarFoggedObject" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _WarFog;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
half4 wf = tex2D (_WarFog, IN.uv_MainTex);
o.Albedo = c.rgb * wf;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Comment
Answer by Mike 3 · Dec 13, 2010 at 04:41 PM
Looks like you're missing the decleration in the properties block, like _MainTex has.