View Full Version : Multipass lighting/texture question.
10-29-2000, 01:04 AM
Hi, as some of you probably know I finally got a 3d card that can do multitexturing. I've been trying to figure out how to collapse a 2-pass rendering technique into one multitextured pass. I'm not sure if it's even possible.... http://www.opengl.org/discussion_boards/ubb/rolleyes.gif
Here it is:
1. Turn off OGL lighting and texturing.
2. Render objects in pure white/yellow.
3. Turn lights and texturing back on.
4. Render the objects again.
Okay, so whats so good about that? Well, the textures for the objects have an alpha channel and are mostly fully opaque, but where theres a window in the RGB image there a blob of transparency in the alpha channel.
This means I can use OGL lighting and still have full-lit 'windows'. See?
So can I use multitexturing somehow by turning off the the lights on one texture unit ? (Its sounding more dodgy the more I think about it http://www.opengl.org/discussion_boards/ubb/smile.gif )
10-29-2000, 10:15 AM
I can't quite figure out what you're trying to accomplish (what formula)...
There may be some way to do what you want, but first I'd have to know what you actually want.
10-29-2000, 01:08 PM
Um, formula? I'm pretty new to all this multitexturing/blending lark so haven't quite got my head around the algebra just yet (don't ask me what the combiners are going on about just yet http://www.opengl.org/discussion_boards/ubb/smile.gif )
What I want is OpenGL lighting with my big space ships, but I don't want it to affect the windows in the ship's texture. I want them to remain at full brightness, whatever the OpenGL lighting.
So when I render the object in the first pass I don't have any lights, or textures and I render it yellowy-white.
Then I render it again with lighting and texturing switched on. The pure transparent texels in the alpha component of the texture are where the 'windows' are in the colour component.
This means that the first pass 'shines' through here - and no OpenGL lighting happens, so the space ship's windows are fully bright no matter where the OpenGL light source or its intensity.
I can even vary the transparency in other places and have a kind of 'hull light' effect, but that can look pretty shabby.
I don't think there's anyway to do this on two texture units is there? Can you turn the lighting calculation off for one texture unit and leave it on for the other?
If I could, would I have to bind a plain yellow texture to the ship for the first pass or can I render it untextured...?
I just dunno.
10-29-2000, 04:57 PM
So let's put the texture in T0, with T0.a indicating 0 (window) or 1 (hull), and with the primary color coming from OpenGL lighting. Let ConstantColor be the color you want the windows to be.
ConstantColor * (1-T0.a) + PrimaryColor * T0.rgb * T0.a
This can be done with EXT_texture_env_combine, with the caveat that you have to work around the fact that you can only access the current texture in each texture unit in that extension.
Enable both textures, and bind your texture to both of them (that's the hack). In unit 0, configure your environment to MODULATE. In unit 1, configure it to COMBINE_EXT with an operation of INTERPOLATE. Interpolate between the constant color and the previous result, using the texture's alpha.
10-29-2000, 05:08 PM
Fantasic, I'll give it a go.
I never would have got that - you just had to use that 'combine' on me didn't you? http://www.opengl.org/discussion_boards/ubb/wink.gif
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.