"Unity3D ShaderLab explain the development of actual combat" in Chapter 6 VertexLit rendering path

Shader variable seed light source 3

  • The first:
    • _WorldSpaceLightPos0: w is 0 to parallel light, w is 1 is a point light.
    • _LightColor0: Color.
  • The second:
    • float4 unity_4LightPos {X / Y / Z} 0: four point light source position (world space).
    • float4 unity_4LightAtten0: 4 light sources attenuation.
    • float4 unity_LightColor [4]: ​​4 color light sources.
  • The third
    • float4 unity_LightPosition [4]: ​​4 parallel light / spot light source position (eye space).
    • float4 unity_LightColor [4]: ​​4 parallel light / spot light color.
    • float4 unity_LightAtten [4]: ​​4 parallel light / spot light attenuation.

Different paths, the light source under different variables LightMode

Model \ path Variable light source Vertex path Forward path Deferred path
Vertex _WorldSpaceLightPos0 Important parallel light Same as above Same as above
unity_4LightPos{X/Y/Z}0 A point light source (first important) Same as above Same as above
unity_LightPosition Important light source (preferentially parallel light), if the scene is not important light source, the light source is parallel Same as above Same as above
ForwardBase _WorldSpaceLightPos0 no Important parallel light Same as above
unity_4LightPos{X/Y/Z}0 no Point source (important priority), if there is ForwardAdd Pass then it is all important sources of Same as above
unity_LightPosition no no no
ForwardAdd _WorldSpaceLightPos0 no Important sources (performed once for each source Pass) Same as above
unity_4LightPos{X/Y/Z}0 no Important point light source Same as above
unity_LightPosition no no no
Deferred _WorldSpaceLightPos0 no no Important parallel light
unity_4LightPos{X/Y/Z}0 no no A point light source
unity_LightPosition no no no

This table Deferred still a little problem, after detailed investigation capacity ...

Published 41 original articles · won praise 4 · Views 3894

Guess you like

Origin blog.csdn.net/weixin_42487874/article/details/103243660