SimpleReflection

时间:2022-11-06 17:31:55

SimpleReflection

  取法线的x、y作为reflection-map的uv。

Shader "Custom/SimpleReflection"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "White" {}
_ReflectionMap ("ReflectionMap", 2D) = "White" {}
} SubShader
{
Lod
Tags { "Queue" = "Transparent"}
Pass
{
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM #pragma vertex Vert
#pragma fragment Frag
#include "UnityCG.cginc" sampler2D _MainTex;
sampler2D _ReflectionMap; struct V2F
{
fixed4 pos:SV_POSITION;
fixed2 uv:TEXCOORD0;
fixed2 uv2:TEXCOORD1;
}; V2F Vert(appdata_full v)
{
V2F output;
output.pos = mul (UNITY_MATRIX_MVP, v.vertex);
output.uv = v.texcoord;
output.uv2 = mul(UNITY_MATRIX_IT_MV, float4(v.normal, )).xy/+0.5;
return output;
} half4 Frag(V2F i):COLOR
{
return tex2D(_MainTex,i.uv) + tex2D(_ReflectionMap,i.uv2);
} ENDCG
}
} FallBack "VertexLit"
}

相关文章