Search Unity

Terrain hole and lightmapping

Discussion in 'World Building' started by WEST069, Mar 8, 2021.

  1. WEST069

    WEST069

    Joined:
    Aug 17, 2017
    Posts:
    2
    Hi!
    I'm trying to make a house with a basement. Unity version 2020.2.2f1. I created a terrain with a hole for the basement level. I used the built-in unity tools.
    1.png

    House and terrain marked as Static.
    2.png

    Also i used some emissive material and baked spot lights as indoor lighting. When i try to bake the light i get some artifacts.
    3.png

    Terrain still affects on indoor lighting, although basement terrain's area is a hole. Also i got green reflections on the ceiling due to the terrain grass material.
    When i uncheck Contribute Global Illumination parameter of the terrain, i get the result i wanted.
    4.png

    But I don't want to turn it off, because the outdoor lighting will not be correct.
    What i should to do to fix this?

    P.S. Sorry for my english, I did my best)
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Have you tried making the basement roof double-sided, perhaps a little thick, and underground?

    Like this:

    basement.png
     
  3. WEST069

    WEST069

    Joined:
    Aug 17, 2017
    Posts:
    2
    I thought about it, but it's not quite what I need.
    I solved the problem in a different way. First, I lifted up the terrain and house on some value. I used Set Height instrument of the terrain. Then I made a deepening for the basement. Like this:
    1.png
    You don't even need to draw holes. Just a deepening. This solved all light baking problems.
    Now the sea level will be different from 0, but it is not a problem. Unity cannot work with negative terrain heights, so we had to lift it up to make a deepening.
     
    tomobiki and mariandev like this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Thank you for taking the time to followup!!

    There's actually a solution for this too: numerically lift the ENTIRE terrain heightmap up some amount, then physically move the terrain object down... I do this automatically at runtime in my terrain deformer, so that even a flat terrain (all heights at 0.0f) can be dented downwards. I don't save the results but you obviously would.

    Relevant code (download the whole package to see it functioning):

    https://bitbucket.org/kurtdekker/ma...nStuff/TerrainDamager/TerrainPreAdjustment.cs

    It's pretty trivial to just onetime lift the terrain, then lower it's placement, but be sure you're using source control in case something goes wrong and you need to revert the terrain!
     
    WEST069 likes this.
  5. tomobiki

    tomobiki

    Joined:
    Sep 27, 2020
    Posts:
    65
    Hi, I had a problem very similar to yours; I posted yesterday on Unity forum the problem here: https://forum.unity.com/threads/help-about-lighting-through-hole-in-terrain.1171610/
    And this morrning I thought to do exactly what you wrote in your post: create a deepening in the terrain instead than an hole: I don't think it's a solution, but just a workaround: however it can solv the problem.
    I hope that Unity will solve the issue of lightmapping through holes, that I consider a bug.
     
  6. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,758
    You have to understand that the Unity system for creating holes in the terrain, is different from actually digging a hole by means of terrain tools (raise/lower terrain), which is essentially, altering the height map in a different way.

    So each way will act differently, so test both, choose what works best...
     
    tomobiki likes this.