Caelum with SH

xadh00m

25-01-2009 22:24:29

Hi!

Kojack currently works on an spherical harmonic approach to simulate lighting:
http://www.ogre3d.org/forums/viewtopic.php?f=5&t=47393

Maybe this could directly go into caelum as a feature if it becomes stable. As far as I know he samples his skybox to calculate the SH coefficents. Maybe this could be adapted to work with the caelum sky properties as well...

xad

cdleonard

26-01-2009 07:41:02

Maybe this could directly go into caelum as a feature if it becomes stable. As far as I know he samples his skybox to calculate the SH coefficents. Maybe this could be adapted to work with the caelum sky properties as well...

Yes; it's a very interesting technique and it would be nice for it be available in a shared library (the sampling part). It would be even nicer if it would work with a cube RTT. But I don't have the energy to work on this. Maybe you could submit a patch?

kojack

29-01-2009 06:49:49

I've just taken a quick look at Caelum's source and demo (never used it before).
The problem that I see with integrating spherical harmonic irradiance is that the sky colour is calculated in a vertex shader.
To get the samples required for building the SH, I'd need either a cubic texture (a cubic RTT should work, but there might be a hit when reading back), or code to calculate the colour to match the skydome.
The second method would ignore cloud cover from the equation though.

Does caelum render the sky into a cubic rtt? I didn't think it did, but since you mentioned it, maybe it does.
Otherwise, I can try converting the skydome vertex shader to c++ so I can request the colour in any direction. I can already request the sun and moon position, so that part is easy.
After that, actually putting SH lighting in should be pretty easy (it's tiny and fast).

cdleonard

29-01-2009 09:47:41

The "cube RTT" idea is not implemented but would be VERY useful and not very difficult to implement. You could then use such a cubic texture for a lot of stuff. The advantage of a RTT is that you can render arbitrary objects in the cube map.

Reading back the texture should be acceptable if it's only done very rarely. I'll try to look at the SH demo carefully and see exactly what it would take to integrate this.