View Full Version : alphablending + light problem
04-29-2002, 05:43 AM
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...
04-29-2002, 07:55 AM
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.
04-29-2002, 10:38 AM
you have to set up the texture environments correctly:
GL_MODULATE // so pixel color gets multiplied by current color which is interpolated between vertices --> you have a lit textured object
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
04-29-2002, 01:12 PM
yes but textured alpha blending needs the interpolate function on textUnit 1 to work...
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).]
04-29-2002, 10:42 PM
have a look to : http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/004481.html
04-29-2002, 11:36 PM
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 ?
04-30-2002, 03:51 AM
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).]
04-30-2002, 05:40 AM
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...
04-30-2002, 07:27 AM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif (register combiners prove this)
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.. http://www.opengl.org/discussion_boards/ubb/smile.gif
04-30-2002, 08:30 AM
so, if I've well understood :
first stage :
you get texture0 in unit0
you get texture1 in unit1
you interpolate via alpha source
(tex0*alpha + 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 http://www.opengl.org/discussion_boards/ubb/wink.gif)
05-01-2002, 07:00 AM
Yes, if somebody know how to do it, i'm interested too.
I can't fine any tut' or good explanation about NV combiners.
05-01-2002, 08:19 AM
"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..
well i don't know the syntax that well of the texenv for multittexturing (as i always use registercombiners)
but you got the idea..
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..
curcolor = (1-alpha)*tex0+alpha*tex1
unit0 = primary_color //your lighting values
unit1 = previous_color //result of first stage
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.. http://www.opengl.org/discussion_boards/ubb/smile.gif)
pixel.rgb = primary_color*((1-alphasource)*tex0+alphasource*tex1)
wich is EXACTLY what you're asking for.. i guess http://www.opengl.org/discussion_boards/ubb/smile.gif
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...)
05-01-2002, 09:11 AM
Thanks for the effort ! http://www.opengl.org/discussion_boards/ubb/wink.gif
It's much clearer now.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.