# 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.

## 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 on other sites
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 on other sites
well I'm using XNA 4... no idea if its using D3D9 or any of the newer ones.

##### 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 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.

1. 1
2. 2
3. 3
Rutin
25
4. 4
5. 5
khawk
14

• 11
• 11
• 23
• 10
• 9
• ### Forum Statistics

• Total Topics
633650
• Total Posts
3013119
×