| 1 |
Shader "Unlit/NewUnlitShader" |
| 2 |
{ |
| 3 |
Properties |
| 4 |
{ |
| 5 |
_MainTex ("Texture", 2D) = "white" {} |
| 6 |
} |
| 7 |
SubShader |
| 8 |
{ |
| 9 |
Tags { "RenderType"="Opaque" } |
| 10 |
LOD 100 |
| 11 |
|
| 12 |
Pass |
| 13 |
{ |
| 14 |
CGPROGRAM |
| 15 |
#pragma vertex vert |
| 16 |
#pragma fragment frag |
| 17 |
// make fog work |
| 18 |
#pragma multi_compile_fog |
| 19 |
|
| 20 |
#include "UnityCG.cginc" |
| 21 |
|
| 22 |
struct appdata |
| 23 |
{ |
| 24 |
float4 vertex : POSITION; |
| 25 |
float2 uv : TEXCOORD0; |
| 26 |
}; |
| 27 |
|
| 28 |
struct v2f |
| 29 |
{ |
| 30 |
float2 uv : TEXCOORD0; |
| 31 |
UNITY_FOG_COORDS(1) |
| 32 |
float4 vertex : SV_POSITION; |
| 33 |
}; |
| 34 |
|
| 35 |
sampler2D _MainTex; |
| 36 |
float4 _MainTex_ST; |
| 37 |
|
| 38 |
v2f vert (appdata v) |
| 39 |
{ |
| 40 |
v2f o; |
| 41 |
o.vertex = UnityObjectToClipPos(v.vertex); |
| 42 |
o.uv = TRANSFORM_TEX(v.uv, _MainTex); |
| 43 |
UNITY_TRANSFER_FOG(o,o.vertex); |
| 44 |
return o; |
| 45 |
} |
| 46 |
|
| 47 |
fixed4 frag (v2f i) : SV_Target |
| 48 |
{ |
| 49 |
// sample the texture |
| 50 |
fixed4 col = tex2D(_MainTex, i.uv); |
| 51 |
// apply fog |
| 52 |
UNITY_APPLY_FOG(i.fogCoord, col); |
| 53 |
return col; |
| 54 |
} |
| 55 |
ENDCG |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
// From https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html |
| 61 |
|