-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
i3dm renders incorrectly when model has non-identity matrix #11176
Comments
Thanks for the report @bbbbx! |
I have encountered a similar behavior with I can provide the tileset with some trees placed: Peek.2023-06-29.15-04.webmThe same tileset is working just fine in |
i retried with a simpler example, cube 10 units. this leads to wobbly vertex displacements : cube10_instanced_tileset.webm |
I've found a workaround for cases when |
Also reported in #11617. |
After this came up several times in the forum, most recently at https://community.cesium.com/t/disappearing-i3dms-on-map-navigation-again/34035 , I did a short debugging pass. Well. Not so short, actually. What's particularly humbling is that the statement that was made in the first comment, namely
was spot on (and it took me a while to arrive at the same "insight"). Some details:
The caveat is that this node transform may, for example, involve scaling, and that scaling will therefore be indirectly applied to the instancing transforms when it comes to determining their effect on the bounding sphere. Maybe it becomes clearer with some random debug log from some test model: The case where it's not working, when a primitive is attached to a node with a uniform scale of 0.01:
This cannot be right. The instancing translations alone would require a radius of ~1000. The case where it is working, because the scale of 0.01 is "baked" into the primitive, and the node transform is the identity:
The bounding sphere here is properly computed from the primitive min/max plus the instancing min/max. No scaling is applied afterwards. Now, the question is still: How to solve this? One could be tempted to just omit some scaling here or there, to compute the proper bounding sphere. But it's not that simple. There could be instancing information (like from In contrast to that, the (I'm talking about "affecting" here - I should be more precise, and say whether this affects the rendering or some bounding volume computation in some draw command. But .. it's complicated. One thing that I want to try out is whether the rendering even works properly when there is an I3DM for a glTF that contains two nodes with different scaling factors. It's not yet clear whether the "error" here is really only affecting the draw command bounding volume part, or whether it also affects the rendered instances. I hope that it's only the draw command. But this has to be investigated further) |
@bertt already provided very helpful data in the forum thread...s, that helped to narrow down the issue. I created another test ("CC0", so to speak). It is an I3DM with positions
This is used to create four instances of a GLB that contains some data that aims at
For the latter, there are a bazillion possible reasons. (I mean, starting with the fact that the I3DM only contains positions, but no scaling/up-vectors etc). But the glTF consists of 4 unit cubes:
(I obviously ~"tried to cover several cases" here. Doing this thoroughly and systematically, sneaking in scaling and translation (and maybe rotation etc) everywhere, and/or using transforms that "cancel out" each other, would yield a combinatorial explosion. The cases have been selected based on the insights from the debugging pass, just to have a few "hot candidates", and a first, basic test...) The good news is: The bug does not affect the rendering of the instances themself. Regardless of the scaling and whatnot, they are all unit cubes at the proper locations: The ... also good... ? or bad...? ... the other news is that this already shows the problem: Only the green cube seems to ever disappear. It is the only one that is attached to a node with a global scaling less than 1.0. Based on the previous debugging pass, this is not toooo surprising: For the other cubes, it will just overestimate the size of the object, roughly meaning ~"a reduced culling-efficiency" - it will still 'render' these nodes even if it wouldn't have to. I'll have a short look at possible solutions for all this, and maybe create a draft PR. EDIT: Nearly forgot: Here's the test data, with a tileset JSON and sandcastle: |
An old thread that very likely refers to the same issue: https://community.cesium.com/t/the-gpu-instantiated-artifacts-will-disappear-when-i-rotate-the-model-in-cesium/24688 |
When the transformation matrix of the glTF node of i3dm is not the identity matrix,
the calculation of the bounding sphere of the model(scene graph/primitive/draw command) is wrong,
causing the far and near planes of the viewing cone to be smaller than expected,
and finally the pixels outside the bounding sphere are discarded in the fragment shader(writeLogDepth.glsl).
Screenshot:
i3dm.mp4
Sandcastle example: url
Browser: Google Chrome 111.0.5563.65
Operating System: Windows 10
The text was updated successfully, but these errors were encountered: