Will (does) Unity support Displacement Maps?

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.crazybump.com/

Yes. Unity can use normal maps out of the box. I’ve also seen some other shaders that do parallex mapping.

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)

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 (Microsoft Research – Emerging Technology, Computer, and Software Research):

  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.

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

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.

Nice backgrounders from ATI:

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

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.

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.

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.

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).

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 ?

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.

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

Hey, thanks for the response!

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).

1 Like