Jump to content
  • Advertisement
Sign in to follow this  
winsrp

Telling the GPU to create geometry

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

So I have an 3d array, let think of it as

(5,5,5) array of bit, so they have 0 or 1... Now, instead of the normal approach of filling my vertex buffer with all the points, I want the GPU to take this array as input and create my poligons.

So I make a custom vertex declaration, with this array and make a "placeholder point", and send all the 5x5x5 data in it.

Now how can I make it so the GPU make a cube out of each 1, and nothing out of each 0 in the array? (noob at HLSL, this is why I ask)

Regards,

Winsrp.

Share this post


Link to post
Share on other sites
Advertisement
You need a geometry shader for this. From your mention of "vertex declaration" I take it that you're using D3D9, which means that you won't be able to.

Share this post


Link to post
Share on other sites
XNA uses D3D9 internally. If you want to use D3D11 from C# you'll need another library like SlimDX

However for an array that small creating the geometry on the CPU should be quick enough, and easier to implement.

Share this post


Link to post
Share on other sites
well, that was just the example for the question the real example uses a

(32,32,32) array of sections, where each section is (16,16,16).... and each position is a cube. so that would be around 134 million cubes, and each face of the cube (6 faces) is currently using 4 vertices (for 2 triangles).. so... its around 3.2 billion possible vertices, and I was looking into a way of optimize that.

now that the huge numbers freak out everyone (math is cool), i have to say that of course I'm only drawing the faces of the cubes which don't have adjacent solid blocks near them, also not drawing the ones that end up as 0... so lets say I only end up drawing like 0.01% of all those possible cubes/vertices, like 1.5 million cubes, or around 36 million vertices, which are still quite a lot.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!