Unity 固定渲染管线雾效 Legacy Fog 实例

Unity 固定渲染管线雾效 Legacy Fog 实例

Unity5和之后的版本除了关掉雾效,其它Fog命令都无效

说明

  • 雾效根据相机距离混合生成的像素和固定颜色,只改变rgb通道的值
  • Fog
    • Fog {Fog Commands}
  • Mode
    • Mode Off | Global | Linear | Exp | Exp2
  • Color
    • Color ColorValue
  • Density
    • Density FloatValue
  • Range
    • Range FloatValue, FloatValue
  • 即使使用了fragment shader雾效命令仍然有效
  • 在固定管线不支持雾效的平台上,unity在运行时通过补丁的形式支持雾效命令

效果

在这里插入图片描述
在这里插入图片描述

代码

Shader "Practice/FixedFunction/Fog"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _Color("Color", Color)=(1,0,0,1)
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            Fog{
                //关闭
                // Mode Off
                // Mode Exp2
                Mode Global
                //尝试了几种方式这里指定Color无效,在Rendering/Lighting Settings/Fog下设置颜色有效
                // Color (1,0,0,1)
                Color [_Color]
                Density 0.5
                Range 0, 20
            }
            // SetTexture [_MainTex]{combine primary * texture}
            SetTexture [_MainTex]{combine texture}
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值