Sign in to follow this  

[dx10] stencil acces in a shader - volume texture generation from model

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

im trying to generate a volume texture from a model. i've set up my ortho graphic to draw the model from the top, moving down to draw "slices". Im thinking of using the stencil buffer to determine where the model is solid. So drawing a backface will add 1 to the stencil buffer, drawing a front face will subtract one. Once i'm done any area where the stencil is greater than 0 the model is solid. problem is, how can i get access to the stencil buffer? when i create the render texture i create a "depth stencil" texture, is the stencil somehow combined with the depth buffer? so i just need to access this texture? AFAIK it is only a single channel, im using depth format as DXGI_FORMAT_R32_FLOAT. Also, is it possible to get access to a render textures pixels, so i can build up a 3d texture manually? [Edited by - supagu on May 11, 2007 10:19:11 AM]

Share this post


Link to post
Share on other sites
Ok, so you want to convert you mesh to a volumetric representaion? Such that, for each location in 3D space, if it is in/on the mesh the volume gets one value otherwise it gets another?

There are basically two approaches.

1)Go through each pixels of the volume and cast rays in every direction. Count the number of surface crossings and this tells you wherther a given location is inside the mesh. This approach is slow but automatically 'fills' the model.

2)Go through each face and render it 'into' the volume. That is, in the same way that three 2D coordinates allow you to render a polygon on the screen, three 3D coordinates allow you to render one in 3D space. It's a 3D version of the scanline algorithm. This approach is very fast but the result is hollow - you need to use a 3D flood fill to fill it.

If you search for 'arie kaufman' and 3D scanline conversion you might find a helpful paper (but it's a little complicated). I implemented my own crude 3D polygon renderer by basically subdividing each triagle till it was only the size of one voxel and then drawing that to the volume.

You can find my source code from this thread in subversion...

http://www.ogre3d.org/phpBB2/viewtopic.php?t=27394

Hope that helps.

Share this post


Link to post
Share on other sites
Sounds like a perfect example of using resource views - have you read up on them yet?

Create a resource of type D24_UNORM_S8_UINT and create a depth/stencil view on it. Render as appropriate. Then bind it to the pipeline via a standard texture view using X24_TYPELESS_G8_UINT and read your stencil value from the green channel of your sampler...

I've not tried it, but on paper I don't see why it won't work...

hth
Jack

Share this post


Link to post
Share on other sites

This topic is 3871 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.

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