Displacement Nightmares

Hey folks. Currently building a project for a client which involves shapes and creatures pressing and moving against a membrane. I’ve tried using shrink wrap, cloth simulations and blend shapes to achieve the effect, but nothing seems to give me the same freedom of movement as rendering a depth pass sequence of the objects moving and using that to drive a displacement modifier.

image

Unfortunately, it’s still a bit rough. Objects extruding far out of the surface look stretched and glitchy with narrow triangles. Additionally, the mesh is using 64,800 triangles, which is about the maximum I can use in Unity Realtime per object.

Can anybody think of a prettier / more efficient way to achieve this effect?

Additionally, I’d like to be able to apply that animated displacement to a surface which has already been displaced with a cloud texture (creating an organic lumpy base surface).

It should look like the animation above applied to this…

…but instead it looks like this:

The problem is that the normals changed by the first displacement completely screw up the second displacement (I think).

Does anybody know how I can achieve the double displacement of my dreams? I think I need to find a way to redirect the surface normals after the first displacement, but I’m open to any suggestions from you wonderful people.

Source files here and here.

Try using adaptive subdivision with displacement. Switch on Cycles Experimental Features then start with a low poly mesh (you can do a single polygon if it’s flat, no need for lots of geometry to displace since it will be adaptively created at render time). Add a Subdivision Surface Modifier in Simple mode with Adaptive checked at the end of your modifier stack, and then just feed the displacement texture into your material’s Displacement output as you were probably doing before. Adjust the adaptive displacement to taste.

No need to provide extra geometry, no need for extra modifiers, double displacement, etc. I think.

Single polygon plane, adaptive subdiv, Vornoi->Displacement node height->Displacement material output. Not even smooth shading.

Thank you, @Zoot ! I’ll try this in the morning - as I’m heading to bed now. However, I wanted to check that you think this should work when exported to Unity Realtime (as mentioned in the original post). Ultimately, I’ll be using this technique for a VR project (baked out and imported as Alembic).

Either way, very excited to try out the adaptive subdivision! That looks fantastic! Thank you! =D

Just did a quick test and I think I’m a bit confused. I’ve moved the modifiers around into different orders, but I just seem to get a noisy mess, especially when animating. Any tips? =D

Sorry I missed the Unity bit, so adaptive subdiv probably won’t work for you unfortunately. Looks great in a Cycles render though!

Not sure what the best way of handling this is, but Displacement where you have to output a really heavy mesh seems like maybe there ought to be a better way. Could you just have the objects interpenetrate the “screen” in Unity and use shading there to make it look like it’s all the same surface?

If doing double displacement I’d just try adding the two effects in one material and just doing the displacement once if possible.

have you tried the warp modifier? It gives you much more flexibility and control

You can use an empty to control the texture, the direction, the rotation etc and all of them can be animated

Warp example .blend (833.4 KB)

2 Likes

Hey @Zoot ! Good advice!

Can’t seem to get that cycles render working as we discussed (see my own output above).

Not 100% sure how I’d have objects interpenetrate the membrane in Unity (though there is a cloth tool in there). Ideally, though, I’d like to bake out the heavy lifting before it gets into Unity so I can just play the animation.

However, yeah, I’d been thinking that maybe I could combine the two displacements into one texture. It’s a really good idea! Thank you for pushing me in this direction…!

@ARC9 - Holy cow, where has this modifier been all my life! This thing’s AMAZING! Encountering some errors, but this is a much nicer tool than the Displace modifier (although the From and To empties are a little weird). You’ve definitely solved my second problem!

1 Like

glad to help! the (from & to) empties are a bit confusing at first but if you imagine a line going through them it makes sense, like this



more info here https://docs.blender.org/manual/en/dev/modeling/modifiers/deform/warp.htm
i discovered this modifier by watching a 2 hour long video that explained every single modifier in blender
https://www.youtube.com/watch?v=z-SG_DcJF5I

1 Like

Yeah, eventually I figured out the purpose of the From/To empties - still find them a bit weird, though!

Thanks so much for the links! (Now I just need to work out how to use these modifiers at an affordable realtime rendering ‘price’…!

1 Like

Don’t know anything about Unity Realtime.

If Unity Realtime can do tesselation in the shader, then vertex shader displacement is the appropriate way to do this, not with Blender.

If it can’t, you should put some serious thought into whether an animated bump/normal map can do a better job. Going to depend on use.

I don’t know if it’s better, I don’t know if it’ll work for your purposes, but you didn’t mention dynamic mesh deforms, and you can use that to do that effect as well.

For your displace->displace, consider doing it on a flat mesh and displacing in global Z rather in normal, then using another modifier afterwards to turn it into a curve.

1 Like

@bandages

Pretty sure Unity can handle the tesselation in realtime - I just need to try and figure out how to achieve this in code… =( I figured that baking to Alembic would solve a lot of my problems, but it still seems unperformant, which is annoying. This could be my computer, however, so I need to test this on other systems.

I’m looking into normal maps atm, but while I think I might be able to make them work for the smaller objects, we probably need something with a little more dimensionality for VR.

Regards dynamic mesh deforms - not 100% certain what you’re saying here. Could you clarify this? (Apologies, it’s probably me!)

Regards the displace->displace, I think I’d tried that and ultimately couldn’t make it work properly either. @ARC9 's solution above, with the Warp modifier, was the solution there. Holy shit, it’s worth looking at that Warp modifier…!

Well, playing with it a bit, it’s probably not ideal here. But if you a mesh deform with a dynamic bind it will only deform the verts inside the cage of the bind target (well, ideally; in practice it’s a little error-prone) and you can use that to stretch meshes around objects.

dmd

But yeah, here, I’d say that the closer you can work to the vertex shader, the more performance you’re going to get. Working further up the pipeline than you need to is just going to add overhead. I’m not experienced with vertex shader tesselation+displacement (I’ve worked with DX9, before you could do that), but there’s no reason a modern video card shouldn’t be able to do this on the fly with a few hundred thousand verts. Depending on integration with other shader stuff. There should be some shader tutorials dealing with displacement; I remember Catlike Coding seemed to have some good tutorials.

Have you looked into Dynamic Paint? It might be a viable option.

Sorry folks, didn’t seem to get notifications so this reply is late.

All good advice, @bandages . Ultimately, my client went with an off-the-shelf raymarching solution for Unity, which renders a lot of this moot. =/ Nonetheless, thank you for your notes and thoughts on the topic…!

@Rhen - Yeah, I’ve given Dynamic Paint a good go, but wasn’t able to create anything significantly better than the Warp modifier on top of Displacement modifier. C’est la vie, thank you for your input and efforts here.