文档

Unity Engine


User Manual

Script Reference

Unity Engine


Optimize Surface Shaders

Make Surface Shaders run faster or reduce their file size.
阅读时间1 分钟最后更新于 1 个月前

Surface Shaders 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