Unity3D开发之Unity5版本自写Shader没有雾的效果问题

原本项目是Unity 4.6版本的,升级到Unity 5之后发现原本的雾不再看见了,然后查了一下相关资料,发现官方是改变了雾的渲染。

这里有相关的官方方式:

http://forum.unity3d.com/threads/official-changing-how-fog-is-done-in-unity-shaders.261217/

里面有比较重要的一段:

  • For surface shaders, nothing needs to be done; fog variants & code will be generated. You can add "nofog" to #pragma surface line, if you really don't want fog.
  • For vertex/fragment shaders, if you want fog you have to do this:
    1. Add #pragma multi_compile_fog
    2. Add UNITY_FOG_COORDS(n) to your vertex-to-fragment struct
    3. Add UNITY_TRANSFER_FOG(o,o.vertex); to your vertex shader. "o" is output struct name, and "o.vertex" is position in clip space.
    4. Add UNITY_APPLY_FOG(i.fogCoord, col); to end of your pixel shader. "i" is input struct name, and "col" is the color computed in your pixel shader. This applies standard fog color; if you want custom fog color (as some particle/additive shaders do, for example), you can do UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); to fog towards black for example.
  • For fixed function shaders, nothing needs to be done. "Fog { ... }" command in shaderlab still works, but now it onlyaffects fixed function shaders (for non-fixed function, see point 2 above).
  • By default, fog modes used by scenes are included into game data build. If you know you'll want to change them at runtime, you can choose "Custom fog modes" (default is "automatic") under project's Graphics Settings, and tick checkboxes you need.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值