cloud rendering

Recommended Posts

i know, here are alot of threads about cloud rendering, but i haven't found a single post wich explicitly explains how to shade the clouds. finally i've managed to write a cloud generator ( using perlin noise, done on the cpu ). the created texture then is just mapped on a curved skyplane ( the texture defines the alpha channel ). ( http://www.shadowman-works.de/forum/files/2/clouds1.png & http://www.shadowman-works.de/forum/files/2/clouds2.png ) but how can i shade the clouds? can somebody explain me how this could be done? i think a simple model ( taking into account the density of the clouds and the color of the sun ) would be enough.

Share on other sites
Have you looked here? http://www.markmark.net/

Share on other sites
as long as i can see these articles cover clouds for a flight sim or something similar. the cloud systems are all particle based and their lighting formulas are much more complicated as for a "static" sky, aren't they? is there a possibility to adapt them for my ( and many others ) method?

Share on other sites
You never told us what you wanted to do exactly, we're not mind readers :)

Share on other sites
i'm very sorry.
i thought that my explaination was enough. i just need a formula or some hints to be able to shade a skyplane, no volumetric clouds or something like that...

Share on other sites
the thread is interesting, but i can't get it right. some people speak of raytracing a ray from the sun trough the cloud => how am i supposed to do that o.O

another thing that is missing: how do i calculate the density of a cloud? should i just take the r g b value of the cloudmap, multiply it and this is its density?

the last thing that is really bugged: i want to light my clouds, not with the standart paralell lighting method, but with the sun as a point light.

Out.Pos = mul(Pos, matWorldViewProjection);// Sunrays from pointlight// lightDir is the Position of the Sun on the SkydomeOut.hemi = saturate(dot(normalize(lightDir - Out.Pos), normalize(mul(Normal, matRotation))));

the funny thing is that my clouds change color, depending how the camera is aligned to them *g
i have no idea why this is happening, since lightDir is definately the position of the sun. the rotation of the cam doesn't even appear in the code for the cloud rendering.

Share on other sites
You're transforming the position into clip space and then finding the vector between that and the light (which I assume is in world space). That will just give you garbage since they are in different coordinate systems. I think you would be better off lighting in world space.

Btw having a variable named 'lightDir' be the light position is kindof misleading.

Also assuming the result of mul(Normal, matRotation) is a float4 you must specify that the .xyz are being normalized and not the w as well, or you will get incorrect restults.

Share on other sites
Quote:
 Original post by SiS-Shadowmanthe funny thing is that my clouds change color, depending how the camera is aligned to them *gi have no idea why this is happening, since lightDir is definately the position of the sun. the rotation of the cam doesn't even appear in the code for the cloud rendering.

Try resetting the lightDir variable every frame, basically right before using it. I ran into a similar lighting problem and this fixed it for me, so I never got around to actually figuring out why my lighting changed with the camera angle... I just assumed lighting was tied to the view matrix somehow.

Share on other sites
Quote:
 Original post by jameswYou're transforming the position into clip space and then finding the vector between that and the light (which I assume is in world space). That will just give you garbage since they are in different coordinate systems. I think you would be better off lighting in world space.

*slap* ok, so i need to multiply the Position with the Transformation Matrix, right?

Quote:
 Btw having a variable named 'lightDir' be the light position is kindof misleading.

yeah, i was just to lazy to introduce another variable for the Position of the light, since i have one shader file for the whole environment ( starbox, skydome, sun, etc... )

Quote:
 Also assuming the result of mul(Normal, matRotation) is a float4 you must specify that the .xyz are being normalized and not the w as well, or you will get incorrect restults.

i don't get what you mean here. isn't the .w var uninteresting?

Share on other sites
Here's what I meant by lighting in world space:

Out.Pos = mul(Pos, matWorldViewProjection);Out.hemi = saturate(dot(normalize(lightWorldPos - Pos.xyz), normalize(mul(Normal, matRotation).xyz)));

Off topic, but it helps to include the coordinate space of positions and vectors. This gets really useful when you are doing any combination of operations in object, world, view, clip and tangent space all in the same shader.

Quote:
 i don't get what you mean here. isn't the .w var uninteresting?

I haven't had this problem myself but heard about it from Jack's journal entry

Quote:
 Almost as stupid as the time I forgot to specify .rgb and my normalization was working on a 4D instead of 3D vector. That was an odd mistake to track down and fix...

Share on other sites
ok, now i understand what you meant. i've corrected it, the clouds now don'
t change their color based on the camera's rotation. now i just need to find a lighting method that makes them look realistic *g

Share on other sites
does someone have a technique to shade those 2d clouds to make them look at least good? it doesn't have to be perfect, but i think i need a sample to be able to do that, i have no idea to start, except when it comes to the sun.

float4 SmoothBlending(float4 a, float4 b){	return (a + b - (a*b));}tempFloat = 1.0 - tex2D(AlphaSampler, Tex0); // the more white the texture is, the denser the cloud should be => 1 - CloudTexturetempDiffuse = SmoothBlending(tempFloat, CloudColor);tempDiffuse.a = tex2D(AlphaSampler, Tex0);

how should i now add the sunlight ( and use the dotproduct between the vertex's position and the sunlight direction ) to shade the clouds?

Share on other sites
Im not sure exactly what you are doing but for flat clouds you should use normal mapping.. works for me.

Share on other sites
are you using the perlin noise texture for the bump map or something else?
can you show me some screens where i can see the result? its hard to understand how normal mapping can help.

Share on other sites
Well i dont belive in perlin noise for clouds currently.. I just use a pre-made normal map with an alpha channel...then just light my sky dome..

Share on other sites
can you show me how this looks?

*edit*

anyway....

this is a link to a movie of my engine ( with 500x speed )

this is pretty much what i could do. i still stuck with lighting the clouds.
all i am doing for now is using the perlin noise for the alpha channel and for the cloud color:

tempFloat = 1.0 - tex2D(AlphaSampler, Tex0); // the cloud density from the perlin noise needs to be "inverted", because the more white a cloud appears on the map, the denser it istempFloat = pow(tempFloat, 0.3f); // if i just took the inverted value, the cloud would be too dark, so i scale it "down": since 0<tempFloat<1 pow(tempFloat, 0.3) will give a higher valuetempDiffuse = CloudColor * tempFloat; // just multiply the cloud color ( wich is 1.0f by now ) with the densitytempDiffuse.a = tex2D(AlphaSampler, Tex0); // add alpha channel according to the perlin noise map	return tempDiffuse;

perhaps someone can offer me a tipp how to integrate the light comming from the sun and thus influencing the cloud color by the sun's color.
any help would be appretiated :)

[Edited by - SiS-Shadowman on October 14, 2006 3:13:27 PM]

Share on other sites
isn't there anyone who can help me to create better clouds? :(

Create an account

Register a new account

• Forum Statistics

• Total Topics
628402
• Total Posts
2982469

• 9
• 10
• 9
• 19
• 24