Version: Unity 7.0 Alpha (7000.0)
Language : English
Set the lighting model in a Surface Shader in the Built-In Render Pipeline
Surface Shader examples in the Built-In Render Pipeline

Optimize Surface Shaders

Important: The Built-In Render Pipeline is deprecated and will be made obsolete in a future release.

It remains supported, including bug fixes and maintenance, through the full Unity 6.7 LTS lifecycle.

The Universal Render Pipeline (URP) doesn’t support surface shaders. For more information on how to replace surface shaders in URP, refer to Convert custom shaders for URP compatibility.

Surface ShadersA streamlined way of writing shaders for the Built-in Render Pipeline. More info
See in Glossary
are great for writing shaders that interact with lighting. However, their default options are tuned to cover a broad number of general cases. Tweak these for specific situations to make shaders run faster or at least be smaller:

  • The halfasview for Specular shader types is even faster. The half-vector (halfway between lighting direction and view vector) is computed and normalized per vertex, and the lighting function receives the half-vector as a parameter instead of the view vector.
  • noforwardadd makes a shader fully support one-directional light in Forward rendering only. The rest of the lights can still have an effect as per-vertex lights or spherical harmonics. This is great to make your shader smaller and make sure it always renders in one pass, even with multiple lights present.
  • noambient disables ambient lighting and spherical harmonics lights on a shader. This can make performance slightly faster.

Additional resources

Set the lighting model in a Surface Shader in the Built-In Render Pipeline
Surface Shader examples in the Built-In Render Pipeline
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961