Monday, December 29, 2008

PSVSM Shadows And Texture Updates

It's been a while since my last post so a lot has happened - mostly Christmas related stuff, but some planet work as well.

I implemented a second LOD for the textures so that when you view the planet from just outside the atmosphere the textures don't look like they repeat so much and there isn't a mipmap problem with the texture tiling so much which makes the texture really grainy. I also added back a temporary water sphere surface with some specular and normal mapping, to look like water, but it won't really look like water till it is animated, and it has uv problems at the top and bottom. Eventually I plan on coming up with a way to always have the water mesh face the camera at point where the uv isn't stretched and then do a mini-quad tree on it so that I can actually animate the vertices when you're close to the surface (but I'm getting waaayyy ahead of myself there).



After implementing that stuff I got in over my head implementing shadows.

My first success was with Ogre's PSSM shadow demo, but that had a major drawback because the shadows had a gap between where the shadow started and the base of the shadow casting triangles. Also the shadows swam a lot when you moved the camera and they were very pixelated because of the large amount of terrain that was covered.

This image shows the shadow "beards" and uses 3 512x512 shadow maps.



Later I found that this was a typical problem for basic PSSM shadows, and I read that VSM shadows didn't seem to have this problem (although they have their own drawbacks - namely light bleeding, which sounds weird to say)

I posted my latest GLSL shader code for the shadow caster and shadow receiver materials as well as the Ogre material code - and my set up code too so hopefully it can be tweaked to make it perform and look better.

These images show PSVSM using 3 1024x1024 shadow maps. I'll probably have to scale back to 512x512, unless I can come up with a way to gain back fps dramatically.





I plan on tweaking the shadow, terrain texture and water texture code next before moving on to a basic atmosphere.

Sunday, November 30, 2008

Random Transitions and Tiling issues

The latest implementation had seems at the edges of each repeating texture tile possibly due to bilinear filtering. I tried to fix this by offsetting the uv by 1.0 and scaling the actual image down by 2 pixels but this makes the tiles not repeat exactly. Still it is much better than the obvious seams before. I also added a noise texture that I use to randomize transitions between tiles.

Currently my look up table (LUT) only has 5 entries based on altitude only. Eventually I will make one that also incorporates slope.



This is a screenshot of the terrain with the more random transitions. I have 16 texture slots to play with so I will probably mess around with the look up table next before moving on to things like fixing my GLSL normal shading.

Also, something I forgot to mention in my last post was that the height maps are now randomly generated use FBM noise. I create 6 1024x1024 height maps on start up and save them to disk for the next time I run the program because my height map generation algorithm isn't optimized yet and takes a good 10-20 seconds to complete, which adds up when you're adjusting and recompiling frequently. The height maps are named in such a way that they are specific to the seed used for the noise, the size of the map, and the face on the 3D cube.

Saturday, November 29, 2008

Finally got to a good stopping point so here are some pictures of the latest progress.



A textured and shaded planet.



A view from further away with updates frozen.



Wireframe view of planet with updates frozen.

What I've implemented was vertex position and normal sharing between different faces and levels of the quadtree because calculations would be slightly different and you would get seams at the edges of a cube face.

Next I spent some time investigating Ysaneya's subtiling textures using a single texture pack and a slope/altitude look up table

While getting making the Ogre material and glsl shader I happened upon ml278 the 3d Planetary Surveyor which is something very similar to what I'm trying to accomplish! The developer had implemented a version of Ysaneya's subtiling in a glsl and Ogre, so I started with the open source shader he had and tweaked it to make it work in this program.

I still have a small 1 pixel seam around the edges of each texture when they repeat so I have to determine where that's coming from. I also need to add some noise between levels so that the transition isn't so obvious. Then, maybe I'll work on the water and atmosphere, or on the annoying popping effects when the lod levels change.

And, of course, the texture tiling is obvious from far away so I'll need to implement some kind of blurring or dirt map to make it less so.