Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question URP, WebGL, Terrain Tools, Terrain Layers -> Invisible terrain

Discussion in 'Web' started by umbrella-crash, Oct 9, 2022.

  1. umbrella-crash


    Mar 3, 2022
    When building for WebGL, I'm getting invisible terrain. It seems to involve very specific combinations of how the terrain is created and what kinds of maps are in the terrain layers.
    By trial and error, I've begun to find some combinations that work, but I really don't understand why some work and others don't, although I've read a lot of the documents.
    I'd really appreciate some insight. There must be some principles I'm not understanding, even if I am running into a bug. There are no error messages in the console. ("Build completed with a result of 'Succeeded'...")

    Here are some examples where the terrain displays and where it is invisible. In all the cases, the terrain displays when played in the editor or with a Windows build. The problem seems specific to a combination of URP, WebGL and (maybe) Terrain Tools.

    For these examples, I used:
    Unity 2021.3.11f1
    A fresh project with 3D URP Core template
    package Terrain Tools 4.0.3 (from Unity Technologies)
    package Terrain Sample Asset Pack 2.0.1 (from Unity Technologies)
    Settings: WebGL 2 only. Compression format "Disabled"

    1. This works as expected:
    Create a Terrain in a scene with the menu in the hierarchy.
    Add a terrain layer and select one of the layers from the Terrain Sample Asset Pack
    Switch build platform to WebGL (to make this work, Project Settings > Player > Publishing Settings > Compression Format must be set to "Disabled"!! That's a whole other can of frustration.)
    Build and Run
    Now I see the scene with its textured terrain.

    2. This results in invisible terrain:
    Use the Terrain Toolbox to create a terrain.
    Do all the other steps exactly the same as before.
    Build and Run
    Now I see the scene with invisible terrain (non-terrain objects are visible and terrain physics objects still stop falling, so the terrain is there)

    3. This seems to work:
    Use the Terrain Toolbox to create a terrain.
    Add a terrain layer from Terrain Sample Asset Pack
    Select the layer and expand "Layer Properties" and for Mask Map choose "None"
    OR leave the Mask Map and set Normal Map to "None".
    Build and Run
    Terrain is visible.

    4. This makes invisible terrain:
    Do the same as #3, but with two layers, one with a Mask Map and one without.
    All the terrain is invisible, even though part of it is textured with a terrain layer that worked fine in #3

    5. Getting rid of TerrainGroup makes not apparent difference
    I tried to see if there were differences between the terrain created by Terrain Tools and the ones made without it. There must be a difference, but I can't figure out what it is. Terrain Toolbox does put the terrain in a Terrain Group. But if I move the terrain out of the Terrain Group and delete the group, it makes no change in any experiment I've run.

    One approach might have been: Avoid "Terrain Tools" when using URP and WebGL. Unfortunately, I didn't discover this problem until having done a lot of work on the terrain, so recreating it would be a lot of work. Even so, I could do it, but given the mysteriousness of this, I'm afraid I'll run into another problem and have to start over again. Narrowing this down so specifically was a lot of trial and error. I need to understand more of what is going on. Otherwise, the tools seem very easy to break.

    Thanks for any help, suggestions, or insight!
    YagirX, WonkeeKim and javenu like this.
  2. YagirX


    Jan 16, 2016