Unity 3d环境光不影响广告牌着色器



我有一个广告牌着色器,但问题是无论环境光是黑色还是白色,我的广告牌平面都是明亮的。统一环境光是否可能影响公告牌着色器。请帮助

Shader "Unlit/Billboard"

{属性{_MainTex("纹理",2D(="纹理";白色";{}}子着色器{标签{队列=透明的IgnoreProjector=真的RenderType=透明的DisableBatching

ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
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 pos : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;

v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv.xy;
// billboard mesh towards camera
float3 vpos = mul((float3x3)unity_ObjectToWorld, v.vertex.xyz);
float4 worldCoord = float4(unity_ObjectToWorld._m03, unity_ObjectToWorld._m13, unity_ObjectToWorld._m23, 1);
float4 viewPos = mul(UNITY_MATRIX_V, worldCoord) + float4(vpos, 0);
float4 outPos = mul(UNITY_MATRIX_P, viewPos);
o.pos = outPos;
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}

fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}

}

;Unlite/Billboard";顾名思义,着色器是不发光的。这意味着在渲染时不会考虑灯光。如果你想让广告牌与环境光交互,你需要找到另一个具有这种效果的着色器,或者自己修改它。

相关内容

  • 没有找到相关文章

最新更新