Sign in to follow this  
Followers 0
ekba89

volumetric cloud

1 post in this topic

Hi I'm trying to create volumetric clouds using [url="http://graphicsrunner.blogspot.com/2008/03/volumetric-clouds.html"]this[/url] tutorial. (And [url="http://www.inframez.com/events_volclouds_slide01.htm"]here[/url] is the original slides). I don't have any problems to the part where I need to distort the cloud map.Currently I'm using only one sphere just to test it. Here is the code where I do distortion.

[CODE]
[maxvertexcount(4)]
void GSMain(point VS_In p[1], inout TriangleStream<PS_In> billboardStream)
{
float3 eyeVec = normalize(p[0].position - cameraPosition);
float3 sideDir = cross(cameraUp, eyeVec);
PS_In vertex = (PS_In)0;
//left bottom
vertex.position = float4(p[0].position - sideDir*CLOUD_SIZE - cameraUp*CLOUD_SIZE, 1.0f);
vertex.worldPos = vertex.position;
vertex.position = mul(vertex.position, viewProjectionMatrix);
vertex.projectedPos = vertex.position;
vertex.textureCoords = float2(0, 1);
billboardStream.Append(vertex);
//left top
vertex.position = float4(p[0].position - sideDir*CLOUD_SIZE + cameraUp*CLOUD_SIZE, 1.0f);
vertex.worldPos = vertex.position;
vertex.position = mul(vertex.position, viewProjectionMatrix);
vertex.projectedPos = vertex.position;
vertex.textureCoords = float2(0, 0);
billboardStream.Append(vertex);
//right bottom
vertex.position = float4(p[0].position + sideDir*CLOUD_SIZE - cameraUp*CLOUD_SIZE, 1.0f);
vertex.worldPos = vertex.position;
vertex.position = mul(vertex.position, viewProjectionMatrix);
vertex.projectedPos = vertex.position;
vertex.textureCoords = float2(1, 1);
billboardStream.Append(vertex);
//right top
vertex.position = float4(p[0].position + sideDir*CLOUD_SIZE + cameraUp*CLOUD_SIZE, 1.0f);
vertex.worldPos = vertex.position;
vertex.position = mul(vertex.position, viewProjectionMatrix);
vertex.projectedPos = vertex.position;
vertex.textureCoords = float2(1, 0);
billboardStream.Append(vertex);
billboardStream.RestartStrip();
}
float4 PSMain(PS_In fragment) : SV_TARGET0
{
float2 offset = perlinNoise.Sample(cloudSampler, fragment.textureCoords).rg;
offset = offset * 2.0f - 1.0f;
float4 color;
color = cloudTexture.Sample(cloudSampler, fragment.projectedPos + offset / length(cameraPosition - fragment.worldPos));
//color = float4(1.0f, 0.0f, 0.0f, 1.0f);
return color;
}
[/CODE]

As you can see in the first screenshot billboard and sphere is fine (It was the easy part anyways :D). And other two screenshots are the results with different camera positions.

And lastly are there any other good looking volumetric cloud tutorials you can suggest. I searched a little but most of the tutorials are very old so I am curious if there are any newer techniques for volumetric clouds. Thanks.
1

Share this post


Link to post
Share on other sites
I have managed to solve that issue and make it work but it is not as good as I hoped there are artifacts when I try to move camera around the cloud . And now I'm trying to render real volumetric clouds so I can rotate around it and it look better. So I started [url="http://graphicsrunner.blogspot.com/2009/01/volume-rendering-101.html"]this[/url] tutorial series. But he uses a loop with 512 iterations in his shader for sampling volume and when I try to do the same thing with directx 11 it shows a white screen for a while and i get error. Then I tried his code with my laptop (because xna is installed in it) which has a lot worse specs than my pc and it worked with 3 fps. So obviously I'm doing something wrong but before trying to solve what is wrong with my code I want to know if it is possible to get good framerates in games using volumetric rendering techniques since I get 3 fps with just rendering the volume with decent computer. If not are there any techniques that you can suggest for me for rendering clouds.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0