vm6502q / OpenRelativity

An open source framework to add the effects of traveling at relativistic speeds to visualizations or games
17 stars 2 forks source link

Debug difference between realtime and baked lighting #30

Closed WrathfulSpatula closed 3 years ago

WrathfulSpatula commented 4 years ago

There is a drastic difference between real-time and baked illumination. I'm still learning the rendering pipeline, and it hadn't occurred to me that baked light maps might not be exhibiting my updates to real-time lighting, at all.

In real-time lighting, unit vectors and distances are calculated according to their transformation under the Lorentz transformation and according to inner products via the metric. The difference between this and diffuse light maps is very stark. If possible, I'd like to try to achieve an approximation to real-time lighting via directional light maps. If I have the unit vectors and measure of distance correct in real-time lighting, though, I don't think it's at all feasible for baked light maps to stand in for real-time lighting without drastic modification.

WrathfulSpatula commented 3 years ago

I think I've solved the mystery: the obvious difference is due to the real-time attenuation.

For real-time lighting, attenuation is a function of the distance from the light to vertex according to the metric tensor. I thought this affect might be unnoticeable, but it turns out that it's potentially drastic.

If I turn down the coefficient for attenuation, the scene looks a lot closer to baked light maps. Also, I'm attempting to transform unit vectors like the normal and light map directionality unit vectors per the Lorentz transform, (assuming lights are static with respect to world coordinates). The various methods of calculating lighting are starting to converge, somewhat, but there's not really a clear way to fix attenuation for light maps, unless I approximate.