Rocketman needed to have cool clouds. We were going to be on the edge of planets the whole time, there had to be a little bit of atmosphere around them! After quite a bit of searching, I felt as though the most bang for my buck was going to come from volumetric rendering. The ability to go into said clouds and see that they were actually variable density volumes and not just splatted textures was something I just couldn't get out of my head.
I started off by integrating a simplex noise algorithm in the given engine and using it to generate a VolumeTexture filled with said noise. After playing around with it in a small XNA Renderer I implemented just for toying around with the shader I was amazed by what noise could do! No wonder Ken Perlin got an academy award.
The cloud renderer worked as follows:
- Render the back faces of a simple cube mapped with uvw texcoords into a rendertarget
- Render the front faces of the same cube into another rendertarget
- Use those rendertargets in the next pass to cast rays from the front of the cube to the back specifying the iteration count with which to sample your cube texture and calculate the total density the ray traverses on said pixel.
Now for clouds that project shadows it's a little different.
To accomplish my cloud rendering I started by splitting the rendered cube into two halves to then be able to render my planets and characters inside of them. Also as the camera can enter the volume (which would cull the front faces of the cube and destroy our ray), I had to dynamically update the cube halves and texcoords so they would always stay in front of the camera clip plane, while never changing the look of the clouds.
Then using simplex noise harmonics, some simple transforms in time and space to make the clouds evolve and the equation of a sphere, I had some pretty cool clouds!
Then using simplex noise harmonics, some simple transforms in time and space to make the clouds evolve and the equation of a sphere, I had some pretty cool clouds!
Also, since the engine already had shadow mapping implemented, I wanted my clouds to project shadows at a very low cost (since they were already quite expensive to render). I decided to do what any self respecting game developer would do! Cheat!
By projecting the noise found in the densest part of my clouds on my cube during the shadow pass I was able to approximate the shadows that my clouds would generate without actually calculating the density of said clouds. My technique was pretty raw, but it was dirt cheap, and gave great results.
We also used the clouds to add fog to our planet of death.








0 comments:
Post a Comment