[x3d-public] (no subject)

Michalis Kamburelis michalis.kambi at gmail.com
Wed Jan 24 23:50:03 PST 2018


2018-01-24 13:25 GMT+01:00 Michail Vidiassov <master at iaas.msu.ru>:
> Dear All,
>
> is it possible in X3D to store NURBS patches with vertex colours?
>
> The program I am evaluating X3D export for, Asymptote, deals with
> Bezier patches, with colours assigned to corners and interpolated
> within the patch.
> My reading of the format description suggests that the answer is
> negative, but the following example from the X3D specification and a
> demo of an obsolete viewer suggest otherwise (in both cases I was
> unable to find relevant x3d file).
>
> ttp://www.web3d.org/documents/specifications/19775-1/V3.3/Images/NurbsPatchSurface.png
> http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/nurbs.html#NurbsPatchSurface
>
> https://youtu.be/WQEPBfLkyMc
>

In short: It is not possible, i.e. there's no field in the X3D
specification to pass something like "color per control point" (like a
Color or ColorRGBA node) to a NURBS surface, as far as I see.

However, there are some solutions that you can use to "colorize" the
NurbsPatchSurface:

1. You can apply a texture to NurbsPatchSurface. So you can draw your
colors to an image, and apply them this way. NurbsPatchSurface
automatically calculates sensible texture coordinates (or you can pass
explicit "texCoord" field).

2. You can use shaders, like ComposedShader, to colorize your
NurbsPatchSurface. This works for any shape (NURBS or not), since
shaders are specified as part of the Appearance, outside of the
geometry node. So if your colors can be expressed as a deterministic
function of a position / normal / texcoord / etc., then you can
calculate them in the shader.

    Note that NurbsPatchSurface does not have an "attrib" field to
pass "custom shader attribute per control point", which would be
equivalent to "attrib" on other nodes like IndexedFaceSet.

>From my implementation point of view (view3dscene, Castle Game
Engine), adding something like "NurbsPatchSurface.color" or
"NurbsPatchSurface.attrib" (equivalent to "IndexedFaceSet.color",
"IndexedFaceSet.attrib", providing values "per control point") does
not seem difficult :) But I don't know if there is enough interest to
implement it, or think about standardizing.

Best regards,
Michalis



More information about the x3d-public mailing list