Graphics Reference
In-Depth Information
// Smoothly fade rays pointing towards the camera; screen space
// can ￿ t do mirrors (this is in view space) .
float fadeOnMirror
= dot ( viewReflect , viewDir );
// Smoothly fade rays that end up close to the screen edges .
float boundary = distance ( intersection . xy ,
float2 (0.5 f ,0.5 f )) ￿ 2.0 f ;
float fadeOnBorder =1.0 f
saturate (( boundary
FADE_START )/
( FADE_END
FADE_START ));
// Smoothly fade rays after a certain distance (not in
// world space for simplicity but shoudl be).
float travelled = distance ( intersection . xy , startPos . xy );
float fadeOnTravel
=1.0 f
saturate (( travelled
FADE_START )
/( FADE_END
FADE_START ));
// Fade the color now.
float3 finalColor = color ￿ ( fadeOnBorder
fadeOnTravel ￿
fadeOnMirror );
Listing 4.8. Artifact removal snippet for fading the rays that have a high chance of
failing and computing incorrect reflection results. FADE_START and FADE_END drive how
quickly the fading should happen, where they are between 0 and 1. Though the code
snippet shows the same parameters used for both the fading techniques, one should use
different parameters and tweak them accordingly.
store when the ray entered such a state and then, depending on the distance
traveled, fade the ray during that state to remove such unwanted artifacts.
4.6.2 Extrapolation of Surfaces
Since the ray-marching step might not find a true intersection, we could poten-
tially extrapolate the missing information. Assuming the screen is covered with
mostly rough surfaces with glossy reflections, we could run a bilateral dilation
filter, which basically means take the surface normal and depth into account
when extrapolating the missing color (i.e., flood-filling the holes). For any sur-
face other than rough surfaces, the dilation filter might fail horribly because of
potential high-frequency reflection colors.
One might be able to use a tile-based filter that finds good anchor points per
tile and then run a clone brush filter to extrapolate the missing information for
non-rough surfaces. The tile-based approach should work well for running the
dilation only on the needed pixels.
4.6.3 Improving Ray-Marching Precision
If we use a nonlinear, post-projected depth buffer, most of the depth values fall
very quickly into the range between 0.9 and 1.0, as we know. To improve the
precision of the ray marching, we can reverse the floating-point depth buffer.
Search WWH ::




Custom Search