Light direction vector in default or pbr fragment shader?


Where can I find how lighting direction is used with normal to compute brightness in fragment shader? I only looked at default fragment, but don’t find anything looks like it. Can you point me where this is done?

This is used mostly in the pbr light functions Babylon.js/pbrDirectLightingFunctions.fx at master · sebavan/Babylon.js · GitHub

1 Like

Thanks @sebavan. I have some follow up questions.

  1. How is the brightness computed in StandardMaterial? Mesh with StandardMaterial is still sensitive to light direction and intensity.

  2. Is NdotL the dot product of normal and light direction? What is V in NdotV then?

  1. This also puzzles me for a long time. Is there an easy way to find out the condition for a definition to be added to the shader? I know some of definitions depend on whether a particular texture or parameter is set to the material instance. But sometimes it is hard to tell.
#ifdef SHEEN

This is a standard phong shading model.

Yes and V would be for view from view direction.

You can search for the work SHEEN in the sources with case sensitivity enabled :slight_smile: That is how I usually do it which is set to true here Babylon.js/pbrSheenConfiguration.ts at master · sebavan/Babylon.js · GitHub

1 Like

This is a standard phong shading model.

This is back to my original question. Shouldn’t phong shading still use light direction vector somewhere in the default fragment shader? But I don’t seem to find it in the code.

All the functions would be here and they use it internally Babylon.js/lightFragment.fx at skeleton · sebavan/Babylon.js · GitHub