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

Reverse-Z state problem #29578

Closed
eXponenta opened this issue Oct 7, 2024 · 4 comments · Fixed by #29579
Closed

Reverse-Z state problem #29578

eXponenta opened this issue Oct 7, 2024 · 4 comments · Fixed by #29579
Milestone

Comments

@eXponenta
Copy link
Contributor

eXponenta commented Oct 7, 2024

Description

Reverse Z PR not fully correctly implement reverse-Z.

Problem in state:

ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );

This flag applied in capabilities that persistent after initialisation, that is wrong due to context sharing.

ThreeJS state can be flushed for some specific cases like a 1 contex for N-renderers or libs.
For ex: Three + PIXI, Three + WebXR emulator, Three+potree.

WebGLState has reset for that:

function reset() {

Because clipControl is context-related three also should reset this state and change it when needed back

@CodyJasonBennett can you apply some changes and move call of clipControl into WebGLLState instead of WebGLCapabilities?

@Mugen87 what you think about that?

Reproduction steps

Code

Live example

Screenshots

No response

Version

r169

Device

No response

Browser

No response

OS

No response

@eXponenta
Copy link
Contributor Author

eXponenta commented Oct 7, 2024

Also we have state problem with clearDepth:

Reverse Z upgrade depth inside renderer:

_gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );

BUT Three has state for that:

gl.clearDepth( depth );

ReversedZ will broke state upgrade, because clear value will always 0 or 1.

@CodyJasonBennett
Copy link
Contributor

This flag applied in capabilities that persistent after initialisation, that is wrong due to context sharing.

ThreeJS state can be flushed for some specific cases like a 1 contex for N-renderers or libs.
For ex: Three + PIXI, Three + WebXR emulator, Three+potree.

How could this happen? Do they have a different WebGL implementation than the browser or are still using WebGL 1?

Because clipControl is context-related three also should reset this state and change it when needed back

I can agree with this and your changes in #29579. I would much prefer if renderer.capabilities had some hint as to what the context supports. Not sure anyone is using that though since this feature is so new.

@eXponenta
Copy link
Contributor Author

eXponenta commented Oct 8, 2024

How could this happen? Do they have a different WebGL implementation than the browser or are still using WebGL 1?

Simple case:
Potree is outdated library that use parts of threejs with manual state switch, it not know about reverse-Z at all.
For potree to important use valid depth info because it use postprocess for resolve dom lighting.

https://github.com/potree/potree/blob/develop/src/materials/shaders/edl.fs#L38

But in general a reverseZ must have for BIMs ( cad system ), because BIMs have billions of near placed polygons on non-normalized space( about 10000x10000 metres with step in 10sm ). Without reverseZ we to tired use hacks that reducing z-fights.

@mrdoob
Copy link
Owner

mrdoob commented Oct 9, 2024

/fyi @m-schuetz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants