Lightmaps vs dynamic lighting over mesh terrain issues :/

I am having the following issue with my static mesh terrain (1024 lightmap resolution, skylight and 1 directional light in the scene):

Lightmaps (no dynamic lighting - directional light is set to be static; lightmaps directionality is on in the Project settings):
ue4_terrain_lightmaps.png
Full image: http://s33.postimg.org/tg2je443h/ue4_terrain_lightmaps.png

Dynamic light and no lightmaps:
ue4_terrain_dynamic.png
Full image: http://s33.postimg.org/f0zbn6t31/ue4_terrain_dynamic.png

Why do lightmaps looks so horribly different ?

Forgot to add that I am using 4.11.2

It looks like normal map doesn’t even accounted for in static lighting, regardless if the checkbox is ticked in the Project settings :frowning:

Funny thing that if I place a static mesh on the terrain, it casts proper baked shadow on the terrain. It might be some sort of self-shadowing issue with static lighting. I have a strong desire to ditch UE4’s lightmaps and bake those in Blender instead, and multiply the image with the rest of the material (too bad that won’t work / will be too much manual work for static meshes that aren’t terrain or come with UE4).

Posted bug report: https://answers.unrealengine.com/questions/433837/static-lighting-directional-lightmapping-and-self.html

Don’t mean to be pushy, but it’s kinda critical :frowning:

The shadow bias setting is probably affecting the dynamic shadows (controls how close the shadows are to the caster) for the static lighting the terrain is very large so it’s difficult to get a good result, usually people avoid using baked lighting on large environments because you either end up with a high number of lightmaps or you can’t get enough detail.

I can’t use dynamic lighting (it’s for mobile VR), so I can only use static. I am guessing I need to scale down my terrain and see if on smaller scale baked lighting would look any different.

It’s just very odd looking lighting - even large terrain should have proper lighting, similar to what you see with fully dynamic lighting. The only thing that would be different is jagged shadow edges and highly pixelated baked shadows from normal map.

Alright, I tried making mesh smaller, tried bumping up lightmap resolution - no use.

Trying to work with normal maps being compressed as DXT5 now. After that, trying to bake without normal maps and if it looks the same.

No luck with anything I tried. Tomorrow I will bake shadows in Blender and see if I can substitute that for lightmaps in UE4.

I’d be using the WorldNormal visualisation mode to make sure there isn’t something weird going on with that normal map that could be affecting lightmass…

I’ll try, but what should I be looking for ?

I also tried baking lightmaps without normal map, and got similar results :frowning: It looks more like self-shadowing issue as different actors cast pretty good shadows on each other and on the terrain.

@RyanB: Do you happen to know why I am having these issues with self-shadowing on the terrain ?

Thanks

Are you sure your landscape even is inside the dynamic shadow radius in the pic with dynamic shadows?

I am pretty sure it is as I saw CSM acne and artifacts flickering on the slopes as I was moving camera around.

I am actually showing off self-shadowing there and how normal map contributes to shading. Lightmapped surface should look pretty close to that, but it doesn’t at all.

Looks to me like there are no shadows in either image. I believe your light angle is not shallow enough to actually cast any shadows from those gentle slopes. When you rebuild static lighting, the directional light is being constrained to be one of the only 3 ‘lobe’ directions for directional lightmaps. Each lobe is spaced 120 degrees around a circle and they are at a certain pitch above the ground as well. I am not sure off the top of my head what that angle downward is but its probably 30-50 degrees.

So if you had a somewhat shallow directional light, it gets snapped to a direction that is not as steep. So the normals are still affecting but they are seeing a different light direction after rebuilding. That is expected. Use a stationary sunlight if that is a problem.

Try making your sun much steeper so that actual static shadowing comes into play.

(After work) I’ll post comparison screens with camera at a different angle/location for unbuilt lighting and rebuilt lighting. The shadows are clearly there, I am not sure why you would say otherwise :slight_smile:

I just need to have static lighting, not dynamic lighting at all (it’s for mobile VR). The sun (static directional light) is slightly above horizon (dawn). The reason for dynamic vs static screenshots are to show how soft self-shadowing is with dynamic lighting, and how “low poly” (almost like vertex lighting, not lightmaps) baked lighting is.

EDIT: Just baked lightmap in Blender - much smoother shadows than in UE4:

terrain_lightmap.png
Full: http://s31.postimg.org/hjghrratn/terrain_lightmap.png

I still think the problem is that your light rays are basically parallel to the slope of the terrain you are trying to shadow. It looks like in a few spots there is an actual shadow, but most places above looks like backface normal attentuation to me as opposed to shadowing. It is easy to confuse them since they work together usually. I say that because the ‘shadow’ is stopping right at the crevice between the two dunes. If there were actually a cast shadow, it would also cast a bit on the upward slope of the lit dunes.

I made this image a while back to explain the same thing to somebody else with the same issue:

You are probably very close to the blue line such that lightmass doesn’t detect the shadow but the dynamic shadowing with its various biases and inaccuracies is.

Just humor me and try making the sun more shallow like the yellow line.

I see what you mean. I will do several different bakes later today and will post it. Thanks!

@RyanB:

Alright, here is video showing no lighting and dynamic light:

Dynamic:
ue4_terrain_lighting_dynamic.png
Full: http://s31.postimg.org/p5qnkuee1/ue4_terrain_lighting_dynamic.png

Static (lightmaps only; “Use normal map for static lighting” option is on):
ue4_terrain_lighting_static.png
Full: http://s32.postimg.org/syck09g2r/ue4_terrain_lighting_static.png

Static (lightmaps only; “Use normal map for static lighting” option is off):
ue4_terrain_lighting_static2.png
Full: http://s31.postimg.org/sbc6dw2mh/ue4_terrain_lighting_static2.png

If you open full images in two different tabs in your browser and look at them, the difference is quite noticeable.

Looks like it may be computing the lightmaps with lower LOD due to the vertex shaped artifacts on some edges. I will have to check if that is a bug or not, but the rest of the shading differences could possibly just be the loss of precision between a dynamic light and a static one, and perhaps the static one is also getting more bounce lighting that is filling in the shadows. Have you tried setting indirect to 0 for the static one?

There is some other project setting that makes it so that normal maps cause normal shading based on that normal to bake into the lightmaps but I can’t recall what it was called and I am not certain if it will help here.

The terrain is about 10k tris and has no LOD. That’s why it’s puzzling to me to see dynamic lighting working well (predictably), and static lighting not working well as if it doesn’t take into account normal map :confused:

No, but now I will :slight_smile:

Thanks

EDIT: Just finished building lighting with “Use normal map for static lighting” off and it looks (almost) identical to build with that option on. Sounds like a bug.

EDIT 2: Added images to the previous post

Oh right for some reason I forgot this was a static mesh not a landscape. That explains the jaggy artifacts then.

So that might explain more what is going on. I will try to find that project setting for normals and lightmass (if it even still exists). It used to be possible to make it take the normal map into account for this.

You could always import a 500k mesh as LOD0 and simply force it to render as LOD1 with 10k tris as a workaround :slight_smile: