Defracture tool, a displacement map fixer.

I have been working lately on displacing geometry of a 3D model in real time, after it was tesselated.
Displacement maps means I modify the geometry vertices position according to a height map texture. The issue is that most game models don’t have enough geometry to support the fine details of the texture. You could send a lot of geometry to the shader, but this is wasteful. Instead, I subdivide the mesh inside the shader pipeline(tesselate).

I bought a nice 3D model of a stone golem that had normal maps but no displacement maps(height maps + normal maps). I decided to generate the height map using CrazyBump.
That worked pretty nice, but there was an issue. After displacement the model had gaps in certain parts of its surface.


The reason was that because the 3D model was stitched at certain places, like the shoulders and the head. Artists do that so they can unwrap the model’s surface into a 2D space which is required for mapping the texture.
The gaps appeared in those stitched areas because they had duplicate vertices in the same position but with different texture space coordinates.
CrazyBump only use the image and has no reference of the geometry, so it can’t tell there are different places in the texture that belong to the same 3D position in the model.

What I did to fix this is go over all the edges of the triangles that are shared in the 3D model, but are separate in the texture space. Then I just made the pixels in the height map on these edges share the same values for both edges. I had to make this edge fix more than 1 pixel width and it wasn’t a simple challenge.
This image shows where I fixed the displacement map. In practice I didn’t put black colors on the image, but rather an average of values on the two edges.

Denoting the edges

Here are the results:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s