alphablending + light problem

i’ve got my multitextured alpha-blending working correctly, but i wonder how to add light (GL light not lightmap) so that it affects both texture.

I noticed that passing from multi-pass to one pass (multitextured so…) disable the lighting.

I can’t figure out what is not working…

to be more specific : only texture0 takes the light. the texure1 keep OpenGL’s default one.
I wonder if LIGHT must be st for each texture units.


you have to set up the texture environments correctly:

unit 0
GL_MODULATE // so pixel color gets multiplied by current color which is interpolated between vertices --> you have a lit textured object

unit 1
GL_MODULATE // you modulate the result of the texture unit 0 (which is lit!) by your second one

perhaps you should look at the GL_EXT_texture_env /GL_NV_registe_combiners extensions, they allow mor complex operations


yes but textured alpha blending needs the interpolate function on textUnit 1 to work…
so… :frowning:

I’m thinking, that no one Pass GL lighting is possible when using multitextured alpha blending.
Any idea ?

[This message has been edited by MPech (edited 04-29-2002).]

have a look to :

Yes, I know that i must use GL_MODULATE to mix texture1 (which i do with texture0) with the GL_LIGHT influence but the problem is that i must also apply GL_INTERPOLATE function to get alpha belnding between texture0 and texture1…
real dilemma isn’t it ?

you’ll need to use NV or ATI specific combiners then.
They both offer one other combiner you can use in your operations.

[This message has been edited by the_blob (edited 04-30-2002).]

yes but how could it help ?

when i use GL_MODULATE both textures are lighted correctly
but when I want to use GL_INTERPOLATE lighting on texture1 disappear.
the only differrence is usage of arg2 to interpolate (source2 : texture0, operand0 : src_alpha) and I can’t find why it so…

well… on nvidia and ati hardware you have some support for using all textures in every combiner (as they get fetched before, and then combined…)

on ati this is called crossbar, on nvidia its well… its known fact (register combiners prove this)
this means:

you can do in the first stage

curcolor = lerp(alpha,tex0,tex1);

and in the second one:

curcolor = curcolor*primarycolor;

that way you get:

output = primarycolor*(lerp(alpha,tex0,tex1))
or in words:
the interpolated combination of the two textures gets lightened by primarycolor, and this is the final result…

it should work…

so, if I’ve well understood :

first stage :
you get texture0 in unit0
you get texture1 in unit1
you interpolate via alpha source
(tex0alpha + tex1(1-alpha))

then you have the current color

second stage :
you modulate current color with primary color.

but don’t understand is for the second stage, to modulate both current and primary color you have to set them respectivily in unit0 and unit1, no?
so where do you register current color while you do this ?

(sorry to ask, as if I were 4 years old but i’m quite not at ease with multitexture )

Yes, if somebody know how to do it, i’m interested too.
I can’t fine any tut’ or good explanation about NV combiners.

“i cant find any good info about something from nvidia”
well then you are COMPLETELY BLIND…
nvidia’s development server is filled with tons of pdf’s, of ppt’s of zip’s of exe’s of cpp’s of c’s of h’s about EVERYTHING from nvidia…

for mpech

well i don’t know the syntax that well of the texenv for multittexturing (as i always use registercombiners)

but you got the idea…

first stage:
unit0 = tex0
unit1 = tex1
//unit2 = alphasource i just don’t know from where you want your alpha, and not sure how to set this for GL_INTERPOLATE…
combinermode: GL_INTERPOLATE

resulting equation:
curcolor = (1-alpha)tex0+alphatex1

second stage:
unit0 = primary_color //your lighting values
unit1 = previous_color //result of first stage
combinermode: GL_MODULATE

resulting equation:
curcolor = primary_color*previous_color

and this comes then onto the framebuffer (or, if you use some blending func, gets into the blendingfunction to combine with the framebuffer… )

pixel.rgb = primary_color*((1-alphasource)tex0+alphasourcetex1)

wich is EXACTLY what you’re asking for… i guess

for implementation-details, just read some docs and specs etc… myBollux has some nice code on his page i think (but i don’t know the link… the guy with something/myBollux should now put this link in…)

Thanks for the effort !
It’s much clearer now.