Search Unity

Unity 4 tessellation and how it works?

Discussion in 'Editor & General Support' started by DigitalAdam, Jun 18, 2012.

  1. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,211
    That's great that unity 4 will now support tessellation. Does anyone have any good resources or information as to how to go about modeling to support that? It subdivides the mesh, but does it use some sort of mapping to get details?

    Thanks!
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you can check out NVIDIAs tech documentation, demos and code on the matter, they have a plentora. I think ati has a few too
     
  3. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Unity 4 will support DirectX 11. DX11 can support GPU tessellation, if your computer can do it (i.e. you have Windows Vista or later, and have a DX11-capable GPU).

    Now, whether DX11 GPU tessellation is a terribly useful feature or not is still debatable. Personaly as a graphics programmer, I'm much more excited about compute shaders, structured buffers, UAVs and other DX11 goodies; and also using tessellation shaders (hull domain shaders) for non-tessellation purposes.
     
  4. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,211
    Aras - Maybe you can give me an overview as to how it's done in Unity. Does it tessellate using a normal or displacement map?
     
  5. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    At this moment it does not ;)

    As in, when you use DX11, you can write your own hull domain shaders, just like right now you can write your own vertex pixel shaders. What do you do in your hull domain shaders is completely up to you. Some popular practical choices possible: PN-Triangles, PN-Quads, Phong Tessellation; all those with or without a displacement map(s). It's just shader code that decides how to dice up the polygons and then how to move the resulting vertices around.

    We'll see whether we'll find a good sane way of adding some sort of "built-in tessellation" for 4.0 release, but I can't promise anything. Most of it comes down to that there's no single tessellation method that is totally better than all the other methods that are possible.
     
  6. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,211
    You should include some examples or have some integrated shaders, especially for us "artist" types. :)
     
  7. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    What do you mean? Detail tessellation with displacement map is 100 times better than tessallation by default without any maps used. Detail tessellation can make great visual results on rocky surfaces or buildings and is defenetly whorth it, while subdivision without maps can be usefull or not, but in most cases it is not worth performance impact. No need to implement detail tessellation for characters like Crytek did, in my opinion total waste of performance. Characters are already constructed of many polygons and normal map pretty much cover a lot, there is almost to none difference with tessellation. You can even check how Metreo 2033 used tessellation which is complete waste of performance, but hey using detail tessellation on really flat surfaces (1-100 polys) with lots of relief is huge visual gain.
     
  8. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Oh, I do know that. What I'm saying, there's a hundred ways of how exactly "detail tessellation" can be implemented. Before displacement, do you subdivide flat polygons? Or N-Patches? Or Phong tessellation? Then how about subdivision LOD (there's a dozen+ ways of how exactly that could be done)? And then actual displacement, do you use heightfield or vector displacement? Are the displacement maps 8 or 16 bit? How do you adjust the tangent basis after displacement?

    And so on.

    If we do "well you can do anything yourself!" approach, we put all those decisions up to you, the game maker. Advantages: you can do anything that you want; depending on your content pipeline, game that you're making, etc. etc. Disadvantages: you have to actually write the tessellation (hull domain shaders) yourself.

    If, on the other hand, we'd do "it's flat tessellation, using this-n-that subdivision LOD, and scalar displacement, and this way of adjusting the tangent frame, and this is what you get" - advantage of that to you is that "it works without me doing anything". Disadvantage: you might want one of the other 99 ways of doing detail tessellation instead ;)
     
  9. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    I am wondering how does tessallation (in Unity) handle sharp edges. Are those completly being smoothed out? For example if there is cube, is it subdividing it the same as for example 3ds max Turbosmooth or Zbrush subdivision or are faces being smoothed out really close to their edges? And is subdivision procedure handled by developer or player on objects that have it (how many times is it done)?
     
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    have examples of at least 2 different techniques for it please. your users will love you more.


    Personally speaking I like the idea of tessellation for "strange" fx which includes hair but also for other tricks :)
     
  11. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Like I said above: right now there's no "tessellation handled in Unity". You can write your own tessellation shaders. What you do there, and how you deal with creases - completely up to you.

    That said, I think many people hear about "DX11 tessellation" and they imagine displacement mapped catmull-clark subdivision surfaces. DX11 GPU tessellation is not that; in fact it's really really hard to implement catmull-clark in DX11 shaders.
     
  12. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Oh ok then we are going to wait for miracle and hopefully someone will make those shaders avalible on Asset store.
     
  13. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi,
    Would it be possible to have some links to example hull and domain shaders ?
    MSDN does not seem so helpful.
    I also try to find a way to create and test hull and domain shaders ( in a non - unity context for now ), any links would be much appreciated.
    Thanks in advance,
    -Ippokratis.
     
  14. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Haha yes, documentation for DX11 is a complete joke. I thought our docs were lacking, but man, our docs are awesome compared to DX11 docs ;)

    I think nvidia amd should have some tessellation shader examples on their websites. Also, DirectX SDK has some examples, some of them include tessellation.
     
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unity:

    are UDK and cryengine providing out of the box tesselation shaders to use? if so then you don't want to be the ginger haired stepchild of game development do you? :D
     
  16. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Yes they do:D
     
  17. xCyborg

    xCyborg

    Joined:
    Oct 4, 2010
    Posts:
    633
    Please Aras, I don't care if you do built-in tessellation shaders or not, it's not really your job. But for StarTrek's sake write us some DOCUMENTATION on Hull Domain shaders (any new syntax, built-in functions, managing the pipeline etc) for us to do the rest.
    I loved you so much for Surface shaders Aras so don't disappoint us;) BTW can we write a hybrid of a vertex/geometry/pixel/tessellation shader in one nice surface shader? would be catastrophically awesome.
     
  18. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    I'll try.

    But it's really just the same Hull Domain HLSL shaders that you'd write in any other DX11 application, so all the documentation from Microsoft, NVIDIA, AMD and Intel applies.
     
  19. thesaint1987

    thesaint1987

    Joined:
    Jul 13, 2011
    Posts:
    168
    No... Please Aras, write us some sample shaders so that we can see how to map this NVIDIA and Microsoft documentation to Unity. That is far more important, and don't waste time on repeating the information...

    For me the most interesting cases are Terrain tessellation based on height/displacement maps. And detail tessellation for meshes.
     
  20. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Example Tessellation shaders:

    1. fastest 3d package style mesh smooth without smoothing groups and threshold (artists used to doubling edges for creases)
    2. the above but edges handled by smoothing groups
    3. detail (parallax shader) alternatives with detail derived from normal map or conversion of normal map into height map (or just a heightmap).

    That would do out of the box although I suspect you can skip step 2. Artists are all used to subdivision surfaces / mesh smoothing a low poly cage in modelling packages so if they can do the same workflow in unity, that would just be fantastic, yes. Let the artists dictate the way forward here. After all, they will be the ones trying to make it look right.

    Look at how modelling packages smooth and subdivide, it's a good start. But getting that going fast is the challenge, no doubt
     
    Last edited: Jul 4, 2012
  21. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    This pretty much can not be done with DX11 tessellation shaders. See, that's why everyone's reaction to them is along the lines of "Sounds great! Wait... how do I do mesh smoothing or catmull-clark?! What do you mean not possible?! FFFFUUUUU".

    DX11 tessellation shaders can turn faces into more faces, and then move the resulting vertices around based on very local topology knowledge. E.g. they can move them based on a displacement map. Doing any mesh smoothing requires quite a lot of topology knowledge (i.e. knowledge of surrounding faces), and also often requires multiple iterations (something that DX11 tessellation shaders also can't do).

    See above. "DX11 tessellation" is not the smoothing and subdivision you're used to in modelling packages.
     
  22. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    I have to say, Terrain tesselation would be absolutely brilliant! :D As would normal detail map tesselation, but man my mind is exploding with possibilities in regards to terrain...
     
  23. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thanks Aras... well, a detail "parallax mapping replacement" and normal map replacement would be my best bet for it rather than any dramatic change to topology.
     
  24. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Exactly.

    While tesselation may not be *needed* for dynamic objects, like characters and monsters, for obvious reasons, the feature would be a HUGE time saver and quality increaser for environments.
    NO WAY at the moment to make decent stone walls, just to give a first easy example.
    Another vantage: no need to model the stones that much: just give the main hull and then... texture.

    I understand there is the hard choice "Unity team or user team" but I think that saving a lot of work by doing it integrated would be much better.
    At least, you could integrate some shaders for static objects, that would do the trick for 90% of the use of tesselation.
     
  25. bpears

    bpears

    Joined:
    Aug 23, 2012
    Posts:
    249
    Is there a benefit over LOD with tesselation, if you have the ability to just open up your modeling software and add geometry/subtract geometry the same way? I don't see why you wouldn't just do that, unless tessellation is better on performance. There are a plethora of ways to upscale/downscale geometry in modeling software whether you want it smoothed or not.
     
  26. reefwirrax

    reefwirrax

    Joined:
    Sep 20, 2013
    Posts:
    137
    I figure that by now you have seen some amazing tessellation demos? It seems like it can provide millions of free detail polygons, and increase detail massively and do all kinds of special effects, so all in all tessellation is amazing, even averts the necessity for "LOD mesh" etc.
    for a nice example of a special effects based on tessellation, run on the aliens and triangles demonstration: www.youtube.com/watch?v=1c_PVtMIz-A‎
    and the endless city thing with the skyscrapers in it.
     
  27. Tomas-smith

    Tomas-smith

    Joined:
    Nov 8, 2013
    Posts:
    9