volumetric cloud

Started by
0 comments, last by ekba89 11 years, 10 months ago
Hi I'm trying to create volumetric clouds using this tutorial. (And here 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.


[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;
}


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.
Advertisement
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 this 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.

This topic is closed to new replies.

Advertisement