Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Properly interpreting lightmap data

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Community Edition
View previous topic :: View next topic  
Author Message
Spaddlewit
Member


Joined: 24 Aug 2009
Posts: 244
Location: Florida, United States

PostPosted: Sun Jun 26, 2011 9:47 pm    Post subject: Properly interpreting lightmap data Reply with quote

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
View user's profile Send private message Visit poster's website
Starnick
DeleD PRO user


Joined: 28 Jul 2007
Posts: 611

PostPosted: Mon Jun 27, 2011 5:27 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
Spaddlewit
Member


Joined: 24 Aug 2009
Posts: 244
Location: Florida, United States

PostPosted: Tue Jun 28, 2011 2:36 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Tue Jun 28, 2011 1:34 pm    Post subject: Reply with quote

You may use alpha testing for that:

glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, 0.5)
Back to top
View user's profile Send private message
Spaddlewit
Member


Joined: 24 Aug 2009
Posts: 244
Location: Florida, United States

PostPosted: Tue Jun 28, 2011 5:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
AWM Mars
Member


Joined: 06 Jan 2010
Posts: 1195
Location: Wilts England

PostPosted: Wed Jun 29, 2011 8:34 am    Post subject: Reply with quote

I came across a similar problem like this. I changed to PNG for transparancies from TGA's, which were the cause. Might be worth a try. Question
_________________
Politeness is priceless when received, cost nothing to own or give, yet some cannot afford.

Checkout:
http://www.awm.mars.yourinside.com/
http://www.bccservices.co.uk
http://www.localtradecheck.co.uk
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Community Edition All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum