Lightmap packing - avoiding bilinear filter artifacts

Started by
4 comments, last by MadCoder 23 years, 8 months ago
I''ve coded a lightmap generator, which combines smaller lightmaps into a bigger lightmap. Since I used a naive strategy when packing the lightmaps I get bilinear filtering artifacts when rendering from the packed lightmap (the adjacent lightmap blends into the one being rendered on the edges). Now, I''m trying to evaluate the options I''m having: 1. Surround each smaller lightmap with a rectangle of pixels duplicating the edges, hereby wasting texture space. 2. Scale the texture coordinates inward (will 0.5 pixels be enough here?), so that only the actual lightmap will be sampled during bilinear filtering. What do you guys think? Are there other (better) methods or are these the only alternatives? Mucho thanks, MadCoder
Advertisement
I''m wondering how you generate your texture coordinates ? Anyway, maybe you could try to make 2 adjacent polygons also have 2 adjacent lightmaps in your bigger lightmap ? I don''t know how to do that, though..

Y.
I just thought of this, so maybe, maybe not:

You have two square polygons next to each other, each the same size. One needs a light map about twice the res of another. So A has a res of 16x16 and B a res 32x32.

How do we align these?

A | B
0,0 1,0 | 0,0 1,0
0,1 1,1 | 0,.5 1,1

In other words, where B aligns to A, it is using only 16 of the 32 texels. Wasteful, yes, but it could enable you to align textures of different res, and save in the end.

It would be up to you to generate the texture properly.


_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
Mmmh, I think I have to restate the question a bit...

The problem is, I have a lightmap with a bunch of smaller lightmaps (I''ll call them sublightmaps for clarity). Now, when I render a polygon with a sublightmap, I can see part of the adjacent sublightmap ''blend'' into the edge of the polygon. This is caused by the bilinear filtering at the edges, I think. So, if I render a polygon with a dark sublightmap, and a bright sublightmap is right next to it in the packed lightmap, the bright color can be seen at the edge. The texture coordinates are correct. This problem generally occurs when doing this kind of thing naively (like I am). I can only modify texture coordinates (scale them, so that even with the error bilinear filtering introduces the texture unit samples within the sublightmap at all times), or duplicate the edge pixels for each sublightmap (along the edges).

Ysaneya: I don''t think this can be done without wasting way too much texture space. Nonetheless, it would solve the problem. The algorithm for this would be quite tricky I bet...

bishop_pass: First of all, if the square polygons are the same size, their lightmaps will also have the same resolution (at least in my engine). I assume, that what you posted there are texture coordinates, but don''t see how it will solve my problem (maybe I''m just too stupid to understand). I think, you mean a different effect ... the sharing of an edge between polygons which have different resolution lightmaps.

MadCoder
quote:Original post by MadCoder

I think, you mean a different effect ... the sharing of an edge between polygons which have different resolution lightmaps.

MadCoder


That''s what I meant, yes.



_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
Creating a redundant border is the appropriate way, you should not be concerned about a few texels more. The rescaling of the lightmap could cause artefacts, because then you´re displacing your sample points.

Check out the paper by Zhukov about lightmaps : www.creatstudio.com/papers.htm

This topic is closed to new replies.

Advertisement