Screen Space Reflections - ApertureViewer/Aperture-Viewer GitHub Wiki
Technical Deep Dive: Screen Space Reflections (SSR) Settings
1. Introduction
Screen Space Reflections (SSR) is a rendering technique used to simulate real-time reflections, primarily on glossy or mirror-like surfaces. It operates by ray marching within screen space, utilizing the depth buffer and the rendered scene color buffer of the current frame. This allows SSR to capture reflections of dynamic objects and scene elements potentially missed by static reflection probes. However, its reliance solely on screen-visible information introduces inherent limitations: objects outside the camera's view or occluded by foreground elements cannot be reflected, often leading to artifacts like reflections disappearing at screen edges or being abruptly cut off. The settings detailed below control the quality, performance, and behavior of the SSR implementation.
2. Individual Setting Analysis
RenderScreenSpaceReflections
2.1. - Setting Type: Boolean
- Default Value: 0 (False)
- Function: The master switch for the SSR feature. Enabling (1) activates the SSR calculation passes and shader features; disabling (0) bypasses them entirely.
- Impact: Fundamental visual impact (enables/disables the effect). Significant performance impact, as enabling SSR introduces computationally intensive ray marching and additional rendering passes.
- Recommendation: Enable for potentially higher visual fidelity with dynamic reflections, disable for maximum performance.
RenderScreenSpaceReflectionIterations
2.2. - Setting Type: S32 (Signed 32-bit Integer)
- Default Value: 25
- Function: Dictates the maximum number of steps the ray marching algorithm performs per pixel while searching for a reflection hit in the depth buffer. It limits the search distance and computational work per ray.
- Impact: High performance impact (more iterations = more GPU work). Directly affects reflection completeness; lower values may cause reflections (especially distant ones) to be missing or cut short, while higher values allow rays to find hits further away but cost more performance. Interacts strongly with
RayStep
. - Recommendation: Requires tuning in conjunction with
RayStep
. Increase if reflections appear incomplete or cut off, decrease if performance impact is too high. Default (25) is a baseline compromise. High-end quality might require values of 50-100+, depending onRayStep
.
RenderScreenSpaceReflectionRayStep
2.3. - Setting Type: F32 (Float)
- Default Value: 0.1
- Function: Defines the initial size/magnitude of each step taken along the reflection ray during the marching process.
- Impact: Moderate direct performance impact, but High visual impact on reflection quality and artifacting.
- Smaller values: Produce finer steps, leading to smoother, less noisy reflections and better capturing of detail. However, they require more
Iterations
to cover the same distance. - Larger values: Cover distance faster (potentially fewer iterations needed), but significantly increase noise, dithering, banding artifacts, and the chance of stepping completely over thin objects, especially noticeable in foreground reflections as demonstrated during testing.
- Smaller values: Produce finer steps, leading to smoother, less noisy reflections and better capturing of detail. However, they require more
- Recommendation: Critical tuning parameter. Requires balancing with
Iterations
. Start near the default (0.1) or slightly lower (e.g., 0.05-0.08) for better quality, adjustingIterations
upwards as needed to maintain reflection distance. Avoid excessively large values (like 2.0 tested previously) which demonstrably degrade quality significantly.
RenderScreenSpaceReflectionDistanceBias
2.4. - Setting Type: F32 (Float)
- Default Value: 0.015
- Function: A tolerance threshold comparing the ray's current depth to the sampled scene depth. If the difference is less than this bias, a hit is registered. Influences how strictly the algorithm matches the ray position to the depth buffer.
- Impact: Low performance impact. Primarily affects subtle visual artifacts. Smaller values require tighter matches (can cause missed hits if stepping is coarse), larger values are more lenient (can cause reflections to appear slightly detached or "leaky").
- Recommendation: Testing indicates that deviating significantly from the default value (0.015) offers limited benefit. It serves mainly for fine-tuning minor artifacts if observed after tuning
RayStep
andIterations
. The default is generally appropriate.
RenderScreenSpaceReflectionDepthRejectBias
2.5. - Setting Type: F32 (Float)
- Default Value: 0.001
- Function: A threshold used to potentially skip SSR calculations entirely if the reflecting surface itself is extremely close to the camera (depth < bias). Acts as a minimal near-clip for starting the SSR process.
- Impact: Negligible performance impact in most scenarios. Only prevents calculations on surfaces practically intersecting the near plane.
- Recommendation: Testing indicates the default value (0.001) is appropriate. Changing it typically provides no noticeable advantage or disadvantage. Leave at default.
RenderScreenSpaceReflectionAdaptiveStepMultiplier
2.6. - Setting Type: F32 (Float)
- Default Value: 1.6
- Function: Multiplies the ray step size in each iteration (if exponential stepping is enabled in the shader, which it appears to be), allowing steps to become larger as the ray travels further.
- Impact: Low to Moderate performance impact by influencing how quickly distance is covered. Moderate visual impact, mainly on distant reflections and potential banding. Values > 1 speed up traversal but can increase banding/stepping artifacts. Values near 1 maintain more consistent step sizes.
- Recommendation: Testing suggests the default (1.6) provides a reasonable balance. While tunable, significant deviations often have downsides (visual artifacts or performance/completeness issues) that are better addressed by tuning
RayStep
andIterations
. Stick with the default unless specific banding issues are observed that aren't resolved byRayStep
adjustments.
RenderScreenSpaceReflectionGlossySamples
2.7. - Setting Type: S32 (Signed 32-bit Integer)
- Default Value: 4
- Function: Controls the maximum number of jittered ray samples traced per pixel to simulate blurriness on glossy (non-mirror) reflections, approximating surface roughness. Results are averaged.
- Impact: Potentially Very High performance impact, as it multiplies the core ray tracing work for glossy pixels by the sample count. Visually affects the quality (smoothness vs. noise) of reflections on rougher surfaces.
- Recommendation: Use with caution due to performance cost. Testing indicates that for many static or mirror-like surfaces, the visual improvement from increasing samples above 1 can be subtle or negligible relative to the performance impact. Its value appears most pronounced on surfaces with fine, dynamic detail or complex normals, such as rippled water. In such cases, multiple samples (e.g., default 4 or higher) can average out noise and better interact with the surface detail, potentially leading to clearer or more realistic blurred reflections compared to a single noisy sample trace. For general performance,
1
sample may be sufficient, using the default4
or higher only when targeting specific improvements on detailed/dynamic surfaces like water, and accepting the associated performance cost.
3. Interdependencies
RenderScreenSpaceReflections
enables/disables all others.Iterations
andRayStep
are critically linked. SmallerRayStep
(for quality) usually requires higherIterations
(for completeness), increasing cost.GlossySamples
adds a costly quality layer dependent on the base ray march; its benefit is context-dependent.DistanceBias
,DepthRejectBias
, andAdaptiveStepMultiplier
are secondary tuning parameters, with defaults generally being effective based on testing.
4. Testing Procedures (Revised Focus)
4.1. General Setup: (As before: ALM on, Shadows on, Water Reflections on (if testing water), FPS counter, Debug Settings floater). Also note relevant Water Shader Settings (e.g., Blur Multiplier
, Normal Map
, Wavelet Scale
) as these can significantly interact with SSR's appearance on water.
4.2. User Testing Procedures:
- Baseline: Start with SSR Off, note visuals and FPS. Enable SSR (
RenderScreenSpaceReflections = 1
) with all other SSR settings at their defaults. Observe initial impact and performance cost. - Tune Core Quality (
RayStep
/Iterations
):- Focus on
RayStep
. Reduce it from default (e.g., 0.1 -> 0.08 -> 0.05) and observe reduction in noise/dithering, especially in foreground. - As
RayStep
is reduced, observe if reflections (especially distant ones) start getting cut off. - If reflections are cut off, increase
Iterations
(e.g., 25 -> 50 -> 75 -> 100+) until completeness is restored to an acceptable level. - Find the balance between acceptable foreground smoothness (
RayStep
), desired reflection distance (Iterations
), and performance (FPS).
- Focus on
- Evaluate
GlossySamples
:- Use the tuned
RayStep
/Iterations
values. - Test on a flat, glossy (but not mirror) surface. Compare
Glossy Samples
= 1 vs. 4 vs. 8. Note visual difference (noise vs. smooth blur) and FPS impact. Is the improvement worth the cost? - Test specifically on rippled water (ensure non-zero wave settings or a normal map). Compare
Glossy Samples
= 1 vs. 4 vs. 8. Does the reflection appear clearer, less noisy, or more integrated with the ripples at higher sample counts here compared to the flat surface? Note FPS.
- Use the tuned
- Verify Secondary Parameters: Briefly check if changing
DistanceBias
,DepthRejectBias
, orAdaptiveStepMultiplier
significantly from default improves any specific artifact (leaking, banding) not resolved by tuningRayStep
/Iterations
. Revert to default if no clear benefit is observed. - Check Water Shader Interactions: Explicitly test changing water settings like
Blur Multiplier
(set to 0.0 vs. default vs. positive values) to see how they affect the SSR appearance on water.
4.3. Developer Testing Procedures: (Methodology remains the same - profiling, uniform checks, logic trace)
- Focus Profiling: Quantify the performance cost per
Iteration
step and perGlossy Sample
. Measure frame time changes when tuningRayStep
. Profile SSR passes vs. water shader passes to isolate costs. - Verify Defaults: Confirm the default values for
DistanceBias
,DepthRejectBias
,AdaptiveStepMultiplier
are generally performant and visually stable across various scenes. - Grazing Angle Analysis: Use a graphics debugger to visualize ray paths and hit points for foreground water reflections vs. distant ones to confirm the instability/inaccuracy at shallow angles.
5. Overall Conclusions & Recommendations (Revised)
- SSR provides dynamic reflections at a performance cost, with inherent screen-space limitations (edges, occlusion, grazing angles).
- Achieving desired quality requires careful co-tuning of
RayStep
andIterations
. Prioritize smallerRayStep
for smoothness, increasingIterations
for completeness, balancing against performance. - The benefit of
SSR Glossy Samples
above 1 appears context-dependent, being most valuable for improving realism on detailed/dynamic surfaces like rippled water, but potentially offering diminishing returns at high performance cost on simpler surfaces. Start low (1 or 4). - Testing suggests the default values for
DistanceBias
,DepthRejectBias
, andAdaptiveStepMultiplier
are generally robust and require adjustment only in specific artifact-chasing scenarios. - Be mindful of SSR's inherent limitations (especially grazing angles causing foreground degradation) and interactions with material/water shader parameters (e.g., water blur settings).