PDA

View Full Version : sky gradient problem

ugluk
01-20-2011, 05:20 PM
I have a problem with the preetham sky model and putting it to good use on a fixed pipeline rendering system.

As most of you probably know, the model will also render the sun in a more or less blurred fashion, depending on turbidity and it covers the entire sky for the entire day (+ a bit into the evening).

As I am rendering this with the fixed pipeline (please don't admonish me for that), I'd like to have a sky gradient with the sun blended in after that as a kind-of billboard (not oriented towards the camera, but perpendicular to the skydome) and the clouds projective textured onto the skydome.

To do this, I've made a texture with the sun position (theta_s) from the zenith(0) to beyond the horizon(pi/2 + a bit beyond) indexing the rows and the skydome vertex theta indexing the columns (from 0 at zenith to pi/2 at the horizon).

To make the sun not show I place calculate the angle gamma like this.

gamma = M_HALFPI + theta_s;

so that gamma is away from the sun. That is, the whole sky takes up gammas from 0 to pi, but I sample from a point away from the great circle crossing the sun, hopefully far enough from the sun.

The result:
http://img401.imageshack.us/img401/3443/blan.png

The question:
Do you think this sky gradient is good enough? Is there a better way to generate one? I know I should have written either a fragment or vertex shader and it would be done sooner than a blink of the eye. But it is old school for now.

ugluk
01-21-2011, 09:09 AM
Anyway, I guess the fixed pipeline is too obsolete to be even worth a comment :) Still I am surprised why the whole horizon, even the part facing away from the sun has this orange color. Maybe the Preetham model is valid only for the hemisphere the sun is in and the dome color is clamped for the other half of the sphere.
http://img832.imageshack.us/img832/7776/blaz.png

ZbuffeR
01-21-2011, 10:19 AM
Well your question is really unspecific, so I had just a "huh yeah maybe good enough (for what?)" moment. Artistically, instead of green/yellow, something more in the orange/redish tones would feel nicer but hey, I am no artist :)

ugluk
01-21-2011, 10:47 AM
Well, yellow RGB is 255-255-0, so there is some green in yellow, maybe a model artifact - you've got better eyes than me Zbuffer. I've read you're post on Preetham in these forums once before. This green tint did not appear with your implementation?

EDIT:
http://www.gamedev.net/topic/100346-having-trouble-implementing-a-sky-colouring-algorithm/

It appears colors are a well-known problem with Preetham and you need to fiddle with the exposure function and gamma correction to get them right. I guess, for fooling around even the Preetham model is good enough, but otherwise you need to look elsewhere.

Thanks Zbuffer for pointing out the (now obvious) problems with the image. I can use a color filter to tone down the green, but as I said, for fooling around even this image is probably ok.