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

Will (does) Unity support Displacement Maps?

Discussion in 'Shaders' started by jokeane, Dec 4, 2008.

  1. jokeane

    jokeane

    Joined:
    Dec 4, 2008
    Posts:
    6
    Hello,

    I'm wondering if it is possible to create low-poly meshes which at run-time are displaced by a displacement map to create more detail in Unity.

    This is a pretty technical question, and is related to which pixel and vertex shader models are supported in Unity and how Unity handles 3D hardware features (or lack there-of).

    -Jim

    If you'd like some background on Displacement Mapping (with pictures):
    http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter07.html

    http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter08.html

    And a couple of nice tools for creating normal, displacement, and other maps:
    http://www.xnormal.net/1.aspx
    http://www.crazybump.com/
     
  2. jeffcraighead

    jeffcraighead

    Joined:
    Nov 15, 2006
    Posts:
    740
    Yes. Unity can use normal maps out of the box. I've also seen some other shaders that do parallex mapping.
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Displacement Maps don't work with low poly objects, then you likely mean parallax / normal / relief maps.

    displacement maps really deform the geometry so the geometry first must be in place to be transformed with detail. They thought are great for dynamic effects, but as Unity didn't get SM3 compilation support till Unity 2.1, not so many SM3 only effects have been offered (or at least I haven't seen many)
     
  4. jokeane

    jokeane

    Joined:
    Dec 4, 2008
    Posts:
    6
    I appreciate your attempts to answer the question, but:

    A) Normal maps and Displacement Maps are two different things. See references in original posts.

    B) The point of Displacement Maps is to dynamically display higher detail if the mesh is close to the viewer without needing a large static mesh in memory.

    What I'm interested in is specifically the techniques referenced in Graphics Gems 2 or as discussed by Hughes Hoppe from Microsoft Research (http://research.microsoft.com/~HOPPE/dss.pdf):

    1) Start with an original 'very high' resolution mesh.

    2) Creation of a lower resolution mesh based on the high resolution mesh and a displacement map.

    3) Real-time rendering using a combination of vertex and pixel shaders. This means doing dynamic subdivision surface creation where the newly created verts are perturbed by the displacement map.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Dynamic subdivision on SM2 / SM3 requires the geometry to be present on the model already so you need to create the geometry data on the fly within the engine / script before running the shader.

    Only SM4 / DX10 graphics hardware can create geometry on the fly (geometry shader) and this type of shaders is not supported in Unity, only up to Shader Model 3.
    SM4 support in OpenGL is lacking to inexistant on the ATI end, NVIDIA is quite a bit further there (also thanks to cG 2.0). DX9 does not support it at all, that would require Vista + DX10
     
  6. jokeane

    jokeane

    Joined:
    Dec 4, 2008
    Posts:
    6
    Thanks.

    I didn't understand the "SM" acronym in your previous post as "Shader Model",

    To sum it up, the answer is:

    "Unity does not currently support the required shader model."

    Can anyone from the Unity team comment on future directions shader support? OpenGL / DirectX 10, 11?

    Also apparently ATI cards can indeed do displacement mapping. ATI has another very nice tool (mesh mapper) for creating displacement, normal, and ambient occlusion maps.

    http://developer.amd.com/gpu/MeshMapper/Pages/default.aspx

    Nice backgrounders from ATI:

    http://ati.amd.com/developer/gdc/2008/Tatarchuk-Tessellation_GDC08.pdf

    http://developer.amd.com/gpu_assets...ower of Multi GPUs - Publisheable version.ppt
     
  7. Lovecraft

    Lovecraft

    Joined:
    Jun 17, 2011
    Posts:
    1
    I don't see why you cannot do what you are asking by dynamically adjusting your mesh along an interpolated curve or spline then using a shader model Unity supports to then deform it with a map.

    Just add the vertices you need for detail and remove them when they are no longer needed.

    Newer shader models do this kind of thing for you by my understanding but they do this because developers were doing it themselves before there existed shaders for it.

    This is essentially what ultra high polygon sculpting software is doing (think ZBrush and MudBox etc.)

    I would think you could coax the GPU to handle much of it as well.

    Look at some of the examples of real time procedurally generated terrains for ideas on how to go about this sort of thing in Unity.
     
  8. sadow (not shadow)

    sadow (not shadow)

    Joined:
    Mar 14, 2011
    Posts:
    45
    um, displacement mapping takes a height map and deforms a mesh by using the height information in the height map.
    it first subdivides a mesh to so that it store more vertices to be deformed, and then push/pull them along the normal based on the height map, the thing you were talking about with a higher resolution model is another form of tessellation, displacement is simple, just processor hungry.

    I'm also interested in whether it would be possible to create a shader, or script to do displacement mapping, as the math behind it is pretty simple.
     
  9. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    There is no way to subdivide a mesh in a shader. geometry shaders / tesselation is a DX10+ only feature, unity does only support up to Shader Model 3. The only form of displacement mapping available is really the one where you deform the existing mesh and that can be done.
     
  10. Chickenlord

    Chickenlord

    Joined:
    May 13, 2011
    Posts:
    381
    An alternative would be to use relief/parallax occlusion mapping (the algorithms are pretty simple, implemented it once). though these have some issues, like aliased edges and they are pretty expensive when used on lagre/ a lot of objects (due to the hight iteration count needed for smooth steps).
     
  11. killme

    killme

    Joined:
    Jul 25, 2011
    Posts:
    3
    I'm looking for a CG shader for parallax occlusion mapping (I'm trying to convert the DirectX sample one for Unity but without any success).
    Anyone succeed in it ?
     
  12. Mirzero

    Mirzero

    Joined:
    Jul 7, 2012
    Posts:
    9

    That's not a displacement map. What you're talking about is a Height map...

    See the following for information on Displacement Maps: http://nintendo-revolution.blogspot.ca/2005/12/is-displacement-mapping-last-secret.html

    Unfortunately I don't know if they're available in Unity, yet... but none of the people answering the question, anywhere I look, seem to be familiar with what a displacement map actually is.
     
  13. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    the article you link shows displayment mapping at the top, it deforms existing geometry.
    Thats possible in unity but you have to write it yourself.

    The bottom one that refers to zbrush is tesellation and requires Unity 4 + Windows Vista+ and DX11 compatible hardware.
    And again, it requires that you to write a shader for your specific use case and target hardware
     
    Last edited: Jul 9, 2012
  14. Mirzero

    Mirzero

    Joined:
    Jul 7, 2012
    Posts:
    9
    Hey, thanks for the response!
     
  15. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Unity 4 does support DirectX 11, which means you can use tessellation shaders with optional displacement. We do ship several simple ones in Tessellation Shaders package (but of course they require Windows 7+ and a DX11-capable GPU).
     
    eelstork likes this.