Use of Displacement Maps in Physically Based Rendering Polydata

EDIT: found a partial solution, working on it now.

So I’ve been working on adding support for physically-based rendering into some of my work and have had reasonable success using the new functions present in VTK 9.0, following the Python PBR example found here.

I’m completely satisfied with how PBR handles flat textures however I’m struggling to find a cogent example for the handling of displacement textures within VTK.

Displacement textures modify Polydata by extruding along the normals of a surface to produce a new profile, I’ve attached screenshots of a displacement map being used with the vtkFitToHeightMapFilter() class which gives beautiful results when combined with a tuned SSAO pass.

vtkFitToHeightMapFilter() seems like it’s more suited for the generation of topographic maps as the z-position of the Polydata appears to get overridden and the deformation only occurs in the z-direction. When using a 3D surface (such as vtkParametricBoy) as the input connection this filter will effectively flatten the data along z and then apply the displacement map which makes all of the surfaces co-planar.

I was wondering if there was a filter that deforms Polydata along the normals of the Polydata surface that can use a texture as an input and uses the same transform that is used to map the other PBR textures. Presumably there would have to be some sort of probe filter to do the sampling too.

Here I’ve applied the height map as the albedo texture, what I’d like is for the Polydata to deform so that the darker regions move inwards and the lighter regions outwards along their respective surface normals.

After some research it appears that vtkWarpScalar and vtkProbeFilter is what I was looking for, I’ve got a rudimentary function working that still needs a little tweaking. Currently I convert the image into a scalar array for the displacement to the polydata needs to be a certain size to work. Hopefully I can figure out how the ProbeFilter works to remedy this. The color should be pretty easy to fix, it looks a tad grotesque at the moment.

1 Like

That looks great! Glad to see PBR and SSAO being used.
Ideally, the displacement map should be supported directly in the shader but this is not supported yet in VTK.

1 Like

I guess from a conceptual point of view it makes sense to keep displacement mapping separate from other texture-based rendering techniques due to the physical changes imposed on the mesh. There are still a couple hoops I need to get through for the mapping to work on all my data (figuring out how the textures map, probing the mesh locations) but I think that’s more a testament to how comparatively easy it is for a novice programmer like me to add PBR and SSAO using VTK into my work to be honest.

It’s really nice to see that the more advanced features of VTK and ParaView are explained using in-depth tutorials on how they function by people like you. I imagine it’s difficult to cover the usage case for everyone but this forum seems to do a good job at providing help for the things that get missed.

Hi there,

I am working on a project where I need to do the exact same thing to what you did here - deform a Polydata along the surface normals based on a displacement map image. As such, I’m trying to reproduce the renderings you created above.

Could you explain a bit more about how you used vtkWarpScalar and vtkProbeFilter to produce the working or doughnut images and / or provide a code snippet you used to generate those renderings?

Currently, I am able to apply the height map as the albedo texture, but am unable to deform the Polydata successfully.

Thanks in advance!