PDA

View Full Version : Two texture samples from one texture unit



vincoof
03-28-2003, 06:36 AM
Is it possible to sample the same texture unit with two different texture coordinate sets ?

Something like :
glTexCoord2fv(coord1); // sample TEXTURE0 with coord1
glSecondaryTexCoord2fv(coord2); // sample TEXTURE0 with coord2

I know the glSecondaryTexCoord2fv command does not exist, but I'm wondering if it can be emulated with extensions (be it NV_texture_shader/NV_register_combiners, ATI_fragment_shader or ARB_fragment_program).

My guess is that it's possible with ATI_fragment_shader and ARB_fragment_program but not with NV_texture_shader/NV_register_combiners. Am I right or wrong ?

TIA

ps: I know it's obvious with multipass. please don't point me to that solution http://www.opengl.org/discussion_boards/ubb/smile.gif

DopeFish
03-28-2003, 06:52 AM
Pretty sure it can be done in fragment programs.. I use an arb_f_p which does 2 lookups into a single bound texture, using offset coords coming from the image data in the 2nd bound texture

Ysaneya
03-28-2003, 06:53 AM
You can bind the same texture to different texture units and access them with different texture coordinates, but since it's obvious i guess that's not what you're asking.

It should be possible to do what you're describing with any video card able to do dependant texture reads. If a card can do two texture reads (Radeon 8500 family), you can access the same texture twice. If a card can do 4 texture reads (R9700 family i guess) you can access it 4 times. GF3 and GF4 have a limited form of dependant reads, so i'm not sure it's possible to do that on these cards.

Y.

vincoof
03-28-2003, 07:34 AM
Thanks.

I'm pretty sure that GF3-4 could perform double texture access, but that's the register combiners that don't expose multiple sources for a same texture unit.

ehart
03-28-2003, 01:24 PM
You definitely can do this in ATI_fragment_shader and ARB_fp. In ATI_fragment shader, you can only fetch a single texture twice, and you need to have a two phase shader to do it. In ARB_fp, you can fetch from a single texture as many times as an implementation allows fetches. On the 9700, I believe this is 31 times.

-Evan

vincoof
03-31-2003, 01:25 AM
Thanks Evan.
I don't really need to fetch a single texture 31 times but that's an interesting information whatsoever.