Unity之通过Shader实现雪景

左边是下雪后的效果

// 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 150

CGPROGRAM
#pragma surface surf Lambert vertex:vert noforwardadd noshadow

sampler2D _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"
}
如果不需要顶点颜色,可以自己去掉

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试