Jump to content
  • Advertisement
Sign in to follow this  
mika91

[HLSL] Optimize HeightMap

This topic is 3318 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, My scientifical software use Direct3D and Shaders for large heightmap rendering (512x512). It's working great, but I'd like to optimize memory footprint. X and Y coordinates can easily be computed from vertex position in VertexBuffer. So only Z coordinates are pertinant and should be stored in tables and buffers. My VS function should be like this: struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel VS( float inZ : PSIZE ) { VertexToPixel Output = (VertexToPixel)0; float4x4 preMatrix = mul(xWorldMatrix,xViewProjectionMatrix); float4 inPos; inPos.x = VERTEX_POSITION % xWidth; inPos.y = VERTEX_POSITION / xWidth; inPos.z = inZ; Output.Position = mul(inPos, preMatrix); Output.Color.r = inPos.x / xWidth; Output.Color.g = inPos.y / xHeight; Output.Color.b = 1; return Output; } So there is a way to get vertex indice in the VertexBuffer ? Or someone haa any idea to improve ? Thanks, Mickael

Share this post


Link to post
Share on other sites
Advertisement
What you probably want is to create one vertex buffer containing only x and y coordinates. This buffer never changes.

You then create a second vertex buffer with your height data, and set that as a separate vertex stream.

Share this post


Link to post
Share on other sites
Another idea is to use the heightmaps for texture fetching in the Vertex Shader (VS3+)and use 1 vertex buffer grid of 256x256 for example, and use shader parameters to offset the positions to actual world data.

Share this post


Link to post
Share on other sites
Quote:

What you probably want is to create one vertex buffer containing only x and y coordinates. This buffer never changes.

You then create a second vertex buffer with your height data, and set that as a separate vertex stream.


It's a pretty good compromise.
I will try it.

Quote:

Another idea is to use the heightmaps for texture fetching in the Vertex Shader (VS3+)and use 1 vertex buffer grid of 256x256 for example, and use shader parameters to offset the positions to actual world data.


I don't understand this solution, sorry :s

Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!