Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Using TerrainPaintUtility in game works in preview but not build

Discussion in 'World Building' started by qgi, Jul 30, 2019.

  1. qgi

    qgi

    Joined:
    Feb 12, 2007
    Posts:
    8
    I'm experimenting with modifying terrain in-game with TerrainPaintUtility in the Experimental.TerrainAPI.

    Basically I'm calling TerrainPaintUtility.BeginPaintHeightmap, blit the modification into the paintContext's destinationRenderTexture and then call TerrainPaintUtility.EndPaintHeightmap.

    This works great in preview mode but doesn't work in an actual build.
    I've tried calling SyncHeightmap on the corresponding terrainData afterwards but that didn't do the trick.

    What additional steps are required to get this working in the game build, or are these methods only intended for use in the editor?

    Thanks!
     
  2. ChrisTchou

    ChrisTchou

    Unity Technologies

    Joined:
    Apr 26, 2017
    Posts:
    65
    I just tested it on 2018.4LTS, and it appears to work in a PC standalone build.
    What version of Unity / what platform are you using?

    Possibly there is a bug where it is not including the new height copy shader in recent 2019.3 builds (newly added to fix some other issues).

    In 2019.3, you can probably workaround it by grabbing the built-in shaders for your version of Unity here:
    https://unity3d.com/get-unity/download/archive

    And copying
    DefaultResourcesExtra\TerrainShaders\Utils\TerrainHeightBlitCopy.shader

    into a Resources\ directory in your project.
     
    wyatttt likes this.
  3. qgi

    qgi

    Joined:
    Feb 12, 2007
    Posts:
    8
    Chris, Thank you for your answer. I've been trying with 2019.1.11 and 2019.1.12 on macOS. In both versions it works in game preview but not in the standalone build. I've converted the project to 2019.3.0a10 but that didn't help either.
    The Builtin Shaders package for 2019.3.0a10 doesn't contain a TerrainHeightBlitCopy.shader (neither do the packages for 2019.1.11/12) so I couldn't try what you suggested.
    I've also tried with 2018.4.5f1. That doesn't seem to work either.