参考资料:http://www.yaldex.com/open-gl/ch12lev1sec1.html
效果图:
代码:
Shader "Custom/Hemisphere_Lighting" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_SkyColor("Sky Color",Color)=(1,1,1,1)
_GroundColor("Ground Color",Color)=(0,0,0,1)
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float4 _SkyColor;
float4 _GroundColor;
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
fixed4 color : COLOR0;
};
float4 _MainTex_ST;
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _Ma