Two texture samples from one texture unit

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

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

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.

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.

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

Thanks Evan.
I don’t really need to fetch a single texture 31 times but that’s an interesting information whatsoever.