In my point of view, per-vertex lit calculates lighting color in vertex shader and then pass it to fragment shader after rasterization, while per-pixel lit calculates lighting color in fragment shader with interpolated normal passed from vertex shader.
In Forward rendering, some number of brightest lights that affect each object are rendered in fully per-pixel lit mode. Then, up to 4 point lights are calculated per-vertex.
Data of the 4 per-vertex lights are packed in built-in variables like unity_4LightPosX0 , unity_LightColor in ShaderLab.
What confuses me is that these variables can be access both in vertex and fragment shader, so isn’t it the user’s choice (calculating lights color in vertex or fragment shader) to implement per-vertex or per-pixel lit on the 4 unimportant lights?
Briefly:
What’s the meaning of ‘per-vertex’/‘per-pixel’ in the description?
What’s the limitation of the 4 unimportant lights compared with the main per-pixel light?
@kechen00 for “unimportant” it means that it will only do the lighting per vertex… it will use all 4 lights, and the normals from the corner vertices of each triangle. 3 calculations for a triangle… and the 3 color result will be interpolated across the whole of the triangle.
for per-pixel lighting, it means it will use those same 4 lights, but do the lighting calculations on every pixel, instead of every vertex. It interpolates the normals across all pixels rather than color, its slower, but even without normal maps, it will look better, it will pick up hi-lights for specular lighting much better, and you’ll get less vertex lighting artifacts ( where you can see the shape of the triangles )
it also allows the use of a normal map ( again, even slower, but even nicer looking ), to change the normal vector for every pixel ( which is not possible for per vertex lighting )
@JonPQ Thank you. I have exactly the same understanding on per vertex/pixel lit with you. But what actually confused me was that, with the colors and positions of 4 unimportant lights provided as uniforms, per-pixel shading can be achieved easily too. So why is it saying that “4 point lights are calculated per-vertex”.
But now I think I have figured it out since I read the source code of unity standard shader. In both UnityStandardCoreForward.cginc and UnityStandardCoreForwardSimple.cginc, Shade4PointLights is called in vertex shader.
May be “4 point lights are calculated per-vertex” is just the truth of Unity’s standard shading model, rather than a rule of any custom forward rendering model.