[x3d-public] Nurbs patch coloring

Andreas Plesch andreasplesch at gmail.com
Tue Apr 21 07:28:56 PDT 2020


Dear Michail,

let me cc the public list since this exchange may be of more general
interest, and will get archived that way.

I implemented and tested the four corner color interpolation approach.
Please find an x3dom build here:

https://5e9ef94a5187040007515022--x3dom.netlify.app/

and your example adjusted to only provide the four corner colors and
no weights here:

https://5e9ef94a5187040007515022--x3dom.netlify.app/examples/functional/nurbs/bezierpatchescornercolors

As indicated, I took the route to keep the color space nurbs
interpolation and in case of only four colors being provided fill in
the missing control point vertex colors by bilinear interpolation,
assuming uniform spacing.

But this could be seen as an implementation detail. Other browsers may
only use bilinear interpolation (at some point in the future).

The semantics follow the vertex color semantics of other geometry
nodes. The color node, if provided, has colors for each control point,
in the same order as the control points are given. If number of colors
does not equal the number of control points, results are undefined,
except if there are exactly 4 colors. In this case, the colors are
assigned to the parametric corners of the surface, in this order:

P(0,0) has color[0]
P(uDimension-1, 0) has color[1]
P(0,vDimension-1) has color[2]
P(uDimension-1, vDimension-1) has color[3]

Colors for other control points are derived by bilinear interpolation
between the four corners, in parametric space.

Colors between control points are interpolated by NURBS interpolation.
The control point colors define a NURBS surface in color space which
can be sampled at each parametric point required for tesselation.

I did not add transparency although this requires 'only' some book
keeping. [ Not sure if x3dom deals well with RGBA vertex colors
although it should ].

Take a look at the build and please try it with other examples,

-Andreas

On Tue, Apr 21, 2020 at 12:08 AM Michail Vidiassov <master at iaas.msu.ru> wrote:
>
> Dear Andreas,
>
> On Tue, Apr 21, 2020 at 6:03 AM Andreas Plesch <andreasplesch at gmail.com> wrote:
>
> > thanks. I understand now what you had in mind with bilinear coloring. You would like to only consider the corner colors whereas larger nurbs surfaces may also have a lot of internal control points which I thought may have their own colors similar to real vertex coloring.
>
> You are right, but it is the _next_ step of improvement after corner colors.
> One color per patch, color discontinuity at common edges -> (bi)linear
> interpolation, color is continuous -> smooth change with NURBS colors.
> And it is a step into uncharted territory where we (at least I) have
> no clear idea on how things should look in case of general NURBS.
> Plus "color NURBS parameters must be the same as geometry NURBS
> parameters" may be considered not a full step, thus my fears that
> generalization (for the sake of generalization) would lead to
> "NurbsColorCoordinate".
>
> > Paradoxically this simpler coloring method would not be easier to code since it involves an additional method (bilinear interpolation) while with color nurbs interpolation the existing setup is just reused.
> >
> > As you indicated providing 4x4 colors instead of 2x2 may be doable but I see in your use case it is a bit cumbersome.
> >
> > One approach may be to have x3dom fill in automatically control point colors if only exactly 4 colors are provided. That should be straightforward.
>
> That is for you to decide, I do not understand x3dom code enough to
> argue on that.
> It seems surfacePoint3DH has u, v and colors - why not just replace
> NURBS color calculations with bilinear interpolation (completely or if
> there are only 4 colors).
>
> > I think the ordering would then be reverse from what you suggested:
> >
> > color=[ c0, c1, c2, c3 ]
> > c0 at 0 u, 0 v
> > c1 at 1 u, 0 v
> > c2 at 0 u, 1 v
> > c3 at 1 u, 1 v
>
> The ordering in my example was arbitrary, I just wanted to describe
> bilinear interpolation in general with a formula to avoid
> misunderstanding.
> So there was no suggested ordering.
>
> > I think I can give this a try,
>
> Please consider enabling RGBA colors.
> And in your current code NURBS vertex colors are used only if weights
> are present.
>
> Sincerely, Michail



-- 
Andreas Plesch
Waltham, MA 02453



More information about the x3d-public mailing list