Baked indirect lighting from the terrain is missing

Hello!

I am trying to bake lighting in Baked Indirect mode using Progressive GPU/CPU lightmapper. Everything works fine except the terrain. Terrain object do not contribute indirect lighting to the scene. If I replace terrain object with plane mesh indirect lighting is baked correctly. Plane object has the same albedo value as terrain texture.

The terrain is marked as a static object, contribute GI is enabled, and sunlight uses baked mode.

Tried to enable/disable instancing on terrain, to replace terrain material and shader (TerrainLit, Lit, Unlit). I also tried emissive material and CPU lightmapper, shadowmask mode but the result is the same. Indirect lighting from the terrain is missing.

Unity 2022.3.26f1, HDRP 14.0.11.


Top: Terrain object. Bottom: mesh object.


Baked lightmap preview mode looks broken.


The terrain lightmap is baked but does not contribute GI to the scene.


Lighting settings.


Important note: Enlighten lightmapper works fine with same terrain.

The artifacts on the third image look like texel validity artifacts to me. Please take a look at this post and see if the advice does anything for you Lightmapping Troubleshooting Guide

TL;DR make your emissive Double-Sided, or increase Bakeface Tolerance in your Lightmap Parameters Asset. Use the texel validity debug mode to see if invalidity is your issue (there should be a bunch of red spots)

Thank you!

I’ve tried double-sided emissive or diffuse materials, increased backface tolerance up to 1, and increased pushoff but the result is the same. No matter what material I use on the terrain object - indirect lighting is missing. I used debug modes to preview texel validity and UV overlap. Texel validity output is green on terrain, plane, and walls. No UV overlaps are visible. Left: mesh object, right: terrain.

However, Baked Albedo debug mode shows completely black albedo on a terrain.
Left: mesh object, right: terrain. Progressive lightmapper.

Same with Enlighten GI. (Didn’t noticed earlier) Baked Albedo debug mode shows a completely black color, and Baked Indirect debug mode shows no indirect lighting from the terrain.
Left: mesh object, right: terrain.

Yes, completely black albedo cannot generate bounced indirect diffuse lighting. But I don’t see the reason why it becomes black only on terrain object during baking.

Just tested the same scenario (Static terrain and static walls) with the Built-In pipeline project and baking indirect light from the terrain works fine. Baked albedo debug mode displays correct albedo value and bounced light generated during bake.

I also tried to use the unsupported Built-In standard shader in HDRP project to test baking from it. It fails to render and it’s fine, but still picking albedo value for baking. But terrain object gets same black albedo color during baking.

Baking from Built-in shader in HDRP project: both mesh (left) and terrain (right) has same material with same albedo value but Baked Albedo debug view shows no color on terrain.

So, when I try to bake scene in Built-in project it works fine with any material both on mesh objects and terrain.

But when I try to bake same scene in HDRP project terrain gets black albedo value and fails to generate bounced diffuse lighting. (Tried HDRP Lit, TerrainLIt, Unlit and even unsupported Built-In shader) Did I miss some HDRP settings related to terrain baking? It is a template project with default HDRP settings.

Shorter explanation of what I’ve discovered so far.

Good news!
I discovered temporary solution. Assign unsupported Nature/Terrain/Standard shader to terrain object. Bake. The terrain gets correct albedo color and provides indirect diffuse lighting as a result. Then return HDRP Terrain Lit shader.
I still believe something is broken. Terrain Lit shader should work with lightmapping.
I hope this info will help to identify the issue.

That definitely looks like a bug. I filed a bug report. Once our system refreshes, you should be able to see it here Unity Issue Tracker - [HDRP] Light doesn't bounce off terrains

1 Like