Shader "Custom/StereoRenderShader"
{
Properties
{
_Color("Color", Color) = (0,0,255,1)
_Alpha("Alpha" , Range(0,3))= 1
_LeftEyeTexture("Left Eye Texture", 2D) = "white" {} //主纹理,外来的贴图
_LeftLerpNum("LeftLerpNum" , Range(0,1)) = 0.5
_RightEyeTexture("Right Eye Texture", 2D) = "white" {}
_RightLerpNum("RightLerpNum" , Range(0,1)) = 0.5
//[Space(45)][Header(Transparency Properties)]
//[Space(10)][MaterialToggle] _UseDirtmapasTransparencymap("Use Dirt map as Transparency map", Float) = 0.5
//_Transparency("Transparency", Range(0, 1)) = 0.5
//[HideInInspector]_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
}
CGINCLUDE
#include "UnityCG.cginc"
#include "UnityInstancing.cginc"
ENDCG
SubShader
{
Tags { "RenderType" = "Opaque" "Queue" = "Transparent"}
LOD 200
CGPROGRAM
//#pragma surface surf Lambert alpha //原来的
#pragma surface surf BlinnPhong alpha
sampler2D _LeftEyeTexture;
sampler2D _RightEyeTexture;
fixed _Alpha;
fixed4 _Color;
fixed _LeftLerpNum;
fixed _RightLerpNum;
//fixed _Color;
struct Input
{
float2 uv_MainTex;
float4 screenPos;
};
void surf(Input IN, inout SurfaceOutput o)
{
float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
#if UNITY_SINGLE_PASS_STEREO
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
screenUV = (screenUV - scaleOffset.zw) / scaleOffset.xy;
#endif
if (unity_StereoEyeIndex == 0)
{
fixed4 color = tex2D(_LeftEyeTexture, screenUV);
fixed3 outColor = _LeftLerpNum * color.rgb + (1 - _LeftLerpNum) * _Color.rgb;
o.Albedo = outColor;
o.Alpha = color.a * _Alpha;
}
else
{
fixed4 color = tex2D(_RightEyeTexture, screenUV);
fixed3 outColor = _LeftLerpNum * color.rgb + (1 - _LeftLerpNum) * _Color.rgb;
o.Albedo = outColor;
o.Alpha = color.a * _Alpha;
}
}
ENDCG
}
Fallback "Diffuse"
}
SurfaceShader 透明效果
猜你喜欢
转载自blog.csdn.net/BDDNH/article/details/101194991
今日推荐
周排行