Lightmapping problem

Started by
4 comments, last by VladR 17 years, 11 months ago
Hi!! Can you please help me with this lightmapping problem: I seem to have seams at the edges of polygons and can't understand why, take a look here please http://www.godsofasgard.as.ro/engleza/images/uniform%20density1.JPG http://www.godsofasgard.as.ro/engleza/images/bad1.JPG http://www.godsofasgard.as.ro/engleza/images/wireframe.bmp.JPG So what could possibile be wrong? Here's how I create the lightmaps glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, 3, LIGHTMAP_SIZEW, LIGHTMAP_SIZEH, 0, GL_RGB, GL_UNSIGNED_BYTE, pPolygon->lightmap); Please, where could the problem be?
Advertisement
In the second shot "bad1.jpg", are each of the tiles of your flat grid getting their own texture? If that is the case then this is fairly common with lightmapping and is called "bleeding". This happens when you are filtering your lightmaps and is very well explained in this flipcode article ...towards the end the author goes into detail as to what causes it and what can be done to remedy it.

If however each tile isn't getting it's own texture then i'm not sure what is going on [smile]

Hope this helps,
ViLiO
Richard 'ViLiO' Thomasv.net | Twitter | YouTube
In fact each triangle there get's a different texture for lightmapping, but how are the pixels from the edges are affected by filtering with illegal pixels? I mean there's no way out of the texture is it? and the seams do not appear on the diagonal edges there... They only appear on the sides of the texture, so how and by what illegal pixels(out of the map, that do not show on the screen) are affected the good pixels around the edges? Please clarify this for me, I'm a little :) confused
You are using bilinear filtering so each pixel is a blend of four texels. When you sample in the middle of your lightmap texture you are averaging four *different* texels. Not so at the edges, due to the clamping. In the corners, where both u and u are clamped, the four sampled texels will be the same.
one solution for this problem is to scale down the UVs a little bit (about a half texel) to the center of your polygon.
1. Each vertex should have UV coords of the middle of the texel (half-texel accuracy.
2. Another easy solution is to put one row of texel around each side of the triangle - this way, it`ll definitely sample the texels that are neighbouring the edges.

Try either way and post results here.

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

This topic is closed to new replies.

Advertisement