Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Virtual Texture?

Discussion in 'World Building' started by Reanimate_L, Dec 7, 2018.

  1. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    So with the all the terrain update, is there a plan to add virtual texture into built in terrain?
     
  2. Deleted User

    Deleted User

    Guest

    virtual textures?? please elaborate ...graphene? and another company have paged textures...or...as soon as I invent quantum image interpolation...unlimited image size entangled with your local textures...1k locally, 1tb entangled... virtually..:)
     
    Last edited by a moderator: Dec 11, 2018
    Mikael-H likes this.
  3. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Yeah something like granite, but for terrain it should be more specific feature. Ie bake all the the texture layer into one layer just like base map texture with albedo, normal, and mask. so the virtual texture only sample one layer baked texture. this could improve performance rather that the terrain have to sampling all the texture layer all the time.
     
  4. If they were putting something like that in the engine (virtual texturing) it would be silly to restrict it on the terrain. Although it would be awesome having something like that built in, but I wouldn't count on it.
     
  5. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    True, but the reason why i'm wondering about this specifically for terrain is to optimize the texture layer.
    The more layer count we have, the terrain getting more expensive to render. since Terrain using add pass for each 4 layer. Having all of those layer baked into one just like basemap would improve the performance a lot, but we will need a very high texture resolution for that. And that's where virtual texture would come to help handling all of those texture tiles.
    Also having the layers baked into one layer would improve the performance when we need to do terrain mesh blending.
     
  6. ChrisTchou

    ChrisTchou

    Unity Technologies

    Joined:
    Apr 26, 2017
    Posts:
    74
    Yes, there is a virtual texture clip-map cache in the works.
    The idea is to cache the material layer blending and greatly improve pixel shader perf (especially for high material counts), as long as you can afford to allocate the cache texture memory. It's much simpler than generic virtual texturing and streaming solutions like Graphine, but exactly what we want to speed up terrain rendering.
     
  7. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    That awesome, we really need a way to improve terrain layer rendering performance. When you are talking about the cache texture memory as in RAM or VRAM?
     
  8. It's very good to be wrong sometimes. :D
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Actual virtual texturing is absurd and well out of the reach of most AAA studios let alone indies, and for terrain it's borderline suicidal - I guess people haven't really thought about how much storage space that really is if they ask for it ;)

    But virtual-procedural texturing is really useful and sees much use from big and small devs alike so I'm cautiously optimistic about this (which is a variant of PVT):

    Thumbs up! I was thinking though.... why only terrain? Why not meshes too? Please consider this or at least let us know why not.
     
  10. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419


    Was looking at that.

    Not too familiar with this -- What kind of memory/disk-space are we looking at with a scene like in that video, @ChrisTchou?
     
  11. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Ah -- that's what I was missing.

    I knew the virtual texturing technique was pretty ancient (relatively-speaking) and required loads of disk space, but doing that in screen-space somehow might actually be viable enough to work.


    Seconded. :)
     
  12. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Oh, i do understand the storage space that we have to pay. but again at least we can choose between performance and final build size.

    VPT would be the best for both world i think, also there's a repo on github someone creating a VPT for unity terrrain just FYI


    Baby step man...baby step. Maybe after terrain, who knows :)

    for that specific demo, from the demo link
    • 32k Sample Data (1.07GB)
    • 16k Sample Data (323MB)
    • 8k Sample Data (91.5MB)
     
    awesomedata and hippocoder like this.
  13. ChrisTchou

    ChrisTchou

    Unity Technologies

    Joined:
    Apr 26, 2017
    Posts:
    74
    It is a run-time cache only -- it doesn't affect what you have saved on disk.
    The cache basically consists of several large render textures, chopped up into tiles, plus an index map that says where to put each tile.

    The idea is you render / blend your terrain materials into the cache, in an amortized fashion to keep cost low (for example, update one tile per frame). Your per-frame per-pixel terrain rendering can then simply read out of the cache -- which is much cheaper / much less bandwidth than blending all of the materials for every pixel.

    So it's effectively trading memory for perf by caching the material blend result.

    The index map is organized as a clip-map (per camera), so it's very much designed for caching data on a large contiguous plane (i.e. most Terrains), as the maximum tile resolution it can reference is limited by the distance to the camera. A clip-map also keeps the index map small and easy to manage, unlike generic virtual textures, that can have extremely large index maps.

    The cache itself is designed to be pretty general purpose -- it doesn't decide which tiles to populate, or what to render to them; it just provides the texture setup, index map organization and tile allocation book keeping. We are working on a default implementation that uses distance and view culling heuristics to calculate the best tiles to populate, and renders the standard terrain materials into the cache. But, you could modify it to read back from the GPU to determine which tiles to populate, and read the tile data off disk instead of rendering it, and basically get terrain-only mega-texture.
     
    hippocoder and awesomedata like this.
  14. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    It sound like Virtual Procedural Texture?
     
  15. ChrisTchou

    ChrisTchou

    Unity Technologies

    Joined:
    Apr 26, 2017
    Posts:
    74
    I'm not aware of that term, but if it fits the definition, then sure! :)

    It's not 100% procedural, as you still can paint the splatmaps, but it's also not storing every cache pixel out to disk, so it is procedurally generating it to some extent.
     
  16. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    well almost. :D.
    Btw i'm curious since i'm not familiar with VT ClipMap cache. The Large render texture inside the cache, is it the the combined texture of all layers?
     
  17. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    You guys rock.

    General purpose is good. :)
     
  18. ChrisTchou

    ChrisTchou

    Unity Technologies

    Joined:
    Apr 26, 2017
    Posts:
    74
    Yes. It would look a lot like the basemap / pre-baked LOD texture (but in a virtual texture).
     
    Reanimate_L likes this.
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Nice, would be great if we have access to sample the virtual texture for terrain mesh blending.
    Thanks for answering @ChrisTchou
    Edit : Oh while you guys are on it. any plan to add support for decals/terrain decals that going to be baked into VT?
     
    Last edited: Dec 18, 2018
  20. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    @ChrisTchou - Be nice if it's kinda possible to mess with a wetness level or such even though it's cached else we'd probably see some kind of pop going on as tiles are refreshed. I think though could just use graph. I'm guessing 8 splats become a simple lit HDRP shader (for example) - equivalent of one splat. It's this shader we need to mess with in the graph, the end result one... for wet (or maybe other people want snow, whatever).

    Or maybe I'm overthinking it. I'm not looking for much more than a smoothness tweak. when it rains.