PDA

View Full Version : EXT_paletted_texture replacement for FX



SergeVrt
07-04-2003, 12:06 AM
Just noticed the topic had strange title so changed it ...

so the text was

We are ( in the team as we have this quetion among us) working on substitution of EXT_paletted_texture with NV_texture_shader
( as you know there are no EXT_paletted_texture at new FX cards ( no at ATI and other crads)
As we are intrested in grayscale rendering, we luminance texture to unit 0
and another luminance texture (256x1) which acts as a palette to unit 1

then we enable texture shader and set

glActiveTextureARB( GL_TEXTURE0_ARB );
glBindTexture( GL_TEXTURE_2D, nLuminanceTexture );
glTexEnvi( GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D );

glActiveTextureARB( GL_TEXTURE1_ARB );

glEnable( GL_TEXTURE_2D );

glBindTexture( GL_TEXTURE_2D, nPalette4Luminance );

glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV,
GL_DEPENDENT_GB_TEXTURE_2D_NV)

the result is the same as using paletted textures while we use GL_NEAREST
filtering.

Now the questions

first regarding performance

there we have
strange things with performance... when we draw few (1,2,4...) big
quads the speed of NV_texture_shader a loss in speed is
about 25%... but when we draw more and more quads (they become smaller
in order to fit in window) at some point both method show the same
performance and with quntity of drawed quads exceed ~40 the situation
go to opposite...

any clues here?

Now the question on
register combiner.
Since the result of
dependent read appear in texture unit 1 we use register combiner for getting
that fragments to screen not affected by textures from unit0... Is there
more streight way to do that?

clunis_immensus
07-24-2003, 12:49 AM
I'm trying to map a GL_UNSIGNED_BYTE 3D texture to a 256x1 RGBA GL_FLOAT dependent-texture. The 3D texture seems to looking up the palette. However, there seems to be some "bias" i.e. voxels with value 0 seem to be looking palette[128] and so on. Is there any other parameter that I should adjust?

Here's my code:

glActiveTextureARB( GL_TEXTURE0_ARB );
glBindTexture(GL_TEXTURE_3D,m_unTextureName);
glTexEnvi( GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D );

glActiveTextureARB( GL_TEXTURE1_ARB );
glBindTexture( GL_TEXTURE_2D, m_unPaletteTextureName );
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB);

glActiveTextureARB( GL_TEXTURE2_ARB );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_NONE);
glActiveTextureARB( GL_TEXTURE3_ARB );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_NONE);

glEnable(GL_REGISTER_COMBINERS_NV);
glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV , 1);
float ar_Identity[4]={1,1,1,1};
glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, ar_Identity);
glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_E_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_F_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_G_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);

many thanks!
karthik


[This message has been edited by clunis_immensus (edited 07-24-2003).]

[This message has been edited by clunis_immensus (edited 07-24-2003).]

clunis_immensus
07-27-2003, 09:57 PM
Fixed it. I'd forgotten that the border colour had been set. Since the border-RGBA was now being interpreted as dependent-texture-coordinates, I was getting unexpected effects for areas outside the volume.

karthik