View previous topic :: View next topic |
Author |
Message |
Spaddlewit Member
Joined: 24 Aug 2009 Posts: 244 Location: Florida, United States
|
Posted: Sun Jun 26, 2011 9:47 pm Post subject: Properly interpreting lightmap data |
|
|
I'm just starting to get into using lightmaps and I want to be sure I understand the file format part correctly:
*) Each material specifies a texture file for lightmapping
*) When rendering a polygon in code, it might look something like this:
Code: |
glBindTexture(myTexture->alias);
// Draw polygon
if (mytexture->hasLightmap)
{
glBindTexture(mytexture->lightmapAlias);
// Switch blend mode to something-or-other
// Draw polygon again, using u1 and v1 for UVs}
|
What blend mode do I need to use (what one does DeleD use?)
Last edited by Spaddlewit on Tue Jun 28, 2011 1:41 am; edited 1 time in total |
|
Back to top |
|
|
Starnick DeleD PRO user
Joined: 28 Jul 2007 Posts: 611
|
Posted: Mon Jun 27, 2011 5:27 am Post subject: |
|
|
Yeah, each material has three user-defined layers, and a 4th layer reserved for a lightmap texture.
Applying a lightmap is easy if you're using shaders since all you're doing is modulating (multiply) the color of the lightmap with the color of the polygon (e.g. base texture or color or whatever else is specified in the DeleD material). White areas remain the original polygon color, black areas remain black.
If you're using fixed function rendering, you're going to have to look at multitexturing, which would allow you to draw the polygon in one pass, instead of the two passes you mentioned. |
|
Back to top |
|
|
Spaddlewit Member
Joined: 24 Aug 2009 Posts: 244 Location: Florida, United States
|
Posted: Tue Jun 28, 2011 2:36 am Post subject: |
|
|
Yeah, I'm using fixed-function.
Turns out the V coordinate for lightmaps doesn't need to be flipped like the regular texture materials do.
The only thing I can't figure out now is the proper glBlendFunc to use. I have it looking ALMOST just like DeleD, but there's an issue with alpha blended textures.
|
|
Back to top |
|
|
Grandmaster B DeleD PRO user
Joined: 03 Jul 2007 Posts: 218
|
Posted: Tue Jun 28, 2011 1:34 pm Post subject: |
|
|
You may use alpha testing for that:
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, 0.5) |
|
Back to top |
|
|
Spaddlewit Member
Joined: 24 Aug 2009 Posts: 244 Location: Florida, United States
|
Posted: Tue Jun 28, 2011 5:35 pm Post subject: |
|
|
I'm already using alpha testing like you said... works great for the actual texture, but it's the lightmap texture that's getting drawn where the regular texture dictates transparency.
Edit: Figured it out... For anyone else having this issue, you MUST use multitexture rather than doing multiple passes for the lightmaps to work with alpha blended textures. |
|
Back to top |
|
|
AWM Mars Member
Joined: 06 Jan 2010 Posts: 1195 Location: Wilts England
|
|
Back to top |
|
|
|