Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Feature Request Costume editor to write to terrain Detail Maps?, cant find a texture

Discussion in 'World Building' started by NanushTol, May 14, 2023.

  1. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    138
    I'm creating a terrain graph editor to generate levels for my game, and I'm trying to efficiently access and set the detail terrain map, but it seams like there is no access to a texture like with the splat maps (alpha textures) or the height maps.
    I know of
    GetDetailLayer
    and
    SetDetailLayer
    but im looking for a sulotion similer to
    CopyActiveRenderTextureToTexture()
    or the
    DirtyHeightmapRegion()


    would really help as all of the operations in my editor are calculated on the GPU so to transfer data to the CPU and then do a for loop seams a bit in-efficient.

    Any suggetsions?

    upload_2023-5-14_22-53-13.png
     
    wyattt_ likes this.
  2. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Hi! First of all, just wanna say that graph editor is looking amazing and the output is super clean!

    But now I bring you bad news :(: there's not a texture representation for Terrain details that we manage and use for patch generation or rend. Even our Paint Details tool generates the details map on CPU.

    Given that you have details textures on GPU, you could look into AsyncGPUReadbackRequest of portions of the texture (ie sub-rects of the Terrain tile) over a couple frames. You'll want to associate them with an "edit" so you can throw out out-of-date details data when those callbacks complete. This way you mitigate time spent in a single frame for the readback though the visual feedback will be delayed a little
     
  3. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    138
    Thanks for the reply, and also for the compliment :)
    There are some heavy calculations in the erosion sim that take some time anyway so there is a short wait,
    I just wanted to make sure I didn't miss anything.

    From my experimentation I figures that the value in the stored detail maps is the actual count of detail per "texel",
    so if I put for example map[x,y] = 5
    the amount of details in texel x,y will be 5,
    is that correct?

    I also thought about processing this on a compute shader so it can read the texture without passing through the CPU and at the end just spit out a compute buffer with a dataset that matches the detail map
     
  4. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    I believe so. It is a value from 0 to TerrainData.maxDetailScatterPerRes

    Nice. This sounds like a decent idea
     
    NanushTol likes this.