PDA

View Full Version : Lightmap artifacts



NecroDOME
19-01-2007, 04:12 PM
http://necrodome.homeftp.net/zooi/LightmapArtifact.jpg

As you can see in the image I got some artifacts in my lightmaps. How can I eliminate them?

Here you find the actual light map images.
http://necrodome.homeftp.net/zooi/Lightmaps.jpg

JSoftware
19-01-2007, 04:15 PM
Isn't that either rounding errors or wrong wrapping mode?

Nitrogen
19-01-2007, 04:36 PM
That's a common edge bleeding artefact.
I had plenty of problems with them when I wrote my lightmapper.

A solution is to leave a gap of 2-3 pixels around each shape in your lightmap, then after you finished generating the entire lightmap, go back over it and extend the edges of all the shapes in your lightmap.

The way I did this is something like this:
- Colour in the background of your lightmap a rarely used colour, like (255, 0, 255) or something
- For each pixel of your lightmap:
--- if this pixel is (255, 0, 255) then
--- add up all adjacent pixels which are NOT (255, 0, 255)
--- colour this pixel the average of these colours.

And that should fix it.

Huehnerschaender
19-01-2007, 05:23 PM
Setting the SamplerStates for AddressU, AddressV and AddressW to D3DTADDRESS_CLAMP before rendering the lightmap and after that setting them back to D3DTADDRESS_WRAP should fix the problem I think.

NecroDOME
20-01-2007, 01:40 PM
clamp does not work, already tried that. I think nitrogen has the solution to add padding on each lightmap.

JSoftware
20-01-2007, 05:38 PM
What about clamp_to_edge instead of just clamp?

Huehnerschaender
20-01-2007, 08:54 PM
I never had good thoughts about padding solutions. This cannot be intended by Microsoft. There must be a better way (in fact the way it is intended). I am interested in those "techniques" too, so if anyone knows the answer for all those antialiasing problems, please spread your wisdom :) There are also strange artifacts when using Mipmapping and transparent textures... Too many problems for a single feature. There must be some kind of renderstate that is designed to avoid those artifacts (at least I hope so).

In most cases, the clamp did work for me... But there are still problems in some cases...

NecroDOME
21-01-2007, 12:22 PM
disable mipmaps for a specific renderstate (eg. lightmaps). My world the world becomes also invisible when, due mipmaps are createded, but not filled in any way with any color... (however I didn't tried it yet)

And how can I enable face clamp?