Having trouble implementing a sky colouring algorithm...

Started by
37 comments, last by gjaegy 12 years ago
I've been trying to implement Nishita's paper "A Fast Display Method of Sky Color Using Basis Functions". If anyone has implemented this paper let me know! But anyway, the problem I have is computing the weights: To calculate a weight (eq. 10) you have to sum the intensities around the circle. But to calculate a given intensity, (Eq. 5) you need to sum the weights!! You shouldn't need weight information to calculate an intensity value! Argh. It's late, and i'm frustrated. Dave. [edited by - Stimpson on June 19, 2002 10:17:40 AM]
-----------------------------OpenMountains... an open source snowboarding game... One day... :)
Advertisement
I think you don't quite understand the DNKY paper. DNKY's paper only deals with storing the skylight distribution. The methodology assumes you have a method for calculating the skylight everywhere (e.g., some complicated model, or photographs) and suggests using basis functions to store the data efficiently. So,

1. generate a very large data set of intensities from model or photograph
2. calculate the weights. Save the weights and not the original intensities

Then when you need to display the sky,

3. (re)generate the intensities from the weights

You will not get exactly the same sky as if you had lugged around the whole large data set, but if you used enough expansion terms then it should be a good approximation. The DNKY paper discusses steps 2 and 3, not step 1.

This, at least, is my understanding. I have not looked at the paper closely or implemented it.

If you are trying to generate the sky intensities from a model, I suggest considering "A practical analytic model for daylight" (Preetham et al). They very considerately include parameter values and have source code available at their website. The paper has a nice review of the literature too. I have not implemented this either, though.

[edited by - greeneggs on June 19, 2002 12:24:57 PM]
Greeneggs is right. This paper presents a kind of compression system for sky gradients. The method should work rather well, but be aware of the fact, that you''ll need a *very* high amount of samples to get a good result.

The best way to get the raw data is to use photographic sources (panoramic 360° sky views). You could also use equations (1) and (2) of the mentioned paper, but results won''t be too realistic, unless you use a very accurate approximation of the integrals (long computation time...).

I implemented "A practical analytic model for daylight" some time ago, and I was somewhat dissappointed by the results. The sky colours are not bad, but not close to photorealistic, and take a rather long time to compute. But if you don''t need a photorealistic sky, but a nice approximation, then this paper is worth implementing - it will give you a fully procedural sky model. If you combine that with Nishita''s weighted basis functions, it might be an interesting and fast way to get the gradients.

/ Yann
Thanks guys I knew i was missing something major! I was originally going to implement "A practical analytic model for daylight" but i didn''t actually like the look of the examples given.

I''m definately after photorealism though.. Does anyone know of any analytical models that produce good values? Or should i go for sample data?
-----------------------------OpenMountains... an open source snowboarding game... One day... :)
Yann L, would you be interested in posting some screenshots of your implemetation? I would be very interested in seeing what your implemetation has produced. There are certain phenomena that I would be curious to see if it reproduces.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
OK, I'll try to dig it out. As I said, it's been a while I tried that. It was only a quick'n'dirty hack, just to see if it suited my needs, more or less wrapped around Brian Smits sources. All in all, the results were similar to the images in the paper, but the colours were quite un-natural, IMO.

[edited by - Yann L on June 19, 2002 2:16:50 PM]
If you guys don''t know about it-
There was a quite popular sky thread a little while back.
http://www.gamedev.net/community/forums/topic.asp?topic_id=86024
It''s not the same technique but it deals with sky anyway and I just wanted to mention it. Yann posts a few screenshots of his implementation with Perlin Noise octaves.
quote:Original post by bishop_pass
Yann L, would you be interested in posting some screenshots of your implemetation? I would be very interested in seeing what your implemetation has produced. There are certain phenomena that I would be curious to see if it reproduces.


Looking at the paper more closely, it is actually all very simple. For skylight, I mean -- I suppose Hoffman & Preetham''s ATI article "Rendering outdoor light scattering in real time" is probably better for the aerial perspective stuff.

I don''t understand one thing, though. There are very simple formulas for computing chromaticities x and y, and luminance Y. But what should be done with these numbers? I guess you can convert to X, Y, Z, and then invert the RGB basis matrix to get RGB basis coordinates. (And then do gamma correction?)

The authors say "the luminance Y and chromaticities x and y can be converted to spectral radiance on the fly using the CIR daylight curve method described in the Appendix." What is going on here? What is the point? What does this give you more than immediately converting to RGB? Sorry, I am not familiar enough with graphics techniques to follow this step.


Well I''m gonna have a crack at implementing it without the accompanied source code to try and understand it completely. If i''m successful i''ll write a tutorial or something

Yann, itd be cool to see some of your screenshots of the algorithm at work.

-----------------------------
OpenMountains... an open source snowboarding game... One day...
-----------------------------OpenMountains... an open source snowboarding game... One day... :)
quote:
Well I''m gonna have a crack at implementing it without the accompanied source code to try and understand it completely. If i''m successful i''ll write a tutorial or something

Yann, itd be cool to see some of your screenshots of the algorithm at work.

I can''t find the source anymore, sorry for that It must be somewhere on a dusty archival DDS tape, between gigabytes of useless junk...

But as I mentioned, it was more or less the reference implementation. And it wasn''t too realistic, I''m not sure if you''ll be really happy with the results. I would suggest to test it on the authors source (perhaps even without understanding it), and if you are satisfied with the images, then dive deeper into it and implement your own version.

Good luck anyway

/ Yann

This topic is closed to new replies.

Advertisement