Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Hobbiticus

Multitexture modulation

This topic is 5556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m having some issues with doing lighting for the game I''m doing. We have day/night cycling in the game, but the interiors aren''t lighting well with it. A static lightmap is generated at the start, so that outside light is added to the inside color. What I want to do is multiply the lightmap by a certain color, preferably at render time, in order to modulate what light comes in with the computed outdoor color. The lightmap is 0,0,0 when it is obstructed from outdoor light and the color of the outdoor light dotted with the surface normal when visible. There are 2 textures that are applied during multitexturing - the light map and the base map. They are added together to make the final color. What I need to do is multiply the light map by a certain color to get the final computed color. Any ideas about how to go about doing this without totally sacrificing performance? Legends Development Team

Share this post


Link to post
Share on other sites
Advertisement
If I get right, all your interiors have two textures :
- a lightmap,
- a base texture.

I guess the lightmap is a greyscale texture. But does the lightmap correspond to the outdoor "visibility" ? For instance, the value 0 in the texture means that no light is added for outdoor, and the value 255 means that light contribution from outdoor is added ?

Do you want the outdoor light contribution to be constant (an ambient term) or do you want to be "intelligent" (assuming you know the light direction, you would add N.L) ?

Share this post


Link to post
Share on other sites
Yes, that''s pretty much how it works. And, for it to be "intellegent" and shadow correctly and all that, there would be massive frame loss, so I''d rather not. I just want to modulate the lightmap with the ouside sun color.

Legends Development Team

Share this post


Link to post
Share on other sites
Apart from sun contribution, do you use lighting (for instance, lamps in the indoor scenes) from OpenGL''s lighting mechanism ?

Share this post


Link to post
Share on other sites
Yeah, there''s regular fog, textured fog, fog coordinates (fog volumes), transparency, and environment maps, but I wouldn''t think that would effect what I''m trying to do. I''m not exactly sure what''s going on throughout the entire render, but in this part there''s just the lightmap and base texture. I just need to modulate the lightmap only when I render. 2 passes would suck.

Legends Development Team

Share this post


Link to post
Share on other sites
I guess your best bet is the texture combiners.
More than 90% of today OpenGL-compatible cards support it and it''s pretty efficient too (unlike pixel shaders and-the-like).

You still haven''t answered to an important question: do you use OpenGL''s lighting ? but I''ll post the no-lighting answer then. I guess you assume that multitexturing is available with two texture units, otherwise you can skip this post and flame me as many as you want.

Without Lighting :
- setup the night&day global term to glColor (be it 0 at midnight),
- setup the lightmap to the first texture unit
- setup the base map to the second texture unit
- in the first texture stage, setup the tex env GL_MODULATE, which computes (lightmap)*(night&day)
- in the second texture stage, setup the tex env GL_ADD, which computes (lightmap)*(night&day)+(basemap)


With Lighting it is still possible but I need to know a bit more how you do compute lighting : OpenGL''s standard light ? PPL ? Bump-mapping ? how many texture units can you afford ? etc.


Also, how is computed your volumetric fog ? in the fog coordinate or using VCI ?

Share this post


Link to post
Share on other sites
The interiors are not lit through standard opengl lighting. There''s no bump mapping (as of yet...gotta figure out how to do that), and the fog volumes are independent of the render as far as i know. That should hopefully do the trick. I was thinking that those combiner thingies would be what I needed but I''ve never seen documentation on them or bothered to look them up.

The existing (bugged) render uses material properties and enables opengl lighting to light the structure, which doesn''t play nice with the existing lighting.

Thanks a lot. I''ll give it a try soon.

Legends Development Team

Share this post


Link to post
Share on other sites
Ok, if lighting is disabled it is much simpler.

As for texture environment GL_ADD (I mean glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD)) you should check the availability of the GL_ARB_texture_env_add extension which is (as far as I''ve ever seen) supported on ALL cards that support multitexturing, so it should not be a problem in practice.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!