unity如何设置fog,shader如何接收fog

设置fog,在WIndow->Lighting,Scene签页的Fog项勾选上,设置FogColor,Mode(The options are Linear, Exponential and Exponential Squared (these are in increasing order of fog accumulation with distance).
shader接收fog,需要添加以下几句:

pragma multi_compile_fog

a2v加:float2 texcoord1 : TEXCOORD1;

v2f加:#ifndef LIGHTMAP_OFF
half2 uvLM : TEXCOORD5;
#endif
UNITY_FOG_COORDS(6)
vert加:
UNITY_TRANSFER_FOG(o,o.pos);
frag加:
UNITY_APPLY_FOG(i.fogCoord, finalRGB);

你可能感兴趣的:(Unity)