Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support infinite far planes #547

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emilk
Copy link

@emilk emilk commented Mar 26, 2022

Infinite far planes is a standard trick that actually improves the precision of the Z buffer.

See for instance https://thxforthefish.com/posts/reverse_z/ and https://developer.nvidia.com/content/depth-precision-visualized

Infinite far planes is a standard trick that actually improves the precision of the Z buffer.
See for instance https://thxforthefish.com/posts/reverse_z/
@@ -220,12 +230,20 @@ impl<S: BaseFloat> From<Perspective<S>> for Matrix4<S> {

let c2r0 = (persp.right + persp.left) / (persp.right - persp.left);
let c2r1 = (persp.top + persp.bottom) / (persp.top - persp.bottom);
let c2r2 = -(persp.far + persp.near) / (persp.far - persp.near);
let c2r2 = if persp.far.is_finite() {
(persp.far + persp.near) / (persp.near - persp.far)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be negative?

let c2r3 = -S::one();

let c3r0 = S::zero();
let c3r1 = S::zero();
let c3r2 = -(two * persp.far * persp.near) / (persp.far - persp.near);
let c3r2 = if persp.far.is_finite() {
(two * persp.far * persp.near) / (persp.near - persp.far)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be negative?

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.

2 participants