-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Bevy version and features
Version: v0.16.1
Only default features
Relevant system information
Rust 1.86.0
macOS 15.6.1
Apple silicon M4 Max
What you did
Using view.world_from_clip * vertex_output.clip_space_position
to get a ray origin for some ray tracing in the fragment shader. The last row of view.world_from_clip
however is highly unstable in orthographic projections and requires to be patched roughly like so: view.world_from_clip[3].xyz = view.world_position;
What went wrong
I assume the multiplication of inverted matrices in the uniforms leads to this instability. More specifically it appears that view_from_clip
is at fault, not world_from_view
. Which is to be expected because the near / (near - far)
can produce a value far away from all others on the log scale, thus leading to floating point precision loss.
See the screenshots below for what they look like.
Additional information

