Unity之通过Shader实现雪景

来源:互联网 发布:网络攻击追踪溯源 编辑:程序博客网 时间:2024/06/03 20:57

左边是下雪后的效果

// Simplified Diffuse shader. Differences from regular Diffuse one:// - no Main Color// - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH.Shader "Mobile/Snow Diffuse" {Properties {_MainTex ("Base (RGB)", 2D) = "white" {}_SnowStep(" Snow",Range(0,1))=0.5}SubShader {Tags { "RenderType"="Opaque" }LOD 150CGPROGRAM#pragma surface surf Lambert vertex:vert noforwardadd noshadowsampler2D _MainTex;fixed _SnowStep;struct Input {float2 uv_MainTex;fixed3 customColor;fixed4 vertexColor:COLOR;//顶点颜色};void vert (inout appdata_full v, out Input o) {      UNITY_INITIALIZE_OUTPUT(Input,o);      o.customColor = step(1-_SnowStep,v.normal.y)*fixed3(1,1,1);}void surf (Input IN, inout SurfaceOutput o) {fixed4 c = tex2D(_MainTex, IN.uv_MainTex);o.Albedo = c.rgb*IN.vertexColor+IN.customColor;o.Alpha = c.a;}ENDCG}Fallback "Mobile/VertexLit"}
如果不需要顶点颜色,可以自己去掉

0 0
原创粉丝点击