Hey guys.
This is an issue that's been causing me headache the past couple days. When baking lightmaps with the "non directional" option, my maps look fine. But I need to use the "specular directional" option in the end since I will be using spec maps, and the results are far less than satisfactory.
Here's an image that shows what I'm talking about using an example mesh. I created my own lightmap UVs in a second channel so that I could control my seams and softness / hardness of edges. When baking "directional specular," however, the edges that are fine in "non directional" get really jacked up. The only way I can avoid this right now is letting Unity generate UVs for my mesh, but this results in hard many hard edges and seams in incorrect places.
Just curious if the problem is user related and I'm missing something here.
Thanks a ton!
Replies
echo - I don't believe its a padding issue. Here's a pic of the lightmap baked that I opened in photoshop:
None of these artifacts seem to be visible in them.
There is no black line, like the model shows...
It looks like the errors are happening at smoothing group change areas - which is odd, because that should have nothing to do with UVs and doesn't happen in a Non Directional Bake.
As echofourpapa said, remember to treat every hard edge as a seam on lightmap uv.
I attempted a few bakes with preserve UVs on and off and tried a few different amounts in UV max disntance / angle, resulting in no change in the bakes=(
When I split the UVs in those problem areas, the hard black lines go away and the bake looks "correct", but then I lose the soft bleed that I had before in the non directional bake that made the hard edge seem much softer.
Example: first one is with connected edges, where I intentionally want a bleed.. second is with detached
Any way to get this effect in the directional specular bake other than adding more geo?
In the lighting tab at the bottom when you have an object selected it will show you how your different maps sit on your UVs(Unity used several UV channels, not just one). You might be able to identify what map and UV layout is causing the problems.
I've been experimenting today I think I encountered your problem. I'm using a single directional light, and I get this problem in both directional and directional specular. It might end up being UVs. but I know that adjusting bounces and resolution greatly affect it.
Here's what I'm getting with Unity primitives, single directional light and baking:
Here's the subject prop, a barrel:
I packed the lightmap UVs manually in Blender, to get something packed really tight:
I set it to Preserve UVs and baked, bad lines on seams:
Taking a look at the lightmap I see this:
Not only does Unity repack my UVs(why?) but the padding is pretty awful:
Now I let Unity Generate Lightmap UVs with angle set to 120, and the barrel looks great:
On closer inspection, I found a few problem areas, here:
and here:
The textures had been covering them up, so I didn't notice them until I removed them. On the light map those areas are here:
As you can see the resolution is pretty low and the padding about a pixel or two.
I ran a test, I doubled the atlas size and baked GI texel resolution, and the problems go away, and there is at least some padding:
I'm getting better padding and a better final result.
Also, it turns out that the lightmaps are mipped(I'm not sure why this surprises me). So the problem should get worse the further you are and better the closer you are.
Close: Far:
I'll be lightmapping again soon (I lightmapped a ton in 4.2, a couple years ago) so I'm sure I'll be running into the same issues.