Actually, occlusion queries are unsupported for multiple cameras: we can only have a single occlusion query running for a given mesh (the isOccluded property is not per-camera).
It happens that WebGL uses the first camera (but depending on GPU timings, it could be another one) and WebGPU the last one (or at least not necessarily the first one).
I created a PR to make it consistent, and all engines will now use the first camera for the occlusion query:
@Evgeni_Popov The problem is still present when using a mesh with ImportMesh (WebGPU engine) nothing happens.
And in the console I notice this error which I also have on my project:
a.getContext(...).drawWindow is not a function
I have the same error on my project repeat 250 times :
Query index 49 of [QuerySet] is written to twice in a render pass.
- While validating the occlusion query index (49) in [QuerySet]
- While encoding [RenderPassEncoder].BeginOcclusionQuery(49).
[Invalid CommandBuffer from CommandEncoder "render"] is invalid.
- While calling [Queue].Submit([[CommandBuffer from CommandEncoder "upload"], [CommandBuffer from CommandEncoder "renderTarget"], [Invalid CommandBuffer from CommandEncoder "render"]])
Oh, yes I hadnāt paid attention to the scene.clearColor. It works like this.
But when are there errors in the console : a.getContext(...).drawWindow is not a function
And why on my project do I have these two errors repeating when I use occlusions? What could be causing these errors?
Query index 49 of [QuerySet] is written to twice in a render pass.
- While validating the occlusion query index (49) in [QuerySet]
- While encoding [RenderPassEncoder].BeginOcclusionQuery(49).
[Invalid CommandBuffer from CommandEncoder "render"] is invalid.
- While calling [Queue].Submit([[CommandBuffer from CommandEncoder "upload"], [CommandBuffer from CommandEncoder "renderTarget"], [Invalid CommandBuffer from CommandEncoder "render"]])
I donāt have the error a.getContext(...).drawWindow is not a function in the PG you provided(?)
This error means that a.getContext(...) doesnāt return a proper context, whatever a could be. But without a repro, it will be hard to find the root cause.
Regarding the second error, itās what you get before the PR is merged: are you sure to use the latest version of Babylon.js, or at least a version with the fix?
For the getContext error I wonder if in this case it would not come from an extension of my browser.
For the second error, I am using the latest version 6.20. Iām trying to figure out why, but I donāt know whatās going on? what could produce this?
Without a repro, itās going to be hard to find the root cause. Iāll ask the people who implemented WebGPU in Chrome if they can shed some light on the error message.
In the meantime, are you able in your project to comment out code (such as shadows, additional rendering effects, etc.) until you no longer get the error? The idea is to be able to pinpoint more precisely what led to this error message.
Yes, thatās what Iām doing at the moment, Iām gradually deactivating everything to understand whatās wrong, when.
I realized that on the editor side it works (WebGPU and WebGL), but on the game generated, I the error in WebGPU and not WebGL). So Iām trying to understand where Iām going wrong.
As for the error I suspected to be from an extension for the a.getContext. This is indeed one of my extensions which is creating this error.
Can you add this code just after you created and initialized the engine:
if (engine._occlusionQuery) {
engine._occlusionQuery._allocateNewIndices(10);
}
You should replace the 10 value with the number of meshes for which occlusion queries are enabled. You donāt have to pass the exact number, this number only has to be equal or greater to the number of meshes with occlusion queries.
Let me know if you still have the error after this change.