Internal format of texture3D in GPU - Raycasting

Hi all,

I have a problem.

I’m retrieving a single value from a data volume (Medical Imaging). Which I want to be the gpu as a 3D texture,

glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, width,
height, depth, 0, GL_LUMINANCE16, GL_UNSIGNED_SHORT, vol);

I am programming a shader to process and display with raycasting volume (a take an example that processes RGBA), the question is:

How I can convert and send a single value recovered (in this case, I consider LUMINANCE = L) in RGBA (internal format of GPU), where R = L, G = L, B = L, and A = 1 using GLTEXIMAGE3D ?

Any idea to program my shader with a single parameter, any example of shader with raycasting ?

Note:
The transfer function also send a 2D texture

How I can convert and send a single value recovered (in this case, I consider LUMINANCE = L) in RGBA (internal format of GPU), where R = L, G = L, B = L, and A = 1 using GLTEXIMAGE3D ?

What do you mean by a “single value”? If you mean that you want to update a single position in the 3D texture, you can’t do that with glTexImage3d. You have to use glTexSubImage3d.

Any idea to program my shader with a single parameter

I don’t quite know what you mean by that either.

Hi Alfonse

You know nothing about 3D visualization, but would understand things.

You know what’s an image?

the color of a pixel is a combination of RBGA, but I’m getting only a scalar value, I want to convert RGBA during shipment to the GPU and show a imagen (volume 3D) processed with a fragment shader (mapping color).

Let me see if I can restate your problem better.

You have a 3D array of scalar values. You want to store this as a 3D texture in OpenGL, so that you can read it in the fragment shader.

You don’t want an RGBA texture at all; you only want to pass a single value. If that’s the case, why not just create a texture with the GL_LUMINANCE format. The post OpenGL 3.x version is to use GL_RED with a swizzle mask set with GL_ARB_texture_swizzle (core in GL 3.2).

In terms of a GL command, that would be something like:

void glTexImage3D( GL_TEXTURE_3D, level, GL_LUMINANCE8, width, height, depth, 0, GL_LUMINANCE, type, data );

void glTexImage3D( GL_TEXTURE_3D, level, GL_RED8, width, height, depth, 0, GL_RED, type, data );

“type” would be the C++ type of the data you’re uploading. You know, “byte”, “short”, “float” etc. And “data” is the pointer to your 3D array.

A slight correction:

void glTexImage3D( GL_TEXTURE_3D, 0, GL_R16UI, width, height, depth, 0, GL_RED, GL_UNSIGNED_SHORT, vol);

well, he did not state that he wanted to use non-normalized values.

But if you wanted to upload unnormalized data, AFAIK it should be:
glTexImage3D( GL_TEXTURE_3D, 0, GL_R16UI, width, height, depth, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, vol);

For normalized data
glTexImage3D( GL_TEXTURE_3D, 0, GL_R16, width, height, depth, 0, GL_RED, GL_UNSIGNED_SHORT, vol);

should suffice.

Thanks,

Alfonse
Skynet &
Illian

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.