I am using a HDR for the scene background and environment. I also have a directional light in my scene to create shadows.
Assuming the directional light always points towards 0,0,0 and is an arbitrary distance away, is there an easy way to get the location of the light such that it matches the HDR? This way the shadows will match.
Do people just do this by eye? It doesn’t have to be very accurate, but I potentially have a few scenes to do each using different HDRs, so if there is a neat way of doing it it could save me a lot of time.
If offline calculation is allowed, you could try with this (python) or even implement any of both SPA or IBS methods.
If it should be done on init, you can grab your head around and look for rgb peaks, just like Devedec’s median cut.
Jaume Sanchez did exactly this around 2013 (feeling old just by writing this down), you should found a live example on his twitter account (or timeback machine?)
I used my lazy eye, and the 3d space within my brain to make sense of what x,y,z might mean, and in fact, I didn’t even try.
I never even thought about how badly I got it wrong until this question was raised.
Thanks for all the info @Antonio & @seanwasere ! There’s certainly a lot to take in.
I was just going to create a sphere that is super shiny, put the hdr as the reflection then raycast to it where the light is to get the position on the sphere. I could then just extrapolate that to to bounding sphere of my scene to get the lights position. Sound like I am completely underthinking it though!