Game Development Reference
In-Depth Information
For displacement maps, we treat the borders and corners a little differently
than described in Section 2.2.1. First of all, we do not need an extra border for
filtering, as we use point sampling. However, adjacent faces must have identical
values along their shared border to avoid cracks when using hardware tessellation.
So instead of copying in a border from an adjacent face, we change the original
borders by averaging them as shown in Figure 2.3.
Corners of a face texture correspond to a vertex in the model. Similar to
how we handle borders, we walk the mesh around the vertex, gathering all corner
values and average them. This value is then written back to all corners that share
this vertex so that they are consistent and do not produce cracks. Note that it's
necessary that this value is exactly the same. If you recompute this average
for each quad, remember you are using floating-point math, and therefore must
accumulate in the same order for each quad.
Displacement mapping is done in object space in the domain shader. In our
implementation, we point sample from the highest resolution displacement map
regardless of tessellation level. Becausewearenotfiltering,the filter-related
issues of packed Ptex are not relevant, and there is both less compute and band-
width cost than for the typical texture map application in a pixel shader.
2.5
Performance Costs
To give a general idea of the cost difference between packed Ptex and conventional
texturing, we measured the difference between a packed-Ptex and a conventionally
textured version of the character shown in Figure 2.4(a) . The AO, specular,
albedo, normal and displacement maps are packed Ptex. GPU render time is
3.6 ms on an AMD Radeon HD 7970. If we change the AO, specular, albedo and
normal maps to conventional texture lookups (all but displacement) we find the
time goes down by an average of 0.6 ms.
The main cost is the search for maximum resolution in this implementation,
for which there are plenty of opportunities for optimization we have not yet ex-
plored. We could, for example, move the computation as far up as the hull
constant shader. There is also a cost due to reduced texture cache eciency, as
packed Ptex will generally not have as good locality of reference relative to con-
ventional texturing. The entire UV computation was repeated for each texture,
which should also not generally be necessary in practice.
Given the diculty in authoring a valid displacement map for a model like
the character in Figure 2.4(a) we measured packed Ptex displacement map-
ping against no displacement mapping at all. This model is made from 5,504
quads and tessellated up to 99,072 triangles. The cost of vector displacement
with packed Ptex on this model is 0.14 ms. This is with 16-bit floats for each
component, which is on the high end of what should normally be necessary in
practice.
 
Search Nedrilad ::




Custom Search