Sign in to follow this  
Funkymunky

clipmapping for terrains

Recommended Posts

Funkymunky    1413
I would love to have a clipmapped terrain, like the sample in GPU Gems 2. I've read that chapter numerous times, but I'm still a little uncertain as to its implementation. First of all I understand the idea of having a mip-map chain of the terrain heightmap texture. I don't understand how you generate the vertex data. I think I get that you use the vertex-texture-fetch vs 3.0 operation to offset the terrain by the heightmap mip-map based on the distance from the camera. But how do you wind up with the actual vertices that get offset by the vertex shader in an LOD-based grid...? I think what's confusing me is what part of this operation do I do on the CPU as prep work for the shaders?

Share this post


Link to post
Share on other sites
filousnt    573
Each level of your pyramid has a float4 that contains in xy the space between two vertex of same level and in zw the translation from int(viewer.xz). In the vertex shader,

float2 VertexPos = VertexBufferPos.xy * LevelScaleTrans.xy + LevelScaleTrans.zw;

gives you the xz position in world space. There is only one vertexbuffer, VertexBufferPos.xy € [0,0] [N,N].

[Edited by - filousnt on March 24, 2008 12:55:32 PM]

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