-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
KHR_implicit_shapes extension Draft Proposal #2370
base: main
Are you sure you want to change the base?
Conversation
...s/2.0/Khronos/KHR_collision_shapes/schema/glTF.KHR_collision_shapes.shape.convex.schema.json
Outdated
Show resolved
Hide resolved
extensions/2.0/Khronos/KHR_collision_shapes/schema/glTF.KHR_collision_shapes.shape.schema.json
Outdated
Show resolved
Hide resolved
extensions/2.0/Khronos/KHR_collision_shapes/schema/glTF.KHR_collision_shapes.shape.schema.json
Outdated
Show resolved
Hide resolved
extensions/2.0/Khronos/KHR_collision_shapes/schema/glTF.KHR_collision_shapes.shape.schema.json
Outdated
Show resolved
Hide resolved
"extras": { } | ||
}, | ||
"required": [ | ||
"convex", |
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.
Not a strong opinion but would it be reasonable to make the property not required with the false
being the default value?
|
||
As both the `mesh` shape references a `mesh`, it additionally allows for optional `skin` and `weights` properties, which have the same semantics and requirements enforced by the properties of the same name associated with a `node`. When specified on a `mesh` whose `convex` property is `true`, the resulting collision shape should be the convex hull of the deformed mesh. As collision detection is typically performed on CPU, the performance impact of deforming a mesh in such a use-case is typically higher than inside a vertex shader. As such, use of this functionality should be given careful consideration with respect to performance. When `convex` is `true`, the referenced mesh need not necessarily be convex itself, nor is there any requirement for the geometry to be closed. An implementation must generate a convex hull from the input vertices. | ||
|
||
Degenerate shapes are prohibited. A `sphere` must have a positive, non-zero radius. `box` shapes must have positive non-zero values for each component of `size`. `cylinder` and `capsule` shapes must have a positive, non-zero `height` and both `radiusTop` and `radiusBottom` should be positive; at least one of the radii should be non-zero. For `mesh` shapes whose `convex` property is `false`, the referenced mesh must contain at least one non-degenerate triangle primitive. For `mesh` shapes whose `convex` property is `true`, the referenced mesh must contain contain primitives with at least four non-coplanar vertices. |
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.
Please do not use backticks unless explicitly referring to properties. For example:
A sphere must...
Box shapes must...
|
Rename "convex"->"convexHull". Tidy up phrasing, documentation. Improved introduction text; add an inline sample defining a shape. Clarifications around degenerate shapes & node scale. Remove backticks when not referring to a property.
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.
The contents of this PR do not match the repo in which the extension was developed: https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_collision_shapes/schema
If changes are needed, the original repo should also be updated so that it stays in sync.
"skin": { | ||
"description": "The index of a skin with which to deform the mesh.", | ||
"allOf": [ { "$ref": "glTFid.schema.json" } ] | ||
}, | ||
"weights": { | ||
"type": "array", | ||
"description": "The weights of the instantiated morph target.", | ||
"minItems": 1, | ||
"items": { | ||
"type": "number" | ||
} | ||
}, |
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.
I'm confused, why are skins and weights used for collision meshes? Where was the discussion on this? What is the use case?
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.
This was discussed in several Khronos meetings on the interactivity spec. These parameters match functionality already in the glTF node. The usecase is to allow users to describe collision shapes which accurately match the render meshes.
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.
collision shapes which accurately match the render meshes
I could see weights/skins being calculated once at load time, but since "interactivity" is brought up, it sounds like the intent is to permit changing vertices on any given frame. I cannot find a good specification for the intended behavior when vertices of a collision mesh are animated at runtime (e.g. on every frame). I see two big problems:
-
Firstly, it seems highly unperformant: both the need to regenerate optimized collision geometry (such as a convex hull or deduplicated trimesh vertices); and to run skinning on the CPU (some engines upload skinned mesh geometry to the GPU and do not store a copy on the CPU, so this may involve data transfer from the GPU on each frame). In the case of convex hulls, it might not be feasible to re-build the hull every frame in which it may have been animated.
-
In a physics sense, it seems to me problematic that the skinned mesh deformation is non-physical: if the change in shape causes a collision, does it exert a force? if so, what force? if not, will it be allowed to intersect with adjacent geometry from one frame to the next, or entirely phase through it?
As a concrete example, imagine a razor-thin mesh floor of an elevator, using a skin joint to move upwards, and a small marble resting on the floor of this elevator. Imagine an implementation performs CPU deformation by calling BakeMesh() every frame, effectively swapping out one mesh for another. If the joint node moves quickly enough, the floor of the elevator may move more in one physics frame than the radius of the marble, causing it to fall. This will be highly dependent on physics framerate, which could differ either due to hardware specs or by user agent.
Ultimately, I believe the likely outcome is the majority of conventional game engines will choose between ignoring support for skins/morphs for physics shapes (which means inconsistent support), or doing something unperformant (for example, calling BakeMesh() every frame). This sort of feature sounds cool, but it's a pie in the sky, and the likelihood of inconsistent support could scare users away from using the feature, which tells me that it belongs in a separate extension.
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.
Note that mesh
objects already have weights
defined in the core glTF specification. Those weights may be animated, so this needs to be supported anyway. These properties merely the shapes consistent with how nodes can apply per-instance weights to a mesh, as well as using a skinned mesh.
As with many glTF features, it's possible to describe scenarios which are non-physical or may perform poorly, but at the end of the day, glTF content is made by a human who is ultimately making decisions about what that content is. The fact that a feature may be misused is not a good reason to say "we don't support this feature which is in the core spec."
note that in X3D
Collision for navigation can be a property on Grouping Node types
https://web3d.org/documents/specifications/19775-1/V4.0/Part01/components/navigation.html#Collision
and then there is a whole Rigid Body Physics Component for other object-object collisions
https://web3d.org/documents/specifications/19775-1/V4.0/Part01/components/rigidBodyPhysics.html
________________________________
From: Aaron Franke ***@***.***>
Sent: Thursday, May 30, 2024 6:17 PM
To: KhronosGroup/glTF ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [KhronosGroup/glTF] Merge of KHR_collision_shapes extension (PR #2370)
@aaronfranke commented on this pull request.
The contents of this PR do not match the repo in which the extension was developed: https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_collision_shapes/schema
________________________________
In extensions/2.0/Khronos/KHR_collision_shapes/schema/glTF.KHR_collision_shapes.shape.mesh.schema.json<#2370 (comment)>:
+ "skin": {
+ "description": "The index of a skin with which to deform the mesh.",
+ "allOf": [ { "$ref": "glTFid.schema.json" } ]
+ },
+ "weights": {
+ "type": "array",
+ "description": "The weights of the instantiated morph target.",
+ "minItems": 1,
+ "items": {
+ "type": "number"
+ }
+ },
I'm confused, why are skins and weights used for collision meshes? Where was the discussion on this? What is the use case?
—
Reply to this email directly, view it on GitHub<#2370 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AB2TSM72PNKRZZVZHCH2ZF3ZE6QOZAVCNFSM6AAAAABE5T5AW6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDAOBZGQ2TEMJVHE>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Remove convex hull options from base KHR_collision_shapes; for many cases, convex hulls are not necessary and having to support convex hull generation in a viewer may be a significant implementation burden. Refactor morph targets to support the common use-case of describing a mesh collider which intends to use the same morph target weights as a node's instance weights. Add an explicit recommendation for how an extension can reference a collision shape. Upgrade schemas to draft 2020-12.
@eoineoineoin - Thanks for bringing up 'implicit shapes'. If I could pick two shapes that would help AEC, it would be cylinder and cube. We could add a million other shapes, but I would compromise everything, just to get these two into a future spec somehow. We pay a very high price for cylinders (HVAC, railings, cables, rebar, etc). If the industry agreed on this, there would be a lot of precision gained (measurement), less data-loss (from pre-baked tessellation) and far fewer triangles transported and rendered. Same for 'Cubes'. If the industry agreed on a cube shape, rather than "I think these 16 triangles are a cube", it would add a lot of meaning for AEC - the design intent is captured, it's manifold, it has an agreed volume, render outline-style without guessing, improved z-fighting of overlapping volumes. I know it's a very low bar, but you've got to start somewhere and these two additions add an impressive amount of value IMHO. |
@wallabyway I've lost track of some of the discussion/developments here, and am (unfortuantely) not up to date. But a while ago, I also advocated for basically creating When "shapes" are defined here (non-renderable, as part of a "collision" extension), then someone will create a new extension that defines the same shapes, but "renderable". And in the worst case, one defines a "box" as (min, max), and the other one defines a "box" as (origin, size), and we all know what happens then... Some further related discussion is in #1135 and around #1986 (comment) , and many issues that are linked to/from these. (It's hard to wrap this up - that's why I lost track...). |
Hey Marco, Right, it does seem that there's interest in using the shapes for rendering, amongst other things. So, at the very least, there's a rename of the extension and associated reworking of documentation in the works, to ensure it's obviously usable for multiple different use-cases. The "mesh" shape type is causing us some hassle, though, so I want to see if you have any thoughts here. For things like physics, selectability, UI, etc., it's useful to be able to describe a shape which is derived from a
My concern is that with option 1, the options available in the |
It's hard to say anything really profound here, without all the context, and not knowing the plans that may have been discussed internally already. So all I can say is very high-level, and should be taken with a grain of salt. I think that having a real glTF
That said, from my current, limited understanding, I'm not sure what the problem would be with the point that " glTF meshes are already renderable via nodes" that you mentioned:
If I understood your concern correctly, then it is that someone could do something like Or, referring to your point
Then I think that the (I might be missing a point here...) |
I have been reading through the recent changes to use a collider or trigger "geometry" object. I have some concern with the new version of the spec because it references "node", that implies referencing a node, which must be visible in core gltf. Is there a way to use meshes in physics colliders without rendering those meshes? Related to this problem is a confusing paragraph here, so I would like some clarification on this:
if I understand correctly, does this paragraph that the nodes and child nodes (a comment by Khronos members implies this actually means descendants) in the context of mesh geometry are taken in local space of the referenced if so, can I ask if an acceptable way to implement hidden mesh collision shapes is to make a node whose scale is [0,0,0] (which hides the mesh as per the core gltf spec): since the collision shape children use a coordinate space relative to this node, child nodes will ignore the 0 scale. Does this make any sense? if for some reason using [0,0,0] scale is not possible, the only alternatives I can think of are using a translation at 1e+99 to effectively hide the mesh, or relying on the node visbility extension (but this will not degrade well to older versions of Blender, for example) |
Draft of an extension which describes generic, non-renderable shapes suitable for collision detection.
Known Implementations
Blender importer/exporter
Babylon.js importer
Godot importer
Sample Assets
https://github.com/eoineoineoin/glTF_Physics/tree/master/samples