Jump to content
  • Advertisement
Sign in to follow this  
stevjj

Terrain, vertex construction

This topic is 4323 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

Hey, I was wondering how i would go about sending vertex data to a shader in 2 seperate parts. I am trying to send the x,z coords through 1 vertex buffer and in another have all the y coordinates. I am trying to implement a chunklod style implementation without the optimized triangulation. I plan is to have a couple of base xz vertex/index buffers and then translate + scale them in the shader, however this means i need to add the height data after this. My problem is having the vertex buffer recognise the 2nd VB stream (The height data), at the moment it picks up the x,z coords to the height data. If you could direct me to an example of this in action or just tell me how it would be great thanks.

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure about any example code, but the trick is with the vertex declaration.

Set up both your VB's and make the corresponding SetStreamSource() calls. Then, declaration should be something like:

D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 1, 0, D3DDECLTYPE_FLOAT, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 1 },
// Other elements here...
};


The trick is in the first and last fields. The first field is the stream ID (the FLOAT2 comes from the first stream and the FLOAT comes from the 2nd) and then the usage index at the end so you can differentiate between the two POSITION semantics.

It should map to the following input declaration:

struct VS_INPUT
{
float2 xzPosition : POSITION0;
float yPosition : POSITION1;
};


Note the use of indexes for the semantics.

hth
Jack

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!