PDA

View Full Version : texture blending



zroobavela
02-07-2002, 09:40 AM
Hi,

I need to blend two textures like so:

T1 = texture #1
T2 = texture #2
F1 = fragment #1
F2 = fragment #2

needed blend = T1 * F1 + T2 * F2

Thanks

Julien Cayzac
02-07-2002, 10:02 AM
I need to blend two textures like so:

T1 = texture #1
T2 = texture #2
F1 = fragment #1
F2 = fragment #2

needed blend = T1 * F1 + T2 * F2

Thanks

I must have missed the question mark...

Julien.

zroobavela
02-07-2002, 10:11 AM
sorry.

I am trying to blend these two textures as I described. I cant find the support for such a blend.

I am trying to do this in one pass (using multitexturing).

modulating seems to take the first texture as the fragment for the second texture, like so:

out = F1 * T1 * T2.

opengl blending seems to do the following:
F1 * (1 - T1 ) + F2 * T2

whereas I need

F1 * T1 + F2 * T2.

I took a look at ARB_texture_env_add.
but this just wants to add the fragment to the texture.

does anyone know how to implement the blend function I need, namely F1 * T1 + F2 * T2?

thx

jwatte
02-07-2002, 10:23 AM
Where is the second fragment supposed to come from?

zroobavela
02-07-2002, 10:31 AM
both first and second fragments are calculated real-time and are supposed to encode the blend ratios for r,g,b values in each texture.

Now, ultimately, the fragments are supposed to be the (ohterwise unuser) diffuse and specular color fragments.

should I move this to the beginner's forum, you think?
thanks again

jwatte
02-07-2002, 10:38 AM
No, but I think you should explain what you need a little better.

You want two different textures to be modulated by two different "modulators" (I don't think "fragments" is the word you really want here). Then you want to sum them.

The next question is where F1 and F2 come from. Are these a primary and a secondary color? Or are they texture lookup results?

Assuming that you want full color modulation, not just alpha modulation, and that F2 is not just 1-F1, then you will need to use the register combiner extension on nVIDIA hardware and the pixel shader extension on ATI hardware.

If you want better answers, you'd need to supply better information about the problem :-)

zroobavela
02-07-2002, 10:40 AM
thanks.

mcraighead
02-07-2002, 01:17 PM
This sort of formula is supported on all NVIDIA hardware since the TNT, using the NV_texture_env_combine4 extension.

- Matt