Graphics Reference
In-Depth Information
// Compute view space w
float w = dot ( ViewProj [3] , float4 ( In . Position ,1.0 f ));
// Compute what radius a pixel
l−wide wire would have
float pixel_radius = w ￿ PixelScale ;
// Clamp radius to pixel size .
float new_radius = max ( Radius , pixel_radius );
float3 position = In . Position + radius ￿ In . Normal ;
// Fade out with the reduction in radius versus original .
float fade = Radius / new_radius ;
Listing 6.1. Computing radius and fade factor.
Figure 6.1. Original wire. Note how the wire is aliased and full of holes despite 4 ×
MSAA being enabled.
will now appear fainter and fainter, maintaining the appearance of a thin wire,
as illustrated in Figure 6.3. Comparing Figure 6.3 to Figure 6.1, it can be seen
that the wires look identical, except for the fact that Figure 6.3 does not suffer
from aliasing artifacts.
6.2.3 Lighting
The technique as described so far works fairly well; we have eliminated the ge-
ometric aliasing, but unfortunately thin wires also tend to suffer from shading
aliasing as the lighting function gets sampled very sparsely and pseudo-randomly.
When the wire reaches pixel size, any texture sampling would likely go down to
the lowest mip-map and get uniformly colored by default; however, the normal
Search WWH ::




Custom Search