Fake directional light from environment.dds?

Hi! I am wondering how would one create a fake sunlight directional light from the most luminous highlight of .dds envinment texture used in IBL lighting? I am happy with the IBL results but would need the “fake” sunlight with shadows as well to the scene.

Here is the example - https://playground.babylonjs.com/#SYQW69#832
You may need to tune the position and direction of your light to correspond with the most luminous area (and/or tune dds texture rotationY value).

Thanks! This gives a good direction for the solution… Btw. now when testing the animating light I started getting interested in calculating the light position based on time and gps-location…

Still what I am also kind of missing, is if there is a way to read the env map somehow to get the most luminous spot automatically?

Have to try this at some point :wink:

In order to find most the luminous spot of the texture you may try to use readPixels Texture | Babylon.js Documentation

There’s currently no tool that would compute the direction of max light in an environment map. That’s something that you will have to write yourself.

This post was finally very helpfull here, its what I ended up doing for now:

Boils down to something very simple:

scene.onPointerDown = function(evt, pickInfo) {
console.log(pickInfo.pickedPoint)
}

1 Like