Unity3d《Shader篇》地球旋转上空悬浮云层
记得把纹理设置成Repeat
Shader "Custom/Earth" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _CloudTex ("Base (RGB)", 2D) = "white" {} } SubShader { Pass{ Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; sampler2D _CloudTex; float4 _MainTex_ST; struct Input { float4 pos : SV_POSITION; float2 uv; }; Input vert(appdata_base v) { Input output; output.pos = mul(UNITY_MATRIX_MVP,v.vertex); output.uv = TRANSFORM_TEX (v.texcoord, _MainTex); return output; } half4 frag (Input i):COLOR { float2 uv = i.uv; uv.x=i.uv.x + -_Time*0.3; half4 col = tex2D(_MainTex,uv); float2 uv_cloud = i.uv; uv_cloud.x=i.uv.x+ -_Time*0.8; half4 tex_clouddDepth = tex2D(_CloudTex,uv_cloud); half4 col_cloud = float4(1,1,1,0)*(tex_clouddDepth.x); return lerp(col,col_cloud,0.5f); } ENDCG } } FallBack "Diffuse" }