简体   繁体   中英

How to render volume data into a 3D texture using OpenGL?

I'm trying to render some 3D shapes into a 3D texture using the GPU. I am using Framebuffer objects to accomplish this. The only way I have found so far that works is by rendering to one slice (or layer) of the 3D texture at a time.

For example, if I want to draw a sphere to the 3D texture, I would draw the appropriate cross-section of the sphere to each layer of the texture.

This works fine at small resolutions or for small number of shapes, but quickly slows as resolution or complexity increases.

Is there some more correct or faster approach? I'm targeting moderately old hardware so I'm limited to OpenGL 3.x. Specifically, I can't use some of the techniques described here .

While I haven't personally done this, I know of an example that has a solution for directX. It may be portable to OpenGL: Generating Complex Procedural Terrains Using the GPU , see section 1.3.2: Generating the Density Values.

In short, do an instanced draw, and direct each instance to a different layer of the texture.

You may also be able to duplicate all your triangles and send them to all relevant slices with a geometry shader.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM