Creating custom lights?

Hi, I was wondering if there is any documentation for making a custom light? Also, do any of the built-in analytic lights have settings for “size”, for example if it were a direct light being the sun, it would be the solid angle it subtends in the sky?

Here is the base Light class from where all other lights are derived - Babylon.js docs
Each light may have its own settings and limitations.

Thank you! It looks like I am able to get a similar look to what I want stacking several suns along the same axis with different distances and different falloffs. Eager to look at that light code though!

It’s unclear to me exactly what you’re trying to achieve. Are you able to clarify?

How would “stacking suns” work?

Also, you should have a look at IES lighting, where you can work on precise custom falloffs :

2 Likes

Oh sick, I’ve used those textures in Houdini didn’t realize that was possible in Babylon! I’m trying to replicate the “foggy sun” from Moana, they used an analytic approximation of Mie on the light lookup but I figured I would just stack wider and softer direct lights, the same way I would do bloom in a compositor:

After a lot of testing, we found that the look of specular glints on the ocean surface comes partially from the sun itself, but also partially from the atmospheric scattering that makes the sun look hazy and larger in the sky than it actually is. To get this look, I added a system to analytically add a Mie-scattering halo around our distant lights; we called the result the “halo light”.

You could also take a look at:

.. as I’m still unsure what stacking directional lights would achieve, other than performance degradation if they’re all shadow casters.

2 Likes

Good point – only one will be casting shadows, the stacking is in order to sculpt a different falloff.