ATI fragment shader
Greetings,
I'm trying to implement a texture-palette using ATI_fragment_shader.
I have a new FireGL card.
For testing, I amd trying to apply a 256-entry look-up table to a GL_UNSIGNED_BYTE luminance 2D texture.
All I get is a blank display, when I enable the shader.
I'd appreaciate any suggestions.
I've included my code below:
GLuint nTex, nPalette;
// dependent texture
glGenTextures(1, &nTex);
glActiveTextureARB( GL_TEXTURE0_ARB);
glBindTexture( GL_TEXTURE_2D, nTex);
unsigned char pSlice[256*256], *ptr;
ptr = pSlice;
for(int i=0; i<256; ++i)
{
memset(ptr, i, 256);
ptr += 256;
}
glTexImage2D(
GL_TEXTURE_2D, // target
0, // level
1, // internal format
256, // width
256, // height
0, // border
GL_LUMINANCE, // format
GL_UNSIGNED_BYTE, // type
(void*) pSlice
);
// texture palette
glGenTextures(1, &nPalette);
glActiveTextureARB( GL_TEXTURE1_ARB);
glBindTexture( GL_TEXTURE_2D, nPalette );
float pfLUT[256*4], *pPtr;
pPtr = pfLUT;
for(int l=0; l<256; ++l)
{
pPtr[0] = l < 128 ? 0.0 : 1.0;
pPtr[1] = pPtr[2] = pPtr[3] = 1.0;
pPtr += 4;
}
glTexImage2D(
GL_TEXTURE_2D, // target
0, // level
4, // internal format
256, // width
1, // height
0, // border
GL_RGBA, // format
GL_FLOAT, // type
(void*) pfLUT
);
simpleFragmentShader = glGenFragmentShadersATI(1);
glBindFragmentShaderATI (simpleFragmentShader);
glBeginFragmentShaderATI();
glSampleMapATI ( GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
// dummy operation to end the first pass (better way ?)
glColorFragmentOp1ATI (GL_MOV_ATI, GL_REG_2_ATI, GL_NONE, GL_NONE,
GL_REG_3_ATI, GL_NONE, GL_NONE);
// Dependent texture read
glSampleMapATI ( GL_REG_1_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
glColorFragmentOp1ATI (GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
GL_REG_1_ATI, GL_NONE, GL_NONE);
glEndFragmentShaderATI();
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement