Using nv_texture_shader as color table

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

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

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?

You need to use a Nx1 2D texture rather than a 1D texture, and use the DOT_PRODUCT_TEXTURE_2D operation.

  • Matt

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 .
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