Can anyone point out what I’m doing wrong here? It’s driving me nuts.
I’m developing a volume rendering application, which uses either 2D or 3D textures (depending on graphics card) to render the volume. I’m also implementing an interactive transfer function using whatever means the card supports. So with GF3 and GF4, I use NV_TEXTURE_SHADER extension with a dependent 1D texture and this works fine for both 2D and 3D main textures. For ATI 9700 and above, I’ve used ARB_FRAGMENT_PROGRAM to do a similar thing - this works ok with 2D texture stacks but is buggy with 3D textures. I think I can sort this one eventually. FWIW, the fragment program (which works ok) is like this -
!!ARBfp1.0
ATTRIB inTexCoord = fragment.texcoord;
TEMP texelColour;
TEX texelColour, inTexCoord, texture, 2D;
TEX result.color, texelColour, texture[1], 1D;
END
My problem is when I try to support ATI Radeon 8500 - 9500 using the deprecated ATI_fragment_shader extension. I need to do this to support some laptop demos so I can’t overlook it. Problem is that the documentation is limited and there’s no specific simple examples that I can find. Sure if I want to produce a rusty chrome effect there is plenty of sample code, but not for a very straightforward dependent texture look-up. What I have currently got is this -
My main texture is an 8-bit 2D luminance texture in TEXTURE1. My transfer function is coded in a 256-entry rgba structure which I’ve loaded as a 1D rgba texture in TEXTURE0. The fragment shader (without all the error checking and stuff) started off like this -
glBeginFragmentShaderATI();
glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STQ_ATI);
glSampleMapATI(GL_REG_0_ATI, GL_REG_1_ATI, GL_SWIZZLE_STQ_ATI);
glEndFragmentShaderATI();
This gave me an INVALID_OP on the second glSampleMapATI(). I took this to mean that it couldn’t do the look-up in a single pass. So I forced in a MOV to break it into two passes, like this -
glBeginFragmentShaderATI();
glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STQ_ATI);
glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_2_ATI, GL_NONE, GL_NONE, GL_REG_1_ATI, GL_NONE, GL_NONE);
glPassTexCoordATI(GL_REG_2_ATI, GL_REG_2_ATI, GL_SWIZZLE_STR_ATI);
glSampleMapATI(GL_REG_0_ATI, GL_REG_2_ATI, GL_SWIZZLE_STR_ATI);
glEndFragmentShaderATI();
The docs tell me to code the glPassTexCoordATI() to preserve R2 between passes. This doesn’t throw any glGetError() but just gives me a totally black volume. I’m guessing that the dependent texture read is not working or maybe the alpha is getting corrupted somewhere. I’ve tried all combinations I can think of (including swapping the texture units) but I just cannot get the damn thing to work. This should be so simple so I guess I’m making a pretty basic mistake somewhere - I’d be really grateful if someone would point it out
Thanks in advance,
Roger