PDA

View Full Version : How to create a solid object out of a quad rendered with an RGBA texture?



kon
09-06-2005, 04:25 AM
Hi

a texture with some shape defined in the alpha channel is rendered using a quad. Now, with enabled alphatesting just the pixels passing the alphatest are being rendered.
Now, I'm trying to build a solid object out of this. With solid I mean to render two quads in xy with different z and then "connect" the borders (alphatested!) of these two.
One solution would be first to find the contour(s) of the geometry "analytically" in the texture and then extrude these contour(s) to create the geometry. This is costly in computational time when the alpha values change interactively!
Is there any other (OpenGL-) way to get this solid object?
Any idea is appreciated!

Thanks
kon

ppeterson
09-06-2005, 04:42 AM
Perhaps you can use 3D textures. I've never used them but check out this (http://gpwiki.org/index.php/OpenGL_3D_Textures) which has a tutorial and some sample code.

Pete.

kon
09-06-2005, 05:35 AM
Thanks for your suggestion!
And what geometry should be rendered using a 3dtex? I still need the geometry to render the object! Using a 3dtex it could be done by doing some kind of volume rendering (e.g. rendering axis aligned slices). But when rotating you have to check the viewing direction and choose the correct rendering order (and even more things).
I'm actually looking for something "simple".

Thanks
kon

ppeterson
09-06-2005, 05:40 AM
Couldn't you just render a cube (or a box) and use a 3D texture with transparent voxels? Essentially the same as in 2D.

kon
09-06-2005, 06:16 AM
No, rendering a cube will only generate pixels at the cube's sides! So, you'll only see the six sides of the 3dtexture at the corresponding sides of the cube!

ppeterson
09-06-2005, 11:30 PM
Sorry I led you on a wild goose chase. I wonder if drawing the texture several times on top of eachother with a small offset in the "extrusion" direction will give you a good enough approximation of the effect you're looking for. As long as your viewing direction isn't too parallel to the texture-plane it might do the trick. It may even look cooler than expected ;) . Otherwise, it looks like you are going to have to render the "sides" of the extruded shape.

def
09-07-2005, 12:05 AM
How about some kind of vertex shader with texture lookup and a subdivided cube... don't know exactly where to go with this, but it's an idea...