Skip to main content
GameDev.net gamedev.net
🔒 Locked

Cloud Light Scattering (Screenshots)

Started by HellRaiZer Jun 26, 2004 at 2:30 AM 8 replies 3.1k views
Original Post
HellRaiZer
HellRaiZer
Sorry for beginning one more thread on this subject, but i think i've made some steps and i want your help/opinion for finishing it. Below are two screenshots. Screenshot 1 Screenshot 2 Shading is calculated using Harris' equations as described in "Real-Time Cloud Rendering for Games", with one difference. I'm not using Rayleigh phase function as suggested in the paper, but a phase function that "simulates" Mie scattering (Henyey/Greenstein phase function, see "Rendering Outdoor Light Scattering in Real-Time", ATI Technologies). Using this phase function, first of all the shading is more physically accurate (clouds == large particles), and second it includes the g parameter (eccentricity), which let you specify if the light is scattered, mainly, forward (negative value, brighter clouds) or backward (positive value, darker clouds). As you can see in the screenshots, there is a problem with the shading texture. You can clearly see its pixels, where the color gradient between neighbor pixels is big. I know that this is the result from stretching the texture on the cloud plane. Having a bigger shading texture isn't an option because it will not be real time any more. Anisotropic filter doesn't help much. What do you suggest? Also i can't find any standard b coeffs for clouds (b = scattering coefficient). The same stands for albedo. I'm playing around with the values, to get the best image i can, but the problem is that i have to change them whenever the sun position changes too much (from sunrise to noon). What can i do for that? Where can i find standard values for these coeffs? I hope on a reply, with your comments/suggestions for improving the shots above. Thank you for reading this. HellRaiZer
HellRaiZer
sBibi
sBibi
Quote:
Having a bigger shading texture isn't an option because it will not be real time any more


you don't _need_ to recompute the whole shading each frame, unless your cloud's shading changes a lot between two frames, you can spread that over multiple frames, perhaps it's what you're already doing, but for realistic cloud movement, you can probably get away nicely with one full update per second. (depends on the sun's movement speed too of course...)

for example, with the sun doing a full loop each 6 hours, I can get away with skydome updates spread over 50 seconds... that makes the cost per frame completely ridiculous.

of course another solution would be to optimize more your algos/code, but some algos are really expensive, and spreading the work over multiple frames is often a very good choice, and lets you increase lots of things with almost no impact at all, in your case, the shading resolution.

about your other problem, sorry I don't know
Matei
Matei
Just wondering, since many pixels on the texture will be very far away from the camera, isn't it better to use a LOD approach with low-res textures for areas of the sky far from the camera and hi-res textures for the area nearby?
HellRaiZer
HellRaiZer
I forgot to login. The link for the mentioned screenshot is this:

Detail shading

HellRaiZer
HellRaiZer
deks
deks
Here's some shots of my sky system:
shot01
shot02
The clouds shading is completly real-time (clouds can move/morph at any speed), and 100% GPU @ 60fps on a GeForce6 (from perlin noise to voxel ray-tracing).

The idea of having everything on GPU is to use procedural texturing from the begining to the end. Shading is done procedurally, so you have no precision lost at all.

JF
motote
motote
Deks.... that's amazing... could you post some demo to see it in action ??
HellRaiZer
HellRaiZer
Hello again and sorry for the late posting.

Deks:
Nice work. Your clouds look very 3D. The second shot is great.
But i don't think that it's worth it. 60 FPS on a GeForce 6800!!!! (I think you mentioned that). It's overkill.

I'm looking for something faster, and nice looking at the same time. But not that :)

I'm curious. What shading equation you are using? Because you are calculating everything on the GPU, what things did you simplify? E.g. The number of samples for the inscattering term. Are you calculating it only for one direction, for every voxel. What phase functions are you using. Mie or Rayleigh?

Please if you can, post as many details as possible! I'm not planning buying a GeForce 6800 at the moment, but i wonder how it will look if i simulate it on CPU.

Thanks again.

HellRaiZer
HellRaiZer
deks
deks
Quote:
Original post by HellRaiZer
Nice work. Your clouds look very 3D. The second shot is great.
But i don't think that it's worth it. 60 FPS on a GeForce 6800!!!! (I think you mentioned that). It's overkill.

No that much. The sky is a high fill-rate eater, due to the pixel shader calculations (it's working only in shade model 3.0, don't forget that I ray-trace in the pixel shader!). But, I have several pending optimizations to try...

Quote:
Original post by HellRaiZer
I'm curious. What shading equation you are using? Because you are calculating everything on the GPU, what things did you simplify? E.g. The number of samples for the inscattering term. Are you calculating it only for one direction, for every voxel. What phase functions are you using. Mie or Rayleigh?

None. I simply trace through the voxel field, accumulating the amount of voxels traversed during the ray from sun to voxel. Then, I simply do shade=1/exp(shade*0.05f).
Quote:
Original post by HellRaiZer
Please if you can, post as many details as possible! I'm not planning buying a GeForce 6800 at the moment, but i wonder how it will look if i simulate it on CPU.

In fact, I made it work on shader model 2.0: the problem is to ray-trace through the voxel field. My solution was:

1- setup a floating point texture representing, at each texel, the vector from the sun to voxel.
2- render 64 layers in a render target, fetching the current sun-voxel ray multiplied by the layer number (which represents the current sun-voxel ray position), accumulating in the alpha channel whatever or not the ray is in clouds.
3- Use the alpha channel of that texture in your final shader, using shade=1/exp(alpha*0.05f) to shade the clouds.

It works well if you do 1 layer each frame, but it doesn't allow moving the clouds fast. I wanted to have the clouds fully dynamic, changing shape very fast, but in your case, it would work. Again, you'll be dependent of texture resolution.

JF
deks
deks
As a side note, I also made tests using simple diffuse lighting: while displaying the clouds, fetch one texel to the right and one texel below, compute a normal with this and simply take the dot product of that vector with the vector from sun to current texel. It looked great (clicky), ran really fast, but it lacked from self-shadowing and glowy edges of real clouds.

I still use this technique for clouds at the horizon in my system, which gives fuzzy clouds at distance, and accuratly lit clouds near the viewer. I'll post new (and cleaner) screenshots on monday, when I get back to work.

Happy coding!
JF

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.