Wednesday, March 17, 2010
Tri-Planar Texturing On A Sphere And Spacescape Release!
Applying an animated normal map to a sphere is a problem. You have stretching issues and if using a cube-to-sphere mapping you have uv direction issues. The only solutions I know of to solve these is to do perlin noise in a shader, a 3d repeating noise texture(?) or do tri-planar texturing and use a 2d texture map, which is what I've done here.
I used the code from this GPU Gems 3 article and added a second bump map and animated them by updating the vertex uv coords and the results are decent.
Now there are no visible seams on the sphere and the bump map is pretty evenly spread across the surface. Also when it animates you don't have any visible seams due to opposing uv directions because of the way tri-planar texturing blends the uv maps. This blending does mean, however, that where the cube edges meet on the sphere you get most of the stretching and the bump map is more random. This side affect is OK for water because I want the bumps to look random.
I still have to deal with a bunch of issues including the fps hit this shader brings with it. Now instead of 2 normal map texture look ups per pixel there are 6 - 1 for each of the 3 axis and there are 2 normal maps. On top of this I have texture look ups for the atmosphere color, sun color and the water depth and I haven't even tried adding reflection or refraction.
I've pasted the FX Composer .fx HLSL file at the bottom of this post if you want to try it out.
Also, I have released the Spacescape skybox tool and uploaded the source code to sourceforge.net/projects/spacescape!
The tool is rather complex and so I plan on writing some tutorials & tips to help answer some questions that have been coming up.
Here's an intro video:
Here's the tri-planar sphere.fx file code for NVidia FX Composer. NOTE: this is not my water shader, just the tri-planar stuff and it has a slider called OFFSET that you can drag to see how the bump map animates.
Subscribe to:
Post Comments (Atom)
3 comments:
It's looking great! I was wondering if you are using your own atmospheric shaders now or sean oneills?
The atmospheric shader in this post is the one I talked about a few posts ago.
I mostly use mine because I understand how it works and have more artistic control over it. O'neil's shader is much more sophisticated and physically accurate and doesn't work on planets like mine without really hacking it.
Do you also use triplanar texturing for the terrain? To seamlessly map repeating 2D textures onto the sphere, I mean.
Post a Comment