PDA

View Full Version : Using nv_texture_shader as color table



johanh
01-14-2002, 11:30 PM
I want to render a 3D-texture (12-bit luminance) and apply a color table on the 'result'. What I have reckoned from earlier postings is that I should use the texture_shader(2) extension.
I have tried different things without success so I wonder if someone can post (or email me) some code showing how this should be done because...
Outlines of what I have done is
1) Create 2 textures, a HILO 3D-texture, and a luminance 1D-texture.
2) Use the result from the 3D-texture to index in the 1D-texure
Have I missed somehing crucial??

code clip:
glEnable( GL_TEXTURE_SHADER_NV );
glGenTextures( 1, &tex );
glBindTexture( GL_TEXTURE_3D, tex);
glTexImage3D( GL_TEXTURE_3D, 0, GL_HILO_NV,
image->width(), image->height(), image->depth(), 0,
GL_HILO_NV, GL_UNSIGNED_BYTE, image->imageData() );

glGenTextures( 1, &lookup );
glBindTexture( GL_TEXTURE_1D, lookup );
glTexImage1D( GL_TEXTURE_1D, 0, GL_LUMINANCE, 4096, 0,
GL_LUMINANCE, GL_UNSIGNED_SHORT, palette_data );

// stage 0
glActiveTexture( GL_TEXTURE0_ARB );
glBindTexture( GL_TEXTURE_3D, tex );
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D);

// stage 1
glActiveTexture( GL_TEXTURE1_ARB );
glBindTexture( GL_TEXTURE_1D, lookup );
glTexEnvi( GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB);

Husted
01-15-2002, 01:26 AM
Hi,

How do you obtain the shader result? You should setup the register combiners to get this for you.

You should also download your HILO texture wit GL_UNSIGNED_SHORT as type.

-- Niels

johanh
01-15-2002, 01:41 AM
OK. I was not aware of that, and I have not done anything with the register combiners... Do you have any tips on what needs to be done?

mcraighead
01-15-2002, 03:54 AM
You need to use a Nx1 2D texture rather than a 1D texture, and use the DOT_PRODUCT_TEXTURE_2D operation.

- Matt

johanh
01-16-2002, 05:57 AM
I think I start to understand how the register combiners are supposed to work, but I don't understand how to use them in this context http://www.opengl.org/discussion_boards/ubb/confused.gif.
Can someone post some code that shows how to set up the texture shader and register combiner (and corresponding textures) to make it work. I have a 16 (or 12bit) luminance 3Dtexture and want to use another texture as a lookup table. I just cant get things right!

.Johan