Shader "TA/Snow"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_AddTex ("AddTex",2D) = "white" {}
_BumpMap("BumpMap",2D)= "white" {}
_SnowStep(" Snow",Range(0,1))=0.5
_LightDir("LightDir",vector) = (0,0,1,1)
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
half3 vnormal : NORMAL;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
fixed3 normal : NORMAL;
};
sampler2D _MainTex,_AddTex,_BumpMap;
fixed _SnowStep;
half4 _MainTex_ST,_LightDir;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.normal = v.vnormal;
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 s = tex2D(_AddTex, i.uv);
half3 customColor = step(1-_SnowStep*s.a,i.normal.y);
fixed4 col = tex2D(_MainTex, i.uv);
fixed3 bum = UnpackNormal(tex2D(_BumpMap, i.uv) * _LightDir.w);
half sDir = max(0,dot(_LightDir,bum));
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return half4((col.rgb*sDir + customColor*s*0.7),1);
}
ENDCG
}
}
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。