Jump to content
  • Advertisement
Sign in to follow this  
Crispy

OpenGL lightmaps - a weirdish (texture coordinate?) issue

This topic is 5058 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've based my lightmap generator on this article. Eventually, after quite a bit of tweaking, I got it almost working the way I need it to. However, there are a couple of issues that most likely either relate to texture coordinate generation or some OpenGL-specific thing: since the lightmaps, when output as files, look just fine, there's no reason to believe that the generation istelf is flawed. When examining the texture coordinates manually, those, too, seem to look very okay. A few examples of n-side convex polygons: 1) 1 0 / 0 0 / 0.263566 1 2) 0.374378 1 / 1 1 / 0.865934 0 / 0 0 3) 1 0 / 0 0 / 0.724696 1 4) 1 0 / 0.515152 0 / 0 1 / 1 1 5) 0.5 0 / 0 0 / 0 1 / 1 1 6) 1 1 / 1 0 / 0 0 / 0 1 However, when rendered, the result is this: It is as if the lightmaps are too short - if the lightmap is dark at one end and bright at the other, a narrow band of dark appears in the bright end and, inversely, a narrow bright band appears in the dark end. Here's another screenshot, which is probably more descriptive: There are three lightmaps in this screenshot. They all align perfectly color-wise, were it not for this problem. Another note - the breadth of the band is relative to the size of the polygon: because I'm using fixed-size lightmaps, the bands appear to be larger on larger polygons. Furthermore, when increasing lightmap size, the breadth of the band decreases - as if only a small number (one?) of pixel rows/columns of the original image was messed up. I'm all out of ideas as to what could be wrong at this point - the original version works in the demo code provided with the article and the lightmaps seem to be generated properly. Can anyone suggest what could be wrong? Possibly something related to the textures in video memory? This would be quite weird because all other textures display properly.

Share this post


Link to post
Share on other sites
Advertisement
How are you rendering your textures?

It could be something to do with your texture filtering you could be using.

This would create this effect because of tiling. Your final pixels would be blured by the pixel that would be next to it if it were tiled. To fix this, instead of tiling your light maps, you just flip them at every integer texture co-ordinate.

I don't know about OpenGL but in D3D it'd look like this

'tiling a texture
pd3ddevice->SetTextureStageState (0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);

'you could flip the texture at each int interval (0, 1)
pd3ddevice->SetTextureStageState (0, D3DTSS_ADDRESSU, D3DTADDRESS_MIRROR);

'or you could clamp it which makes any pixel outside the range of 0 - 1 equil to the value of 0 or 1 respectively. Kinda like stretching the last row / colum of pixels.
pd3ddevice->SetTextureStageState (0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);

I hope that helps you. Maybe someone knows how to do this in OpenGL

Matt

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!