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

Amplify - Virtual Texturing for Unity Pro [Beta 1.2.1]

Discussion in 'Made With Unity' started by Diogo-Teixeira, Dec 6, 2010.

Thread Status:
Not open for further replies.
  1. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    That particular implementation uses a 2D texture in the vertex shader. Sadly, Unity doesn't currently allow texture access from the vertex shader. I don't know how much of the rest of the implementation depends on that step (too complicated for me to grasp with just a quick perusal).
     
  2. JanHelleman

    JanHelleman

    Joined:
    Oct 11, 2009
    Posts:
    116
    Everything depends on that, and i did not know unity did not allow that. Sounds a little weird that it doesn't, is this a unity restriction or CG restriction?
     
  3. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    Unity I believe, one of the graphics gurus around here should probably chime in though. It's also possible that the restriction has been lifted at some point, but I haven't heard anything about it being available, and it's kind of a big deal so I would think someone would have mentioned if you could now do it.
     
  4. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Did anybody make feature request for this?
     
  5. JanHelleman

    JanHelleman

    Joined:
    Oct 11, 2009
    Posts:
    116
    if so i will vote for it :)
     
  6. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
  7. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    jan, I'm familiar with the concept and I really wasn't thinking about the geometry itself. Now that you mention it, it'd be really nice to get a displacement channel on the VT. You can use Amplify for terrains without problems. I was referring to the big textures themselves. Is there a standardized format for big ass textures?

    Regarding vertex texture fetch, it is already available in Unity3 \o/
    http://feedback.unity3d.com/forums/...raphics-vertex-shader-texture-fetch?ref=title

    demo, that one would be handy. Tricky to support though.
     
  8. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
  9. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    I'm considering using it to help batching.
     
  10. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    That would be perfect feature, it would save us (anybody) lots of work, it would make really combo from you system.
     
  11. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Agreed. I'll dedicate some time to batching right after compression.
     
    Last edited: Apr 8, 2011
  12. JanHelleman

    JanHelleman

    Joined:
    Oct 11, 2009
    Posts:
    116
    well good ideas cost ya nothing today ;)
     
  13. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Actually I just realized it won't help me, I'll still need to send extra info per-vertex. And that is still a problem.

    I'll keep looking for other options though, don't give up on me. :)
     
  14. JanHelleman

    JanHelleman

    Joined:
    Oct 11, 2009
    Posts:
    116
    What kind of information?
     
  15. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Offset and size of the texture within VT bounds. I'm passing it per-material at the moment. I can't just modify the UVs because of tiling.
     
  16. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    So make some feature request on unity and we can support it. I already supported all your requests :)
     
  17. JanHelleman

    JanHelleman

    Joined:
    Oct 11, 2009
    Posts:
    116
    But do these parameters change per vertex or per mapped texture?
     
  18. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
  19. JanHelleman

    JanHelleman

    Joined:
    Oct 11, 2009
    Posts:
    116
    But a terrain mega texture is essentially one big texture, and the vertex texture mapped solution batches tiles of vertices into space. So you could still pass per vertex batch offsets, but I don't want to be in your way, since I have no access to code and thus have no clue of what I am talking about :)
     
  20. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Right now, this plugin works by packing textures together in one big texture, so no unique mapping yet. For each texture packed I need per-texture/material offset info. I need to get that info into the pixel shader. Right now I'm doing it per-material.

    I could bake that info in the mesh itself, however, getting my offsets into the vertices without breaking any other Unity features is next to impossible. I could probably use vertex color but I'm sure a lot of people use it for other purposes.
     
  21. onedong

    onedong

    Joined:
    Aug 27, 2009
    Posts:
    32
    Hey guys I have a couple texures that are 8k and 12k. Is this plugin something I should look into so that Unity can see my texture higher than 4096? I am essentially baking a building into one texture and i need it really high resolution so I get alot of detail.
     
  22. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    onedong, yes indeed. I've tested up to 16K x 16K without major problems, other than slow Unity import.
     
    Last edited: Apr 12, 2011
  23. Owen

    Owen

    Joined:
    Apr 20, 2011
    Posts:
    79
    It sounds like you are building one giant texture atlas on disk. Would it be possible to put each virtual texture tile into its own image file? That way once you support web builds we could use this system for on-demand streaming over the internet. That could be the holy grail for us web game developers.
     
  24. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    And the point of a mega texture system that does not use a mega texture is what again?
    I fail to see why you even want to use it if you want distinct files cause I don't see any possibility to have any gain then anymore, cause you can't start before you have the whole megat texture around anyway, so streaming isn't in the range of options (unless you talk of megatexture per level)
     
    Last edited: Apr 21, 2011
  25. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    If you desperately did want separate textures per level, then you may want to keep another separate one that holds all of the objects in all of the game levels. This may let you reuse this texture.
     
  26. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Owen, VT tile counts can go from tens of thousand all the way up to a few million. Dealing with that many files is just not practical.
     
  27. chasmash

    chasmash

    Joined:
    Jul 16, 2010
    Posts:
    3
    Would the following work?

    I create a 32k x 32k rgba texture....this texture is then mapped across several static mesh terrian objects. Imagine the static mesh objects together form the game world. I would have one set of mesh objects that were low res and one set that were high res (poly count wise).

    For a given scene, I would combine many of the low res pieces with a few of the high res pieces that were near the player. But the texture would be the same texture for all pieces.

    I have tried to read the thread and determine if this would work but I have ended up quite unsure. Also, in the event this can work, what would the on disk size of the 32kx32k texture be?

    Thanks in advance. This looks very promising.
     
  28. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    There's no problem whatsoever in reusing the same texture on completely different models. Amplify only cares about UVs.

    The size of a 32k x 32k texture in the current version, which is uncompressed, should be around 8 GB. The next major update will feature VT compression which, depending on the quality settings, could shrink that to roughly 3 GB (lossless) or all the way down to around 250MB (low quality).

    BTW, you don't necessarily have to use a giant texture. There are tools available right now that allow you to paint across different materials/textures; e.g. bodypaint, 3d coat, mudbox to name a few. That way you end up with a lot of smaller textures instead of one big one. Could also work for terrains.
     
  29. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    How about overcoming 4GB fat32 limit? Any ideas how to split VT?Going over 4GB is no problem with few 32k textures...
     
  30. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Demostenes, should be safe to go up to 128K x 64K without having to worry about it. However, I've already added that task to the update backlog.
     
  31. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Thanks. I was making some math and if we keep resolution of all textures (we are using lots of 4k textures and with this technology I would like to go even higher in some cases), we probably go over 128k x 64k, because we are building seamless world, so everything is one scene (with dynamic load/unload). We already have cca 2000 0,5-4k textures. We are definitelly planning to use this technology, because it will save us lots of work with memory budget.

    Btw, how are normal maps stored? They are in same "layer" as diffuse, or in separate layer? I mean if I have VT 16k x 16k, and 256 1k textures, can I put only 128 diffuse and 128 normal maps? Or I can have 256 diffuse and 256 normal maps?
     
    Last edited: Apr 22, 2011
  32. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    You might still be able to stay below 4GB, depending on the compression settings. Rest assured, though, this is one of the priority issues for the first revision.

    They are stored in separate channels so you get the same number of everything. That's valid even if you use different texture sizes for diffuse and normal; the smallest will be stretched to match the largest, resulting in wasted detail.

    Looking forward to find out more about your game. :)
     
  33. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Thanks, this is good to know.

    I am looking forward to some presenting, but now is too soon :)
     
  34. xadhoom

    xadhoom

    Joined:
    Sep 2, 2010
    Posts:
    91
    Hi,

    Still eager to use this tool in our projects :)

    One issue I observe with the latest version:
    I have a plane 1x4 units with a VT applied (16kx4k). When I move the camera very closely to the plane (to see the texture details) it happens that the texture is not loaded completely within the camera frustum. When moving the camera left and right it happens that new appearing parts in the view stay blurred. Looks like an issue determining which parts of the VT are visible.

    xad
     
  35. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    I've also noticed that problem recently. I'll be looking into it real soon.
     
  36. tommybear

    tommybear

    Joined:
    May 3, 2009
    Posts:
    33
    Hi Diogo,

    Awesome stuff. Running on mac here and having real trouble importing a 16k x 16k png. What am I missing? I get:

    Texture import error [Assets/a.png]: Texture import error: Assets/a.png
    UnityEditor.DockArea:OnGUI()

    Does it need to import via Unity? Can you create a wizard to get the texture into the VT instead? Or do you need it as reference. Thanks!

    Tommy.
     
  37. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Indeed, that seems to be a Unity error. I've been able to successfully import 16K x 16K PNG (24bit) and TGA (32bit) on Windows 7 x64.

    Unfortunately, at the moment the image has to be recognized and imported by Unity first. I'm still looking for good solutions to bypass Unity's importer. Since we're getting close to a release, I've pushed this issue to the backlog for post-release updates.
     
  38. IndieDude360

    IndieDude360

    Joined:
    Oct 29, 2010
    Posts:
    105
    Wow, does this mean that we can use High resolution textures on certain objects? like a doors or objects you want players to admire?
     
  39. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    It means you can use high res textures everywhere. :)
     
  40. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    Considering your help request for votes, I posted my 3 votes on both of your feedback forum threads:

    Texture2D.SetPixels for compressed textures
    Incremental, additive BuildAssetBundle

    I`m not a programmer and I honestly don`t know the importance of your requests, but I voted because your texturing plugin is really great.
    Hope many others will do the same and you`ll get the support you need from the Unity Team. :)
    Many Thanks.
     
  41. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Thank you, Mark. Your support is highly appreciated. :)

    If SetPixels is fixed it will reduce the time it takes to upload textures from system to video memory. That means faster streaming. Hardware nowadays can do GB/s and we are kinda stuck at around 40MB/s in Unity.

    Fixing BuildAssetBundle would help make Amplify work on web builds without having to resort to streaming from an external location.
     
  42. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Texture2D will likely never get SetPixels for compressed textures as its not available on mobiles for example and on desktop its a very time consuming thing as you need to decompress it, set the pixel, recompress it.

    But the second one definitely gets my support, being hit by "loaded already" just cause the bundle that was meant to be unloaded didn't feel to do it in time, without a way to handle that at all, is extremely painfull and annoying.
     
  43. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    The idea here, which is not just for compressed textures, is to be able to send texture information in it's native format, precisely to avoid any kind of conversion or compression in the background. GetPixels() should also work this way, for the same reasons. Texture formats and platform endianess would have to be more explicit. If these calls were async, then it would be golden.

    Of course, all this could be made optional/overloaded for "advanced" use.

    BTW, why exactly isn't available on mobiles? SetPixels, compressed textures?

    edit--

    I understand that may be seem a bit against Unity's philosophy of abstraction and simplicity but this kind of stuff would really help the community expand Unity's capabilities to new heights. I honestly don't think that they are mutually exclusive but I guess that's up for discussion.
     
    Last edited: May 9, 2011
  44. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Any progress?
     
  45. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    You've beat me to the punch.

    Beta 2 will be out in a few hours. You may expect massive improvements. :)
    More on that later today.
     
  46. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
  47. Diogo-Teixeira

    Diogo-Teixeira

    Joined:
    Apr 9, 2010
    Posts:
    494
    Major (and last) beta version uploaded: Beta 2

    Download

    No need to register this time, just grab the latest revision in the frontpage.

    New Major Features

    - Variable bit rate lossy texture compression. Per-channel adjustable quality.
    - Maximum virtual texture size increased to 65536 x 65536. (beta only)

    Improvements
    • Improved overall stability. Both editor and runtime.
    • Improved Preload times by loading only necessary tiles on startup.
    • Massive performance and memory footprint improvement. However, still limited texture uploads.
    • Reduced overall memory fragmentation.
    • Reduced GC spikes.
    • Got rid of clearing the VT before a rebuild.
    Critical Bugs Killed
    • Blurred/missed tiles even when close to the camera.
    • Fatal error in GC: too many root sets.
    • Occasional hangs in the editor.
    • Triggered occasional rebuilds for no reason.
    Release is Nigh

    Amplify is mostly ready for release. We just need to tie a few knots here and there. Combined with all the other preparations, that should take us a couple of weeks. At the moment we're also setting up the logistics, we've just finished registering a company to help us bring this and other products to market.

    This version took a bit longer than expected but we are now working exclusively on this project until it's out.

    What's Next?

    These will certainly be made available via free post-release incremental updates:
    • Further reduction of GC spikes.
    • Virtualization support for dynamically instantiated surfaces/prefabs.
    • Parallel/multi-threaded builds.
    • Optionally split virtual textures into 4GB chunks to fit fat32 restrictions.
    • Improvements to texture compression.
    • Anisotropic filtering.
    • More optimizations.
    The following are under review:
    • Automated batching.
    • Massive texture support. (beyond 16K x 16K)
    • Terrain support.
    • Web streaming.
    • Network builds.
     
    Last edited: May 27, 2011
  48. jamexist

    jamexist

    Joined:
    Mar 2, 2010
    Posts:
    11
    Cool Diogo, we're waiting for the release...

    Terrain support will be the most interesting and useful feature, hope you make it soon ;)
     
    Last edited: May 18, 2011
  49. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    While I don't have any constructive feedback, I just wanted to say again: Wow, very good stuff! I have my fingers crossed for terrain support, hope it works out.

    Good luck!
     
  50. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Hi there. I'm going to test it now, I've been quite busy till now but now I've prepared some test stuff. I'm about to test a 64000x non 64000 value (if it does not work I'll try to make ix 64kx64k) ortofoto. I've converted it to jpg and has a weight of 995mb.

    Lets see what happens.
     
Thread Status:
Not open for further replies.