PDA

View Full Version : fragment_shader_ATI problem(s)



Jens Scheddin
03-15-2002, 09:29 AM
Hi,

I'm trying to use the fragment_shader_ATI extension but I'm having
trouble understanding how to access and output the texture coordinates and texture data. I don't understand these glPassTextureCoordATI and glSampleMapATI functions.

I want to do per pixel diffuse bump mapping with texture0 being the base map, texture1 the bump map and texture2 the normalization cube map.

I tryed something like this for understanding the functions (examples and papers are very rare to find):

// Basemap color to register1 (or??)
glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
// Output basemap * interpolated vertex color
glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, GL_REG_0_ATI, GL_NONE, GL_NONE,
GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);

But rendering doesn't work with this shader. There is also NO gl error. The base map is correctly bound to texture unit 0. Looks like I don't understand the principles of this extension http://www.opengl.org/discussion_boards/ubb/frown.gif

I'd appreciate any help on this

Humus
03-15-2002, 10:40 AM
Basic dot3 bumpmapping:




glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);

glColorFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI,
GL_REG_0_ATI, GL_NONE, GL_BIAS_BIT_ATI | GL_2X_BIT_ATI,
GL_REG_1_ATI, GL_NONE, GL_BIAS_BIT_ATI | GL_2X_BIT_ATI);

Korval
03-15-2002, 12:12 PM
I don't understand these glPassTextureCoordATI and glSampleMapATI functions.

OK, glPassTextureCoordATI is used when you want the texture coordinate from a particular texture unit/map to be stored in a register.

glSampleMapATI is used when you want to actually use a particular texture coordinate to access a texture map. The return value is the color accessed from the texture map at the specified texture coordinates.

Since basic diffuse bump-mapping doesn't require anything truly special, it's just a simple matter of the following (assuming your conventions for the textures and their coordinates):




glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STQ_ATI); //This access the base map, and stores that color into reg0.
glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STQ_ATI); //This accesses the bump map and stores it into reg1.
glSampleMapATI(GL_REG_2_ATI, GL_TEXTURE2_ARB, GL_SWIZZLE_STR_ATI); //This accesses the renormalization map and puts the normal in reg2.


Now, you simply do a Dot3 with reg2 and reg1, and multiply that result into reg0.

Humus
03-15-2002, 12:45 PM
Reg0 is where you put the shader output btw.

Jens Scheddin
03-15-2002, 02:26 PM
OK,

thanks to Korval and Humus.
However, it looks like I understood the principles of how to use the functions correctly.

But sadly I'm still running into the same problem:

Even if I only output the base map into register 0 it still renders nothing. Writing the bump map directly into the same register works fine. The texture is correctly bound to texture unit 0! And everything works fine when rendering the basemap with the fragment shader disabled (w/o bump mapping, of course)

May this be a bug in the driver?
I'm using win2k with version 5.13.01.6032 drivers


Thanks again http://www.opengl.org/discussion_boards/ubb/smile.gif

Humus
03-15-2002, 03:26 PM
Are you sure you're providing texture coordinates for all textures and that GL_TEXTURE_2D is enabled for all units etc?

Jens Scheddin
03-15-2002, 03:32 PM
Humus,

yes, I'm completely sure. That was the second thing I thought about.

Another funny thing is that passing GL_TEXTURE0_ARB to register 1 and moving this to the output register works. But then I have my bump map in the register1 (?!). This is very odd to me

Humus
03-15-2002, 06:05 PM
Hmm ... odd.
I suppose you should try to update the drivers. There are 6043 driver floating around, go to rage3d.com for instance to grab them.

Jens Scheddin
03-16-2002, 07:06 AM
Well,

now you may understand why I had doubts on myself http://www.opengl.org/discussion_boards/ubb/smile.gif

After downloading the leaked drivers you told me and running the program I had the same strange results. The I decided to switch everything except the first texture (base map) off and, surprisingly, it worked (rendering the base map only via the fragment shader)!
Then I switched everything step by step on again and it run fine. At least I did the dot3 operations and voila: nice bump mapping on the surface

I can't find any explanation for this phenomina but I'm glad it works now http://www.opengl.org/discussion_boards/ubb/biggrin.gif.
I always did a clean rebuild so that can't be the problem...

Thanks for your assistance,

JMS