Advertisement

Multitexturing blending equations...

Started by December 11, 2003 07:11 PM
5 comments, last by Hobbiticus 21 years, 2 months ago
I'm currently working on a project for the Torque Game Engine, and I'm trying to see if I can brighten up interiors somewhat. The interiors use lightmaps for lighting, but there's no way for them to "shine." Right now, the texture color is just multiplied by the light map. This means that the maximum brightness can only be that of the texture. So, when the lightmap is at full intensity, the material is at its normal color. What I'm thinking of doing is instead of 1.0 being full brightness, 0.5 would be full brightness, similar to that of the bump mapping tutorial found here. So, shadows would be < 0.5, and highlights (say, 2 lights are shining directly on a surface, causing it to be brighter than normal) would be > 0.5. This can be accomplished with a blend function of GL_DST_COLOR, GL_SRC_COLOR, but that would require two passes. The rendering is currently set up using multitexturing and using a single pass, so I don't want to make it slower than it already is. What I'd like to do is just change the exporter so that it will support this type of lightmap format, and change the rendering function to do the same. Hopefully, all that I will have to change is texture environments in order to accomplish this. I'm pretty sure this can be done with the GL_COMBINE_EXT/_ARB extension (whatever extension group this is in) in order to accomplish this. The problem is that I cannot find good documentation on all of the different modes and constants, and what they have to do with each other. Would anyone happen to know a good reference for this or would anyone know the correct texture environments for this? In a nutshell, I want to use a blending equation of GL_DSR_COLOR, GL_SRC_COLOR in multitexturing instead of blending to allow a single pass rather than multipassing. EDIT: Ok, another question. All of the material colors seem to be clamped to the original texture color for all other objects. If the light intensity goes above 1, then the color stays the same, but the "line" between light and dark becomes more defined, as if the same thing as above with the light maps is happening with anything else. Is there a way to "unclamp" the textured materials? Legends Development Team [edited by - Hobbiticus on December 11, 2003 8:31:35 PM]
Legends Development Team
what you want to do can be done..

for a good ref, goto the GL extension registry, and find GL_ARB_texture_env_combine, and it''s extensions (extensions to an extension ) GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3, and the most annoying possible, GL_NV_texture_env_combine4 and GL_ATI_texture_env_combine3 which do pretty much the exact same thing but do it very differently!! grahh!!

anyway.

yes you can do ''overbright'' texture blending with texture combiners. This can either be scaled to either 2 or 4. This also includes alpha too, which is quite useful actually.

basically, to overbirght a texture unit, all you need to do is:


glActiveTextureARB(GL_TEXTUREn_ARB);
glClientActiveTextureARB(GL_TEXTUREn_ARB);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvf(GL_TEXTURE_ENV,GL_RGB_SCALE_ARB,2.0f);


needless to say combiners can do _a_lot_ more than just this so I suggest you look into them deeply.


As for your second question, no, you cannot stop the clamping. however you can simply half the brightness of the light and then overbright the result...

| - Project-X - | - adDeath - | - my windows XP theme - | - email me - |
Advertisement
Ok, so this is how it looks right now:

// Lightmaps
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

// Base textures
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

I'm too tired to think right now, but I tried commenting out the second call to glTexEnvi and adding this after:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0f);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);

and that doesn't seem to work. If anyone knows, please post, and then I can make it work really quick in the morning. Thanks.

Legends Development Team

[edited by - Hobbiticus on December 12, 2003 2:11:14 AM]
Legends Development Team
You could also look up GL_ADD_SIGNED_EXT, it would simply ADD your light map over-top of your base texture.
No, adding wouldn''t work right because then you couldn''t have shadows. There needs to be a multiply in there somewhere.
Legends Development Team
It seems like the scaling isn''t working for some reason. Even if I turn off the lightmaps and not try to modulate anything and just scale the texture colors, the textures don''t brighten at all. What''s going on here?
Legends Development Team
Advertisement
Ok, apparently I''m a retard, and being lazy, I just #define''d the missing constants in the file I''m working in, and I used the wrong constant for GL_SCALE_RGB_ARB, and now it works. Looks great! Thanks!

Legends Development Team
Legends Development Team

This topic is closed to new replies.

Advertisement