Skip to content

Conversation

superdump
Copy link
Contributor

Objective

Solution

  • At large translations (a few thousand units), the precision of calculating the ray direction from the fragment world position and camera world position seems to break down. Sampling the cubemap only needs the ray direction. As such we can use the view space fragment position, normalise it, rotate it to world space, and use that.

Changelog

  • Fixed: Jittery skybox at large translations.

@superdump superdump requested review from JMS55 and robtfm September 23, 2023 11:02
1.0,
1.0
);
let view_position = view_position_homogeneous.xyz / view_position_homogeneous.w;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view_position_homogeneous.w is constant 1.0 from above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, copy pasta.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no. This was wrong. The vec4 position is multiplied by the inverse projection matrix, so the resulting w is not guaranteed to be 1.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops right

@superdump superdump added this pull request to the merge queue Sep 23, 2023
Merged via the queue into bevyengine:main with commit 22dfa9e Sep 23, 2023
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- Fixes bevyengine#9707 

## Solution

- At large translations (a few thousand units), the precision of
calculating the ray direction from the fragment world position and
camera world position seems to break down. Sampling the cubemap only
needs the ray direction. As such we can use the view space fragment
position, normalise it, rotate it to world space, and use that.

---

## Changelog

- Fixed: Jittery skybox at large translations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bevy Skybox Jittering/Pixelating at Medium/Large Translations

3 participants