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

WebGLState: Fix setting of NeverDepth. #24628

Merged
merged 1 commit into from
Sep 13, 2022
Merged

Conversation

mrxz
Copy link
Contributor

@mrxz mrxz commented Sep 12, 2022

Description

While trying different options of depthFunc I noticed that setting it to NeverDepth didn't yield the expected result. Instead of it always failing depth testing and not rendering anything, it rendered "as normal". Looking into the code reveals that there's an if statement, presumably checking if the passed depthFunc value is "valid". However, the NeverDepth constant has the value 0 and thus fails this check. As such NeverDepth ends up being the same as the default LessEqualDepth.

This PR simply removes that if statement and associated else clause, as the else clauses matches the default case in the switch statement. This allows NeverDepth to be properly set and, unless I'm missing something obvious, behaves the same otherwise.

(Note: the diff makes it look like a lot has changed, but only the if statement and corresponding else clause have been removed, and the indentation level of the switch reduced by one)

This contribution is funded by Fern Solutions

@Mugen87 Mugen87 added this to the r145 milestone Sep 12, 2022
Copy link
Collaborator

@gkjohnson gkjohnson left a comment

Choose a reason for hiding this comment

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

For an extra easy diff turn off whitespace changes:

https://github.com/mrdoob/three.js/pull/24628/files?w=1

@Mugen87 Mugen87 merged commit 50f1db1 into mrdoob:dev Sep 13, 2022
@Mugen87 Mugen87 changed the title Fix logic in DepthBuffer's setFunc which prevented NeverDepth from being set WebGLState: Fix setting of NeverDepth. Sep 13, 2022
@mrdoob
Copy link
Owner

mrdoob commented Sep 13, 2022

Thanks!

abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
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.

4 participants