第二章 04 魔镜世界"/>
第二章 04 魔镜世界
项目预览图:
ase:
Code:
Shader "ShaderCode/04/Mirror_Stencil_Code"
{Properties{_MainTex ("Texture", 2D) = "white" {}}SubShader{Tags { "Queue"="AlphaTest+10" }Pass{ ZWrite OffColorMask 0Stencil{Ref 1Comp alwaysPass replace}CGPROGRAM#pragma vertex vert#pragma fragment frag#include "UnityCG.cginc"struct appdata{float4 vertex : POSITION;float2 uv : TEXCOORD0;};struct v2f{float2 uv : TEXCOORD0;float4 vertex : SV_POSITION;};sampler2D _MainTex;float4 _MainTex_ST;v2f vert (appdata v){v2f o;o.vertex = UnityObjectToClipPos(v.vertex);o.uv = TRANSFORM_TEX(v.uv, _MainTex);return o;}fixed4 frag (v2f i) : SV_Target{// sample the texturefixed4 col = tex2D(_MainTex, i.uv);return col;}ENDCG}}
}
Shader "ShaderCode/04/Scene_Mirror_Code"
{Properties{_Diffuse ("Texture", 2D) = "white" {}}SubShader{Tags { "Queue"="AlphaTest+20" }LOD 100Pass{Stencil{Ref 1Comp Equal}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;};struct v2f{float2 uv : TEXCOORD0;UNITY_FOG_COORDS(1)float4 vertex : SV_POSITION;};sampler2D _Diffuse;float4 _Diffuse_ST;v2f vert (appdata v){v2f o;o.vertex = UnityObjectToClipPos(v.vertex);o.uv = TRANSFORM_TEX(v.uv, _Diffuse);UNITY_TRANSFER_FOG(o,o.vertex);return o;}fixed4 frag (v2f i) : SV_Target{// sample the texturefixed4 col = tex2D(_Diffuse, i.uv);clip(col.a - 0.5);// apply fogUNITY_APPLY_FOG(i.fogCoord, col);return col;}ENDCG}}
}
Shader "ShaderCode/04/Mirror_Skybox_Code"
{Properties{_MainTex ("Texture", 2D) = "black" {}}SubShader{Tags {"Queue"="AlphaTest+15"}LOD 100Pass{ZTest AlwaysStencil{Ref 1Comp Equal}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;};struct v2f{float2 uv : TEXCOORD0;UNITY_FOG_COORDS(1)float4 vertex : SV_POSITION;};sampler2D _MainTex;float4 _MainTex_ST;v2f vert (appdata v){v2f o;o.vertex = UnityObjectToClipPos(v.vertex);o.uv = TRANSFORM_TEX(v.uv, _MainTex);UNITY_TRANSFER_FOG(o,o.vertex);return o;}fixed4 frag (v2f i) : SV_Target{// sample the texturefixed4 col = tex2D(_MainTex, i.uv);// apply fogUNITY_APPLY_FOG(i.fogCoord, col);return col;}ENDCG}}
}
更多推荐
第二章 04 魔镜世界
发布评论