A while ago I adapted a displacement example from diatom on the forum for PBR, now I saw some requests about this subject so here it is. It reads the heightmap texture from the PBR material and displaces the vertices accordingly along the normals sampled from the normalmap texture in the PBR material.
Note: Vertex displacement only gives a good result if your geometry is already very high poly, as you’ll see on the sphere in my network.
This example needs TD 099, Substance PBR material is included.
I just did a quick test and it seems to work fine with Environment light.
The Environment Light Comp is Image Based Lighting - this means it needs an image to do anything. Have you applied a TOP to the environment map parameter of the Environment Light?
Yes. I have. I’ve been using the example as a part of a larger project that uses .Exr animations for lighting scenes.
For some reason it worked with the previous version but not this one. They’re may be other issues in my network. I certainly couldn’t see any changes in the shader that would account for it. I must have busted up some other part while trying to swap in the new shaders.
Just trying to figure out why the vertices are displaced in one direction instead of being parallel to the surface of the sphere.
In fact if you put a grid in place of the sphere the displacement goes “diagonal” inseat of straight up to the y-axe like a regular vertex displacement.
I’ve tried to tweak a bit the vertex shader, in partcular the following line (37)
vec3 newP = P + (N+noSample.rgb) * dsSample.rgb * uDisplace.x;
vec3 newP = P + (N*noSample.rgb) * dsSample.rgb * uDisplace.x;
Rather than a translation operation:
vec3 newP = P + (N+noSample.rgb) * dsSample.rgb * uDisplace.x;
That still ends up a little egg shaped when pushed all the way to the displace max, you might also try looking at what happens if you just use the height map:
vec3 newP = P + (N*dsSample.rgb)* uDisplace.x;
You’ll also end up with different results if you add a texture SOP inline inside of the geo - this lets you change how uvs are assigned on the object - which will in turn change how you’re sampling from the displacement textures.