-
Notifications
You must be signed in to change notification settings - Fork 7
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
Revise EXT_primitive_voxels
#69
base: ext-primitive-voxels
Are you sure you want to change the base?
Conversation
Based on some of the inconsistencies you pointed out I'm starting to think the @j9liu what do you think of this?
Some things I like about this approach:
I'm treating region as its own shape type since the intersection math would be different and runtimes can heavily optimize if there are two radii instead of three. Also I don't think we need to support all these shape types up front, I just wanted to mock them out. One final meta idea I had was to split this extension into two:
That would allow people to use the first extension in a raytracer or SDF renderer even if they don't have voxel data. |
There are many possible questions, alternatives, or related extension proposals (and maybe I'll write a longer comment with further thoughts here a bit later). Many of these questions revolve about the concept of ~"equivalent representations" (down to the level of https://en.wikipedia.org/wiki/Basis_(linear_algebra) ...). But one specific question is: What's the purpose of "ellipsoid"? Assuming that the structure of the voxel cells (i.e. the division into lat/lon/height cells) is not affected by the radii, and assuming that the voxels will be affected by the transform of the node that they are attached to, the different radii of the ellipsoid could be represented with a (non-uniform) node (Yes, the |
This was the initial idea for the extension (as in #48 ). But in offline discussions with @lilleyse, we thought that it might not be intuitive to typical glTF users or use cases. IMO, the "unit" shapes in that PR (box from [-1, 1], or cylinder with height [-1, 1]) contains a hidden scale of 2 that is also not expected of a "unit" shape. Plus the other extensions I've seen for defining implicit geometry in some way, have all included some ability to specify shape-relative dimensions anyway. e.g. here and here. (And I think you actually linked these, though maybe under different context 😅 ) Ultimately I would push back and say that, if we can just use node transforms for everything, why doesn't every 3D model exist in a [0, 1] space? It's more intuitive, at least to me, to have a mesh that exists as-is in its own local space, with the dimensions that it wants to have. Then, it can be transformed by nodes as needed. While math-wise this may be the same, conceptually I think this makes more sense. I don't think having a
|
@lilleyse based on your last post, I mocked up what a separate I had some thoughts:
|
(I would have brought up that "unit cube" in my world means (0,0,0)-(1,1,1), but I couldn't decide whether a "unit cylinder" should have radius 1.0 or 0.5, even though a "unit sphere" definitely has radius 1.0, ... which is odd, because a "unit cube" could just be a "unit sphere with an ∞-norm", ... 🤪 ... I'll skip that for now...) To be clear: I did not want to "propose" the unit-shape-based approach. I was just wondering about pros and cons of different representations for the different possible application cases of such a 'extension that only defines geometric shapes'. These are roughly: Rendering, physics (rigid bodies, collision detection), and things like voxel bounds. I thought that, for example:
But I know nothing about the practical implementation (for voxel, or for stuff like physics). I'm sure that there are drawbacks to some of the approaches that "look nice" when scribbling with pencil+paper, and advantages to the more elaborate ones that explicitly say, for example, "how large a box is". (It's certainly more intuitive, but there may be further advantages as well). |
@javagl sorry if my previous response sounded dismissive. I thought you raised good points, and they were ones I + @lilleyse considered. I meant to respond with the reasons I used to talk myself out of the same concerns
I do agree that the Worst comes to worst the
Yeah I get what you're saying. Though, not to be stubborn about it, but I also think a client could just account for the extra size properties in the math. (e.g., convert |
That's clearer to me. It would also simplify the descriptions in the spec. The spec wouldn't need to define what the unit shape is. It would just say the box has this size and the cylinder has this radius and height. Do you know what conventions other glTF extensions are using?
I agree,
Yeah good point @javagl. It's probably clearly to omit the
Maybe there should be distinct shape types for sub-volumes? That way the extension provides a super simple definition for boxes, cylinders, ellipsoids, and more complex variants for cylinder sub-volume, ellipsoid sub-volume. |
f4d3ccc
to
dc1029a
Compare
I started fleshing out more of the README + spec for
I'm open to this. As it currently stands, this is how the
If we bring this out into a separate
I could go either way. I like the cleanliness of having the base geometry types, and simply adding fancy modifiers to it (like I also had some questions about
|
Also, thinking about how
The one area where it may be a little tricky / confusing is when you also introduce
|
Synced about the status of these extensions offline.
TODO:
Please nitpick names and organization as you see fit 😃 |
It seems like this should really exist on the accessor instead? Similar to
Otherwise, I guess you could map Perhaps we could just create a dependency of |
I'm concerned about the amount of complexity that this would imply for possible implementors. |
That's a fair point. I was rushing to leave that comment and didn't think through the implications. This is my picture so far for how in
in a given glTF:
For a voxel tileset it would be expected / required / implied that:
Perhaps |
It's been a while, but I've updated the PR with the following:
Still TODO:
|
Whoops, forgot about the cylinders. Will work on that, thanks for pointing it out @lilleyse! |
❗ WORK IN PROGRESS ❗
This revisits the specification for the
EXT_primitive_voxels
extension. The goal is to achieve same functionality as the original spec, while redefining elements that may make it more intuitive for simpler use cases. (e.g., a Minecraft-style chunk in a box voxel primitive).I have not finished updating the README, because there's still things in the spec I'm not as confident about, and I don't want to put in the effort to make diagrams for things that will change 😃 I'm listing the biggest changes here, and will draw attention to the ones that are open to feedback.
Primitive Mode
Previously, this extension added three new primitive modes, each indicating some type of voxel geometry.
Now, the extension only adds one new primitive mode, representing a
VOXEL
constant. The actual geometry of the grid is indicated in the properties of the extension (see below).Bounds
Previously, the
bounds
property was used by all three voxel geometry modes to specify a subsection of the shape in its unit shape space.Now,
bounds
has been removed. The grid geometry (and their extents) are indicated in the respective properties:box
,cylinder
, andellipsoid
. This removes the need to shoehorn the grid bounds into the 3-element arrays shared by all shape types.Shape Definitions
Previously, the unit shapes (in which the voxel grid is actually defined) were in a space of [-1, 1].
For example, consider a box voxel grid. The unit box is between [-1, 1] in all dimensions. The
bounds
would specify a subsection, say [-0.5, 0.25], within that [-1, 1] space. It was up to the node transform to scale this primitive to the desired world-space size.In this revision, geometry is now no longer confined to that unit space. The geometry may be specified like so:
Box
box.min
andbox.max
define the corners of the box-shaped voxel grid. These positions are given in the local space of the primitive. So, a box grid may be defined with values like (-1, -2, -3) and (3, 0, 1).The translation and scale from the unit space box can be inferred from the given
min
andmax
. So hopefully this extra transform can be incorporated into existing implementations without too much trouble.Cylinder
The same three "axes" in the previous version of the spec are still used for this one:
radius
,height
, andangle
.height
is listed second because it goes along they
-axis of the glTF, so this attempts to mirror the XYZ order of the box.radius
is now a 2-element array specifying the min and max radial extents for the cylindrical grid. This is now given in the local space of the primitive, so the extents may be defined with values like [1, 2]. This can be scaled back down to the unit range [0, 1] by following the max radius. Minimum value = 0.Similarly,
height
is now a 2-element array specifying the min and max height extents for the grid. Also now given in the local space of the primitive, so the extents may be defined with values like [-1, 3]. This can be scaled / translated back to the unit range [-1, 1].Finally,
angle
is now a 2-element array specifying the min and max angular extents for the grid. Still given in the [-pi, pi] range.❓ QUESTIONS ❓
Part of me feels like this definition of a cylinder is rather complex. (My simple mind would expect a cylinder to be simply defined by a radius and height.) So could the following suggestions have merit?
radius
andheight
can be potentially one item arrays. The default min radius could be 0, so the grid fills the entire cylinder volume up to the given max radius. Height could be interpreted as the cylinder ranging from [-height
/ 2,height
/ 2]angle
can be optionalbox
may be "translatable" via itsmin
/max
, should thecylinder
have acenter
property so you can specify where the cylinder originates?Ellipsoid
Previously, the ellipsoid was defined in rather geospatial terms. Here, it still kind of is, but it'd be great to make it more intuitive for non-geospatial people.
An ellipsoid is defined by the
radii
, a 3-element array specifying the values along the XYZ axes. Thelongitude
andlatitude
properties specify the long / lat ranges across the ellipsoid where the voxel grid spans.I'm still debating how someone would specify a "region" of the ellipsoid based on height. Previously the
height
range was included as part of the bounds, but as @lilleyse pointed out, this is is rather specific to geospatial so it may not be intuitive to make it a prominent part of the spec. But people may still want to specify subdivisions along the radial axes. So maybe there can be two ways to define this:height
: a 2-element property representing the height above / below the ellipsoid where the region spansratio
: a 2-element property representing the ratio of the ellipsoid that the grid spans. For example, [0.5, 1] represents an ellipsoidal grid with a hollowed out middle.❓ QUESTIONS ❓
Again, this definition of an ellipsoid is a bit complex. Could
longitude
,latitude
, andratio
/height
be optional?Additionally, if a
box
may be "translatable" via itsmin
/max
, should theellipsoid
have acenter
property so you can specify where the ellipsoid originates?And finally, should a
region
be a formal property in the main body of the extension (designating it as entirely different from the ellipsoid grid)? Or perhaps it should be an optional sub-property ofellipsoid
?