Having trouble implementing a sky colouring algorithm...

Started by
37 comments, last by gjaegy 12 years ago
About the night sky issues: always keep in mind that Preetham''s paper describes a _daysky_ model. So, IMHO, its behaviour for sun positions (far) below the horizon is quite... undefined. For night time rendering, the paper "A Physically-Based Night Sky Model" could come in handy.
Another thing to point out is that you should implement the CIE overcast sky model (or the CIE general sky model with the appropriate values) as well to cope with higher turbitities (6 or 7 and more). That is mentioned somewhere in the paper.
Dipl.-Inf.(FH) Marco Spoerlwww.marcospoerl.com
Advertisement
quote:Original post by Sardak1234
I''m almost implementing this method of sky coloring. I''ve been fairly happy with it thusfar, took a bit of tweaking to get it to even show up properly, but that''s expected. However, I''ve run into a couple of issues that I can''t quite figure out what is causing it.

First, the time seems to be extremely off. The ''sunrise'' doesn''t appear to occur until approximately 1900 hours. Is this to be expected, or am I missing something?

Second, at ''night'' the sky is extremely orange. Are there any good methods to get this to a much darker coloring or do I have to write something in to explicity darken it once it reaches that portion of the time?

Finally, when I increase the turbidity beyond 5 or so, I get a very deep greenish appearance to the sky. I''m fairly sure this isn''t correct, so I''m assuming I''ve got some numbers off somewhere or a formula mistyped.

Code-wise, I''m using a slightly modified version of the code posted by the AP on the first page and an adapted portion of the code greeneggs posted on the same page. Also, I''m using Yann''s XYZ->RGB matrix.

Thanks in advance.


For the clock, make sure your longitude is set correctly. (Of course the part of the code controlling the sun''s position is not related to anything else -- you can replace it with whatever you like.)

At night, you will have to do something explicitly. This model was not at all designed for the night sky. If you are interested in an accurate representation of the night sky, http://graphics.ucsd.edu/~henrik/papers/nightsky/ is a reasonable place to start.

For turbidity I am not sure. I guess you might want to try things like locally increasing the turbidity in the direction of a city, and have higher turbidity in the evening than the morning (due to accumulated pollution). Experiment to see what seems reasonable, and please let us know what works!

quote:So, IMHO, its behaviour for sun positions (far) below the horizon is quite... undefined


no, the sun positions are correct wether it''s below or under the horizon.. the method used to compute sun positions doesn''t depend on "day" or "night" at all.
quote:Original post by sBibi
no, the sun positions are correct wether it''s below or under the horizon.. the method used to compute sun positions doesn''t depend on "day" or "night" at all.

I haven''t been talking about the algorithm to compute the sun''s position (I never used the one from the paper) but how the sky reacts to certain sun positions below the horizon.
Dipl.-Inf.(FH) Marco Spoerlwww.marcospoerl.com
Somewhat related: if anyone is looking for a good and accurate algorithm to compute the sun position at any time, date and geographical location, try this one. It''s very handy and easy to use. Both code and step by step algorithm tutorial are provided.
quote:ALX wrote:
Somewhat related: if anyone is looking for a good and accurate algorithm to compute the sun position at any time, date and geographical location, try this one. It''s very handy and easy to use. Both code and step by step algorithm tutorial are provided.

Great. Anyone has sourcecode to compute moon position? High accuracy is not required though.

Thanks,
=[dEkS]=
quote:Original post by deks
Anyone has sourcecode to compute moon position? High accuracy is not required though.

You could try these two:
How to compute planetary positions
Computing planetary positions - a tutorial with worked examples


[edited by - Mephiston on May 19, 2004 9:03:19 AM]
Dipl.-Inf.(FH) Marco Spoerlwww.marcospoerl.com
Mephiston> ok, sorry then. but its model can be somewhat coherent for night sky, it hasn't got an undefined behaviour, it only simulates the light halo you've got around the horizon. but I agree the halo looks a bit strange and too blue depending on the turbidity.

thanks for posting those links
they are really interesting!

[edited by - sBibi on May 19, 2004 12:26:22 PM]
[quote name='Yann L' timestamp='1025378472' post='1536082']
And the lighting at dusk/dawn, when the sun is below the horizon, isn''t right (as you already pointed out). It should be more red/orange, instead of the dominant yellow. But I think this is not so much a problem of your code, but more a limitation of this particular skylight model.
[/quote]

I am facing the same issue here. Is there a better model available, that produces a less greenish/yellowish color at dawn/dusk ?

Thanks guys !
Gregory Jaegy[Homepage]

This topic is closed to new replies.

Advertisement