Forward Rendering Path Summary
It is now possible to summarize the situation of forwardbase and Forwardadd adapted to the forward rendering path.
Adaptability of materials under 7.4.1 forward rendering path
These two types of passes cannot be dyed when the camera is vertexlit, but can be rendered by the rendered path to the camera Forward and Deferred .
7.4.2 How Unity Sets the light source for the forward render path
within Forwardbase Pass, _worldspacelightpos0 and _ The LightColor0 will only contain a valid combination of the first pixel row light . In the absence of pixel parallel light, _woridsapcelightpos0 may also contain 1 location data for the pixel point light source, but there is no valid _LIGHTCOLOR0 data. Within the Forwardadd, _worldspacelightpos0 and _lightcolor0 will only contain pixel light sources, and in accordance with the intensity, the order of the parallel light priority is performed once for each pixe! light source.
in Forwardbase, when there is no Forwardadd pass, the combination of unity_4lightpos[x, Y, z]0, and Unity_lightcolor[4] contains the data of the point light source, According to the principle of pixel intensity, but not the parallel light, when there is Forwardadd, then forwardbase inside Unity_4lightpos[x, y, z]0 only contains vertex point light source. Within Forwardadd, Unity_4lightpos[x, y, z]0 do not contain valid data. Unity_lightatten0 data is used to switch between 1.0 and 0.0, indicating whether the corresponding unity_4lightpos[x, y, z]0 is a valid light source data.
 UNITY_LIGHTPOSITION[4] never contain any valid data within Forwardbase and Forwardadd, Oddly, its X component is always 1.0, and it only contains dead data that is not purged in time until it switches back to forward and deferred mode from camera's vertexlit mode.
Speaking so much, in fact for the forward render path, you can simply use the Shade4pointlights function in Unitycg.cginc to calculate the illumination of the vertex light source in forwardbase. For pixel light sources, you must use _WORLDSPACELIGHTPOS0 and _lightcolor0 to calculate.
Untiy 3d Shaderlab_ 7th _ forward Render path _4_forward render path Summary