// Unlit shader. Simplest possible textured shader.
// - SUPPORTS lightmap
// - no lighting
// - no per-material color
Shader "Mobile/UnlitFoW(Supports Lightmap)" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 100
// Non-lightmapped
Pass {
Tags { "LightMode" = "Vertex" }
Lighting Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float4 _Color;
sampler2D _MainTex;
sampler2D _FogTex0; //fog texture variable
sampler2D _FogTex1; //fog texture variable
uniform float4 _Params; //fog variable
uniform half4 _Unexplored; //fog variable
uniform half4 _Explored; //fog variable
float4 _MainTex_ST;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float2 lmap : TEXCOORD1;
float2 fog : TEXCOORD2; // this is a new line
};
half4 frag (v2f i) : COLOR
{
half4 c = tex2D (_MainTex, i.uv);
half4 fog = lerp(tex2D(_FogTex0, i.fog), tex2D(_FogTex1, i.fog), _Params.w);
c = lerp(lerp(c * _Unexplored, c * _Explored, fog.g), c, fog.r); // where c is the fixed4 to return
return c;// * _Color;
}
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
float4 worldPos = mul (_Object2World, v.vertex);
o.fog.xy = worldPos.xz * _Params.z + _Params.xy;
return o;
}
ENDCG
//SetTexture [_MainTex] { combine texture }
}
// Lightmapped, encoded as dLDR
Pass {
Tags { "LightMode" = "VertexLM" }
Lighting Off
BindChannels {
Bind "Vertex", vertex
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord", texcoord1 // main uses 1st uv
}
SetTexture [unity_Lightmap] {
matrix [unity_LightmapMatrix]
combine texture
}
SetTexture [_MainTex] {
combine texture * previous DOUBLE, texture * primary
}
}
// Lightmapped, encoded as RGBM
Pass {
Tags { "LightMode" = "VertexLMRGBM" }
Lighting Off
BindChannels {
Bind "Vertex", vertex
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord", texcoord1 // main uses 1st uv
}
SetTexture [unity_Lightmap] {
matrix [unity_LightmapMatrix]
combine texture * texture alpha DOUBLE
}
SetTexture [_MainTex] {
combine texture * previous QUAD, texture * primary
}
}
}
}