x


Lightmap Bleeding Lightmap Pixels between Spacially Different Geometry.

Hi All

We have a tile based game, each level is described by a scriptable object, we have an editor and inspector to allow us to build a flat 3D world from icons that are translated into prefabs and real geometry.

To reduce the draw calls I am baking the static geometry down to a combined mesh by using the CombineChildren in 4x4 groups, so 16+ draw calls down to 1.

The CombineChildren script doesn't do anything with UV2 set so I am calling Unwrapping.GenerateSecondaryUVSet() which appears to work to a degree, however, we have two issues:

Firstly: presumably because of the way the UVs are baked, and perhaps because the combined meshes have a lot of open edges, geometry that isn't adjacent receives the edge of light bleeding in from the lightmap for another triangle.

Secondly: Similarly, because we are baking tiles into combined meshes, where one group of tiles has been baked together and then abuts another group, the edges tend towards black. This broadly look like filtering, but even if I select point for the map, then 1 texel of resolution down the edge is being lightmapped from the map that belongs to different part of the mesh, nowehere near the triable in questions.

I've tried a lot of fixes for this, changing settings that sound as if they ought to impact the mesh, but none seem to have the desired effect.

I should say that I've checked, by occluding the offending part of the mesh, and the light is not leaking through the room, but bleeding from adjacent lightmap pixels.

My questions are therefore:

  1. What is at fault here - do I need to back my own UVs to avoid this sort of thing?
  2. Otherwise, is there some option for lightmapping,for the CombineChildren script, or in the beast XML that should resolve this for me?

I'll add a few pictures Help much appreciated!

Picture showing first issues:

alt text

Second issue shows the hard edge between 'tiles'

alt text

Cheers Bovine

more ▼

asked May 06 '12 at 06:27 PM

Bovine gravatar image

Bovine
1.6k 26 30 47

(comments are locked)
10|3000 characters needed characters left

3 answers: sort newest

look here: this person had the same problem and increasing pixel light didnt work at first then he made same changes and then the pixel light worked http://forum.unity3d.com/threads/115136-More-than-2-lights

more ▼

answered Aug 11 '12 at 02:12 PM

Dhaiku gravatar image

Dhaiku
-14 1 3

This is a completely different issue where the OP wanted multi real-time lights and his setting was limiting that.

Aug 11 '12 at 02:16 PM Bovine

It is not dislike. Please read the unity answers FAQ - you've posted an answer that is incorrect and as such I've voted the answer down. The issue linked has nothing to do with this issue.

Aug 11 '12 at 03:20 PM Bovine
(comments are locked)
10|3000 characters needed characters left

Did you try increasing the pixel light count value in Edit->Project settings->Quality. test with some bigger numbers like 32 or 64 and bake

more ▼

answered Aug 07 '12 at 07:43 PM

sathya gravatar image

sathya
11 1 3

The pixel light count has absolutely nothing to do with this issue:

http://docs.unity3d.com/Documentation/Components/class-QualitySettings.html

Aug 08 '12 at 11:18 AM Bovine

I can't see how it did, but it's likely you're now using more per pixel lights in game and consequently the issue is being masked.

You should also make this a comment not an answer.

Aug 08 '12 at 11:19 AM Bovine

done, sorry i am new to the unity answer system made it a comment

it worked for me, the higher the pixel light count value, the less the seams are visible, when on 5, they are close to invisible, on 10 you can't see them being masked or not, i can't see them so they are gone when i lower the pixel light value, the seams are really hard

another thing that helped me a lot was switching some code in my shader i first had a custom lambert lighting model i changed that for the default lambert lighting, this decreased the seams alot but not completely (note that most shaders already use the default lambert)

Aug 08 '12 at 09:40 PM Dhaiku

Let me get this straight. You have a seam in your lightmap when you bake your texture. With no real time lights enabled, in he editor when you bake your lightmap you get this seam and when you increase the numbe of pixel lights for forward rendering, making NO other changes, your seams go away?

Please check we are talking about the same setting an that you are not increasing the resolution of the lightmap.

When I increase the resolution my seams also go away but I end up with 4+ lightmaps, each 1024x1024.

Aug 11 '12 at 08:47 AM Bovine

yes that is right i dont increase the lightmap size also note: the seams don't only go away in the bake, but also when i clear the bake and use realtime lights (i don't see a difference between realtime lights or bake, when i had the seam, i had them in both of them, when i increased that pixel light, they were both gone) do you have it only in the bake, or also before the bake?

Aug 11 '12 at 01:22 PM Dhaiku
(comments are locked)
10|3000 characters needed characters left

Beast LM bleeds through open edges. Try to create meshes with no open edges. afaik Combine Children script runs just before loading the game, means after baking the lights so its not the problem of combine children script.

more ▼

answered Aug 07 '12 at 01:00 PM

sathya gravatar image

sathya
11 1 3

We're calling combine children in the editor as we don't want to be combining on the device. If I don't combine there is no bleeding but there will presumably still be open edges.

We've found that an increased resolution will eventually solve the problem, but it's not very scalable.

An open edge should not abut other geometry in the lightmap - isn't that what padding is meant to avoid?

Aug 07 '12 at 01:27 PM Bovine

i have a similar problem

2 tiles next each other

1 tile is not lit, the other is lit

it's a really hard border of light

haven't yet baked any light

alt text

Aug 07 '12 at 05:46 PM Dhaiku

could you post the current resolution of your lightmap another thing: when i created an old game, i noticed that when you have more then 5 lights shining on the same mesh, unity didn't register the 6th (and 7th 8th ...) light since you combine alot of meshes in 1, unity might act weird do you have the same problem when not combining the meshes?

also welding vertexes might solve this, but when you weld all the vertexes you end up with a big mesh, and unity might act weird

Aug 08 '12 at 09:41 PM Dhaiku

We are baking 6 texels per world unit with 1 texel padding. Presumably you're talking about the number of lights that affect a baked texture? I would have though there was no limit here. It isn't anything to do with the setting mentioned, which is for real time lights in forward rendering.

Aug 11 '12 at 08:43 AM Bovine

This is not an answer and is a different issue, THIS issue relates to baked lightmaps.

Aug 11 '12 at 01:36 PM Bovine
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x328
x26
x8
x2
x1

asked: May 06 '12 at 06:27 PM

Seen: 1274 times

Last Updated: Aug 11 '12 at 03:20 PM