注意:此页面上的 ShaderLab 是旧版功能,仅用于向后兼容。如果着色器源文件包含 HLSL 代码,Unity 将完全忽略这些命令。如果着色器源文件不包含 HLSL 代码,Unity 会在导入时将这些命令编译为常规着色器程序。
功能名称 | 内置渲染管线 | 通用渲染管线 (URP) | 高清渲染管线 (HDRP) | 自定义 SRP |
---|---|---|---|---|
旧版雾 | 是 | 否 | 否 | 否 |
在使用旧版固定函数样式命令编写的着色器中,使用 Fog 命令可启用或禁用 Unity 的内置雾。
使用 RenderSettings 类或 Lighting 窗口 将项目设置配置为内置雾效果,然后使用此命令可在给定的通道中启用或禁用雾。
雾化效果根据与摄像机的距离将所生成像素的颜色向下混合为给定颜色。雾化不会修改混合后像素的 Alpha 值,而只是修改其 RGB 分量。
参数 | 值 | 功能 |
---|---|---|
Mode | Off |
不对此通道应用内置雾。 |
Global |
根据项目设置,将内置雾应用于此通道。 请注意,如果在项目设置中禁用了雾,Unity 不会将其应用于此通道。 |
此示例代码演示在 Pass 代码块中使用此命令的语法。
Shader "Examples/FogExample"
{
SubShader
{
// 此处是定义子着色器的其余代码。
Pass
{
Fog Off
// 此处是定义通道的其余代码。
}
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.