[x3d-public] ideal points in IndexedFaceSet
Michalis Kamburelis
michalis.kambi at gmail.com
Fri Feb 16 14:23:38 PST 2018
Hi,
I'm unsure about allowing homogeneous coordinates with w = 0 for
IndexedFaceSet coordinates.
They would work for some tasks (GPU can render them, they work with
math using 4x4 matrices), but some other tasks would need to be
disabled.
- Since the points do not have a regular position (they are in
infinity, and are actually "directions", not points), we cannot use
these coordinates for collision-detection. Physics engines in general
do not accept mesh collider with homogeneous coordinates :)
- Even calculating bounding volumes (boxes, spheres) will not work,
unless the code is specially adjusted to account for this case, and
returns some "infinite" or "infinite in some directions" bounding box.
- Normal positional and spot light equations will not work, since they
assume that there's a normal point in 3D, that has some finite
distance to other position in 3D.
Of course, in your case, you probably don't care about collisions or
lighting on these IndexedFaceSets in infinity, so you may be OK with
just disabling all these features, when 4D coordinates are provided.
So, while I'm not against this idea, I'm just saying it's not trivial.
It would require adjustments in every X3D browser for this special
use-case.
A possibly simpler solution (and one that already works, today, if
you're OK with writing your own shaders (using X3D ComposedShader or
similar nodes, or Castle Game Engine shader effects)):
You can pass your homogeneous coordinates using the X3D attribute
node. Use FloatVertexAttribute with NumComponents = 4, this way you
can pass vec4 per-vertex to shader. In the shader, just use this
position from your own attribute for all the calculations, ignoring
the regular vertex coordinates that the browser sends from
IndexedFaceSet coordinates.
Regards,
Michalis
More information about the x3d-public
mailing list