Back home 🏡 WGSL Spec Bevy WGSL Functions

raymarch.wgsl

Import path

Bindings

Name Group Binding index Binding type Type
depth_linear_sampler # 1 2 sampler
depth_nearest_sampler # 1 3 sampler

Structures

HybridRootFinder

#
Name Type
linear_steps u32
bisection_steps u32
use_secant bool
linear_march_exponent f32
jitter f32
min_t f32
max_t f32

DistanceWithPenetration

#
Name Type
distance f32
valid bool
penetration f32

DepthRaymarchDistanceFn

#
Name Type
depth_tex_size vec2<f32>
march_behind_surfaces bool
depth_thickness f32
use_sloppy_march bool

DepthRayMarchResult

#
Name Type
hit bool
hit_t f32
hit_uv vec2<f32>
hit_penetration f32
hit_penetration_frac f32

DepthRayMarch

#
Name Type
linear_steps u32
linear_march_exponent f32
bisection_steps u32
use_secant bool
jitter f32
ray_start_cs vec3<f32>
ray_end_cs vec3<f32>
march_behind_surfaces bool
use_sloppy_march bool
depth_thickness_linear_z f32
depth_tex_size vec2<f32>

Functions

hybrid_root_finder_new_with_linear_steps

#
fn hybrid_root_finder_new_with_linear_steps(v: u32) -> HybridRootFinder
Parameter Type
v u32
Returns: HybridRootFinder

hybrid_root_finder_find_root

#
fn hybrid_root_finder_find_root(root_finder: ptr<function, HybridRootFinder>, start: vec3<f32>, end: vec3<f32>, distance_fn: ptr<function, DepthRaymarchDistanceFn>, hit_t: ptr<function, f32>, miss_t: ptr<function, f32>, hit_d: ptr<function, DistanceWithPenetration>) -> bool
Parameter Type
root_finder ptr<function, HybridRootFinder>
start vec3<f32>
end vec3<f32>
distance_fn ptr<function, DepthRaymarchDistanceFn>
hit_t ptr<function, f32>
miss_t ptr<function, f32>
hit_d ptr<function, DistanceWithPenetration>
Returns: bool

depth_raymarch_distance_fn_evaluate

#
fn depth_raymarch_distance_fn_evaluate(distance_fn: ptr<function, DepthRaymarchDistanceFn>, ray_point_cs: vec3<f32>) -> DistanceWithPenetration
Parameter Type
distance_fn ptr<function, DepthRaymarchDistanceFn>
ray_point_cs vec3<f32>
Returns: DistanceWithPenetration

depth_ray_march_new_from_depth

#
fn depth_ray_march_new_from_depth(depth_tex_size: vec2<f32>) -> DepthRayMarch
Parameter Type
depth_tex_size vec2<f32>
Returns: DepthRayMarch

depth_ray_march_to_cs_dir_impl

#
fn depth_ray_march_to_cs_dir_impl(raymarch: ptr<function, DepthRayMarch>, dir_cs: vec4<f32>, infinite: bool)
Parameter Type
raymarch ptr<function, DepthRayMarch>
dir_cs vec4<f32>
infinite bool

depth_ray_march_from_cs

#
March from a clip-space position (w = 1)
fn depth_ray_march_from_cs(raymarch: ptr<function, DepthRayMarch>, v: vec3<f32>)
Parameter Type
raymarch ptr<function, DepthRayMarch>
v vec3<f32>

depth_ray_march_to_cs

#
March to a clip-space position (w = 1) Must be called after from_cs, as it will clip the world-space ray to the view frustum.
fn depth_ray_march_to_cs(raymarch: ptr<function, DepthRayMarch>, end_cs: vec3<f32>)
Parameter Type
raymarch ptr<function, DepthRayMarch>
end_cs vec3<f32>

depth_ray_march_to_cs_dir

#
March towards a clip-space direction. Infinite (ray is extended to cover the whole view frustum). Must be called after from_cs, as it will clip the world-space ray to the view frustum.
fn depth_ray_march_to_cs_dir(raymarch: ptr<function, DepthRayMarch>, dir: vec4<f32>)
Parameter Type
raymarch ptr<function, DepthRayMarch>
dir vec4<f32>

depth_ray_march_to_ws

#
March to a world-space position. Must be called after from_cs, as it will clip the world-space ray to the view frustum.
fn depth_ray_march_to_ws(raymarch: ptr<function, DepthRayMarch>, end: vec3<f32>)
Parameter Type
raymarch ptr<function, DepthRayMarch>
end vec3<f32>

depth_ray_march_to_ws_dir

#
March towards a world-space direction. Infinite (ray is extended to cover the whole view frustum). Must be called after from_cs, as it will clip the world-space ray to the view frustum.
fn depth_ray_march_to_ws_dir(raymarch: ptr<function, DepthRayMarch>, dir: vec3<f32>)
Parameter Type
raymarch ptr<function, DepthRayMarch>
dir vec3<f32>

depth_ray_march_march

#
Perform the ray march.
fn depth_ray_march_march(raymarch: ptr<function, DepthRayMarch>) -> DepthRayMarchResult
Parameter Type
raymarch ptr<function, DepthRayMarch>
Returns: DepthRayMarchResult