Hey everyone
I’m trying to do something very simple : sample 2 different textures from the same shader
Strangely it works if I have on texture
As soon as I toggle the code to manage the 2 textures then I can’t get anything except black
So basically it’s like if the shader was only able to manage one texture at a time…
Thanks for any help… I really have no idea what’s going on
ps: I’m using unity 2.6 on win7 with a pretty good gpu
Shader "IcebergHigh Shader" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SkyCube ("Sky Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
_NormalMap ("Normal Map", 2D) = "white" {}
_SnowIceTrTex ("Snow Ice Transition Tex", 2D) = "white" {}
}
SubShader
{
// Pixel lights
Pass
{
Name "BASE"
Tags { "LightMode" = "Pixel" }
Lighting On
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
//#include "AutoLight.cginc"
uniform samplerCube _SkyCube;
uniform sampler2D _NormalMap;
uniform float4 _NormalMap_ST;
uniform sampler2D _SnowIceTrTex;
uniform float4 _SnowIceTrTex_ST;
struct v2f
{
float4 position : POSITION;
float4 uv : TEXCOORD0;
float3 normalWS : TEXCOORD1;
float3 viewDir : TEXCOORD2;
float3 lightDir : TEXCOORD3;
};
v2f vert ( appdata_tan i )
{
v2f o;
o.position = mul( glstate.matrix.mvp, i.vertex);
o.uv.xy = TRANSFORM_TEX( i.texcoord, _NormalMap );
o.uv.zw = TRANSFORM_TEX( i.texcoord, _SnowIceTrTex );
float4 normalWS4 = mul( _Object2World, float4(i.normal,0) );
o.normalWS = normalWS4.xyz;
float3 binormal = cross( i.normal, i.tangent.xyz ) * i.tangent.w;
float3x3 rotation = float3x3( i.tangent.xyz, binormal, i.normal );
o.viewDir = mul( rotation, ObjSpaceViewDir( i.vertex ) );
o.lightDir = mul( rotation, ObjSpaceLightDir( i.vertex ) );
return o;
}
float4 frag( v2f i ) : COLOR
{
float3 finalCol = 0;
// COMMENT THIS and it won't work anymore
/*
float4 bumpMap = tex2D(_NormalMap, i.uv.xy);
float3 normal = bumpMap.rgb * 2 - 1;
normal = normalize( normal );
float3 viewDir = normalize(i.viewDir);
float3 lightDir = normalize(i.lightDir);
float3 reflectVec = reflect( normal, viewDir );
*/
float4 snowIceTr = tex2D( _SnowIceTrTex, i.uv.zw );
return snowIceTr;
}
ENDCG
}
}
}