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
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).
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:
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);