PBRLighting does not support per-vertex lighting?


In Lighting.j3md we have a parameter to enable per-vertex lighting

but we do not have it in PBRLighting:

Does anybody know why PBRLighting does not support per-vertex lighting? And should we add it?

I can’t speak to whether or not it was an oversight but I guess per vertex lighting is going to be easier with phong lighting since in regular frag shading (non-vertex) you are just interpolating the light dir and and so interpreting a precalculated light value is not so bad.

I imagine it’s word on PBR where the IBL is being sampled, etc… I can’t imagine it looking really bad. I have no evidence that it’s true, though.

Could be that it’s just a lot more varyings to manage because the lighting calculations are not as simple in the fragment shader.

1 Like

It doesn’t look as if it’s a matter of “Supporting” anything. I’m not a shader expert, but skimming through lighting.frag: this is just a flag for whether the Shader should rely on an externally generated pre-computed sum of the various lighting components , (per vertex) or generate the data itself. As the comment says, "For better performance"

I’d suspect that the way PBR works, this data has to be computed in the shader, so no “Option” to do things another way.

In lighting.j3md, if you select vertex lighting the lighting information is calculated per vertex and interpolated over the fragments. If vertex lighting is off then the lighting is calculated per fragment. Vertex lighting also skips bump mapping, normal maps, etc…

Considering that in PBR, the roughness, metalness, etc. are all directional on some level and definitely use the indirect lighting information, I suspect that vertex lighting would look very bad if these were interpolated over a whole scan line.