Screen Space Tracing
ScreenSpace::Trace provides functionality for tracing rays in screen space to compute effects like Dynamic Reflections or any kind of ray in world space. It leverages hierarchical ray marching for efficient performance.
ScreenSpace::Trace provides functionality for tracing rays in screen space to compute effects like Dynamic Reflections or any kind of ray in world space. It leverages hierarchical ray marching for efficient performance.
API Reference
static TraceResult Trace(
const float3 Position, // The world-space origin point of the trace.
const float3 Direction, // The world-space direction vector of the ray.
const float2 vPositionSs, // Screen-space position corresponding to the origin.
uint nMaxSteps = 64, // Maximum steps for ray marching (default is 64).
);
Theย TraceResultย structure represents the outcome of a trace operation:
- HitClipSpaceย The hit position in clip space coordinates. With UV and Z Depth.
- Confidenceย The confidence level of the hit detection.
- ValidHitย Indicates whether a valid hit was found.
Usage Example
Texture2D FrameBufferCopy = /* .. */
Material m = /* .. */
float3 origin = /* world-space origin */;
float3 direction = /* world-space direction */;
float2 screenPos = /* screen-space position */;
TraceResult result = ScreenSpace::Trace(origin, direction, screenPos);
if (result.ValidHit)
{
float3 vReflectionColor = FrameBufferCopy[ trace.HitClipSpace.xy ].rgb;
m.Emission = lerp( m.Emission, vReflectionColor, result.Confidence );
}
Referenced API
Canonical API pages mentioned in this guide.
A struct describing an origin and direction
Trace for tools, not to be confused with `Sandbox.SceneTrace`
No summary available.
No summary available.
A material. Uses several `Sandbox.Texture`s and a `Sandbox.Material.Shader` with specific settings for more interesting visual effects.
Result of a collision between two objects.
Access screen dimension etc.
Point that defines part of the spline. Two consecutive points define a segment of the spline. The `Sandbox.Spline.Point.Position`, `Sandbox.Spline.Point.In`/`Sandbox.Spline.Point.Out` Handles and / properties are used to define the shape of the spline. P1 (Position) P1 (In) โผ P1 (Out) oโโโโโโโโโXโโโโโโโโโo โโโ/ \โโโ โโ/ \โโ -/ \- / \ | | P0 X X P2