## Preetham Sun, spectral rendering

Practical and theoretical implementation discussion.
amaan
Posts: 8
Joined: Tue Dec 20, 2011 12:59 pm

### Re: Preetham Sun, spectral rendering

OK just found the Optix SDK code (Haven't looked at optix at all before this)

...\OptiX SDK 2.1.1\SDK\sutil\SunSky.

Thanks,
Amaan

amaan
Posts: 8
Joined: Tue Dec 20, 2011 12:59 pm

### Re: Preetham Sun, spectral rendering

Hi all,

At the risk of further embarrassing myself, here are a few more questions if you have time. I've seen the the Optix code and it's been helpful in tracking down the units issue. In the spectrum-to-XYZ conversion code, a multiplicative factor pops up again

Code: Select all

for (int i = 0; i < 38; ++i)
{
XYZ.X += attenuated_sunlight[i] * cie_table[i][1] * 10.0f;
XYZ.Y += attenuated_sunlight[i] * cie_table[i][2] * 10.0f;
XYZ.Z += attenuated_sunlight[i] * cie_table[i][3] * 10.0f;
}

Where does this factor of 10 come from? Is this because of the 10nm wavelength data interval that we need to take in to account when integrating?

Also, I am converting to RGB from XYZ using sRGB primaries matrix, and have a linear multiplier to scale down the super-bright values returned. The generated output is then transformed from linear colour space to gamma-encoded (1/2.2 as an approximation to sRGB) for viewing. Are you guys using this method as well?

Also, when the sun is at zenith, I get an undesirable pink shade around the horizon. I have seen this in some implementations, and not in others. (Mine does not yet have Aerial Perspective implemented. I am not sure if that has any impact on the look of the horizon). Have you guys noticed this too?

Thanks again,
Amaan

graphicsMan
Posts: 167
Joined: Mon Nov 28, 2011 7:28 pm

### Re: Preetham Sun, spectral rendering

The preetham model has issues when the sun is near the horizon.

tstanev
Posts: 6
Joined: Mon Dec 26, 2011 6:20 am

### Re: Preetham Sun, spectral rendering

amaan wrote:
Where does this factor of 10 come from? Is this because of the 10nm wavelength data interval that we need to take in to account when integrating?

Also, when the sun is at zenith, I get an undesirable pink shade around the horizon. I have seen this in some implementations, and not in others. (Mine does not yet have Aerial Perspective implemented. I am not sure if that has any impact on the look of the horizon). Have you guys noticed this too?
The 10 there is due to the integration over increments of 10 nm.

You may try playing with the "turbidity" value to make the horizon less pink. Also there is some dependence on the lat-lon location, though I have not experimented much with that myself.

amaan
Posts: 8
Joined: Tue Dec 20, 2011 12:59 pm

### Re: Preetham Sun, spectral rendering

Thanks graphicsMan and tstanev. Good to confirm the integration bit.