-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
WebGL2 Occlusion Queries feature #15450
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
Conversation
| * @author simon paris / https://github.com/simon-paris | ||
| */ | ||
|
|
||
| function OcclusionQueryMesh() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you introduce a new object type, it's necessary to adjust ObjectLoader and Object3D.toJSON() so it's possible to serialize/deserialize a scene with objects of type OcclusionQueryMesh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since OcclusionQueryMesh has a callback function property, and also needs to be disposed properly, would it be acceptable to leave serialization unsupported and just print a warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Um, I see what you mean. Let me think about this...
|
Have you considered to choose a different API style similar to BabylonJS? Objects have a property isOccluded which indicates whether the mesh is occluded or not. If you assign a specific value to occlusiontype, an occlusion query is configured for the respective object. You can now evaluate |
|
I personally tend to prefer such an API since it feels easier to use. I'm curious how others think about this 😇 |
|
Can I instead output the result by pushing it to an array? If I output the result as a single boolean, you wouldn't get a result for each frame. A guarantee to get one output for each frame rendered would be useful for some people. A single boolean also wouldn't work with multi-camera setups. For the serialization problem, I could always deserialize it into a disabled state? Then programs that aren't aware of the occlusion query don't have to worry about leaks or disposal. |
I like to keep things simple. I would prefer an API that is easy to use and covers 90% of use cases. Better than a more complex one which also regards edge cases. A single boolean value for 3d objects should be sufficient for most scenarios even for VR applications. But like I said before, this is just my opinion. Let's see how others think about the API style. |
|
Any update on this? This would be a great feature for Three.js. |
|
Do you mind resolving the |
03ca771 to
d96891d
Compare
|
Sorry! I've been busy at work. I've resolved the conflict. |
|
Hi! I come from the future where #26335 has been merged. It'd be great to have occlusion queries for WebGL as well since WebGPU isn't widely supported yet. I haven't looked at how either PR is implemented yet, but I'm sure this PR could use some polishing to get it up to the same standard as the WebGPU version. We're willing to allocate some development time to this project if anyone's interested. @mrdoob @Mugen87 |
|
"WebGPURenderer" is a confusing name for the universal renderer that works for both WebGPU and WebGL2. You can try replacing WebGLRenderer in your project with it. |
|
Occlusion queries have been implemented in Since we want to focus on the development of |
Example: https://raw.githack.com/simon-paris/three.js/occlusion-queries-with-build/examples/webgl_occlusionqueries.html
Documentation: https://raw.githack.com/simon-paris/three.js/occlusion-queries-with-build/docs/api/en/objects/OcclusionQueryMesh.html
This change integrates WebGL2 queries into the renderer, allowing occlusion querying like this:
Hope you like it