POV-Ray : Newsgroups : povray.advanced-users : 3D uv mapping of bezier patches Server Time
19 Apr 2024 13:50:51 EDT (-0400)
  3D uv mapping of bezier patches (Message 1 to 10 of 10)  
From: Bald Eagle
Subject: 3D uv mapping of bezier patches
Date: 19 Jun 2016 17:05:00
Message: <web.576708fa870aacbb80403a200@news.povray.org>
So, the most advanced bezier patch scene I've done is my
(still incomplete)
9-patch surface with interpolated (but still flawed) control points and 2D
uv-mapping.

I'd like to know if anyone has done, or knows how to define the uv vectors so
that I can stretch a single image over the surface of multiple bezier patches
that defines the sides of a box or boxes.

Thanks!


Post a reply to this message

From: Bald Eagle
Subject: Re: 3D uv mapping of bezier patches
Date: 21 Jun 2016 16:30:00
Message: <web.5769a32ae975129580403a200@news.povray.org>
Is there a reference that better explains uv-mapping for bezier patches?

It's hard to make heads or tails of how to construct a patch and uv-map it so
that both the outside and the inside textures are oriented in a way that makes
any sense.

The defaults seem --- odd.   I t appears I'm not the first to think this.
http://www.joshuarenglish.com/cyclopedia/uv_bicubic.html
(See Section 4 at the bottom)

It's unclear to me _exactly_ what the 4 uv vectors are for and what they
specifically do.   How do they function along with the control points?

I have a vague understanding of the generalities, but I would like to find some
specifics.

The following works for me, but gives an inverted interior texture when I flip
the patch 180 degrees to view the back.

 //  Control points arranged from origin over and up
 //  >>> UV VECTORS ARRANGED clockwise from top left around right and down
around to bottom left <<<
 bicubic_patch {
  type 1
  flatness 0
  u_steps 3
  v_steps 3
  //  default
  //  uv_vectors <0,0>,<1,0>,<1,1>,<0,1>
  uv_vectors
  <0, 1> <1, 1> <1, 0> <0, 0>
  <X13, Y13, Z13>, <X14, Y14, Z14>, <X15, Y15, Z15>, <X16, Y16, Z16>,
  < X9,  Y9,  Z9>, <X10, Y10, Z10>, <X11, Y11, Z11>, <X12, Y12, Z12>,
  < X5,  Y5,  Z5>, < X6,  Y6,  Z6>, < X7,  Y7,  Z7>, < X8,  Y8,  Z8>,
  < X1,  Y1,  Z1>, < X2,  Y2,  Z2>, < X3,  Y3,  Z3>, < X4,  Y4,  Z4>
  uv_mapping
    interior_texture  {pigment {image_map {png "UVtesttexture1.png"} scale 1}
finish {phong 0.6 phong_size 20} }
    texture {pigment {image_map {png "UVtesttexture2.png"} scale 1} finish
{phong 0.6 phong_size 20} }
 }  //  end bicubic_patch 1


I would like to do some further write-ups and diagrams if I can noodle this all
out.

Has anyone else done any bezier patch experiments who could provide some
information and/or SDL?

Thanks.


Post a reply to this message

From: Le Forgeron
Subject: Re: 3D uv mapping of bezier patches
Date: 22 Jun 2016 03:00:24
Message: <576a3788$1@news.povray.org>
Le 21/06/2016 à 22:29, Bald Eagle a écrit :
> Is there a reference that better explains uv-mapping for bezier patches?
>
> It's hard to make heads or tails of how to construct a patch and uv-map it so
> that both the outside and the inside textures are oriented in a way that makes
> any sense.
>
> The defaults seem --- odd.   I t appears I'm not the first to think this.
> http://www.joshuarenglish.com/cyclopedia/uv_bicubic.html
> (See Section 4 at the bottom)
>
> It's unclear to me _exactly_ what the 4 uv vectors are for and what they
> specifically do.   How do they function along with the control points?

IIRC, The 4 uv vectors are the uv coordinates of the 4 corners.
i.e. the first corner of the patch get the uv values of the first uv 
vector. And so on.
The interpolation of uv values is done between 3 vertices (unless you 
are exactly on the great diagonal where the influence is only between 2 
points)


>
> I have a vague understanding of the generalities, but I would like to find some
> specifics.
>
> The following works for me, but gives an inverted interior texture when I flip
> the patch 180 degrees to view the back.

the computation of the interior texture is identical to the "external" 
texture, but you are viewing it from the other side (than the expected 
side). Interior texture is visible when the face is the internal one, 
but the mapping is the same as for the "external" texture. Same point, 
same uv coordinates whatever the side, the side only selects the 
internal or external image to extract the colour for that point.

If you use oriented images, when the mapping of the external image is 
identical to the original image, the mapping of the internal image would 
be identical to the original image when viewed in a mirror on the back 
of the textured object.

Or more easily: there should be no difference between a mapping using 
only one "external" image for both sides, and a mapping using the same 
image explicitly for the exterior and the internal side.

Which mean, of course, that the internal mapping appears reversed when 
viewed from the other side.

I usually think of the bicubic_patch as a real flag, attached to a pole. 
If your image is a lion or an heraldic leopard, one side is to the pole, 
another is away from it. Let say the tail is to the pole, whatever the 
side, the tail is nearer the pole. One side of the mapped picture is 
identical to the original, but the other side is viewed as inverted, 
when considering the left & right concept, yet it is "away from the 
pole" on both sides.


>
>  //  Control points arranged from origin over and up
>  //  >>> UV VECTORS ARRANGED clockwise from top left around right and down
> around to bottom left <<<
>  bicubic_patch {
>   type 1
>   flatness 0
>   u_steps 3
>   v_steps 3
>   //  default
>   //  uv_vectors <0,0>,<1,0>,<1,1>,<0,1>
>   uv_vectors
>   <0, 1> <1, 1> <1, 0> <0, 0>
>   <X13, Y13, Z13>, <X14, Y14, Z14>, <X15, Y15, Z15>, <X16, Y16, Z16>,
>   < X9,  Y9,  Z9>, <X10, Y10, Z10>, <X11, Y11, Z11>, <X12, Y12, Z12>,
>   < X5,  Y5,  Z5>, < X6,  Y6,  Z6>, < X7,  Y7,  Z7>, < X8,  Y8,  Z8>,
>   < X1,  Y1,  Z1>, < X2,  Y2,  Z2>, < X3,  Y3,  Z3>, < X4,  Y4,  Z4>
>   uv_mapping
>     interior_texture  {pigment {image_map {png "UVtesttexture1.png"} scale 1}
> finish {phong 0.6 phong_size 20} }
>     texture {pigment {image_map {png "UVtesttexture2.png"} scale 1} finish
> {phong 0.6 phong_size 20} }
>  }  //  end bicubic_patch 1
>
>
> I would like to do some further write-ups and diagrams if I can noodle this all
> out.
>
> Has anyone else done any bezier patch experiments who could provide some
> information and/or SDL?
>
> Thanks.
>
>
>


Post a reply to this message

From: Thomas de Groot
Subject: Re: 3D uv mapping of bezier patches
Date: 22 Jun 2016 03:12:48
Message: <576a3a70$1@news.povray.org>
On 21-6-2016 22:29, Bald Eagle wrote:
> Is there a reference that better explains uv-mapping for bezier patches?
>
> It's hard to make heads or tails of how to construct a patch and uv-map it so
> that both the outside and the inside textures are oriented in a way that makes
> any sense.
>

I have been looking around in my POV-Ray attic but cannot find anything 
useful. I thought about 
http://www.f-lohmueller.de/pov_tut/all_shapes/shapes675e.htm but he 
stays away from the more complex things and adds that these patches are 
generally generated and not made by hand. I can understand that I must 
say. Josh English seems to be the one most advanced on the matter.


-- 
Thomas


Post a reply to this message

From: clipka
Subject: Re: 3D uv mapping of bezier patches
Date: 22 Jun 2016 10:57:42
Message: <576aa766$1@news.povray.org>
Am 21.06.2016 um 22:29 schrieb Bald Eagle:
> Is there a reference that better explains uv-mapping for bezier patches?

It seems that although the `uv_vectors` keyword did make it into
POV-Ray's `bicubic_patch` implementation it never made it into the
documentation.

Given that the feature first appeared in MegaPOV, it would be logical to
search through old MegaPOV docs for a precise description of what it does.


Contrary to what Jerome posted, the UV coordinates are not interpolated
between 3 points, but between all 4 of them.

Imagine the bicubic patch as a rubber sheet; then the UV mapping can be
visualized as follows:

- First, the rubber square is stretched across the XY plane; the corner
points are pegged to the coordinates specified in the `uv_vectors` list,
while all the points along the edges are also pegged to the plane to
keep the lines between the corners perfectly straight.

- The specified texture is "printed" onto the thusly stretched (and
possibly skewed) rubber square.

- The rubber square is relaxed again to its original shape; note that
depending on the choice of `uv_vectors` it will now show a scaled,
stretched and/or skewed version of the specified texture.

- The rubber square is pulled into the final shape as dictated by the
control points, potentially distorting the texture even further.


Post a reply to this message

From: Bald Eagle
Subject: Re: 3D uv mapping of bezier patches
Date: 22 Jun 2016 16:10:00
Message: <web.576aefabe975129580403a200@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> It seems that although the `uv_vectors` keyword did make it into
> POV-Ray's `bicubic_patch` implementation it never made it into the
> documentation.

Right, I understand that, and know from experience how difficult it can be to
properly document something, especially when it's official, for public
consumption, and technical.   Things can be misread 100 ways.

> Given that the feature first appeared in MegaPOV, it would be logical to
> search through old MegaPOV docs for a precise description of what it does.

I'll see what I can do on that front.

> Contrary to what Jerome posted, the UV coordinates are not interpolated
> between 3 points, but between all 4 of them.

Interesting.   The ways docs are written, it strongly suggests that Bezier
patches are subdivided into triangles, which would lead one to assume that it
was interpolated in the same manner.

I understand the general concept of the uv-mapping.  It's a projection of sorts.
  What I was trying to get to the heart of, was how the uv vectors themselves
determine HOW that mapping is executed.  Are they interpreted by the engine in a
certain order to do something analogous to determining the normal of a triangle?
 I'm sure it's something like that, though with 4 corners, one can probably take
the "rubber sheet", leave 2 corners anchored, and flip the remaining 2 over -
essentially giving the patch a twist.  Switching the opposite corners transposes
the uv matrix which probably flips the whole orientation around 180 degrees.

What happens when a single patch gets fractional coordinates?  Not like
stitching 4 or 9 patches together, but just "random" greater-than-zero and
less-than-1 values?   Greater than 1?

My real present interest is to use 6 patches for the face of a cube and uv-map
the cube.  They're not "uvw" vectors, so I'm struggling to understand what
programmers of modelers do in order to get all of the uv-mapping of 3D objects
to map "smoothly", or "as expected".

I'm wondering if I need to do something / think about it like a SkyBox:
http://www.f-lohmueller.de/pov_tut/skyboxer/skyboxer_1.htm

Thanks for all the responses - maybe the section of POV source code that deals
with using the uv vectors to do what it does might help me.   Or I may drop to
the floor gurgling blood as my flesh smolders and blackens.

I'd say the rewards are worth the risks.   ;)


Post a reply to this message

From: Bald Eagle
Subject: Re: 3D uv mapping of bezier patches
Date: 22 Jun 2016 16:45:00
Message: <web.576af820e975129580403a200@news.povray.org>
I did find this:

8.6.4. Other changes related to UV mapping

Author: Nathan Kopp
Modified (4 corners for bicubic_patch) by: Mike Hough

I've added a new keyword, uv_vectors. This keyword can be used in bicubic
patches (type 0, 1, 2 and 3) to set the UV coordinates for each of the four
corners of the patch. This goes right after the control points and right before
the texture. The default is

uv_vectors <0,0>,<1,0>,<1,1>,<0,1> // syntax is "uv_vectors
<corner1>,<corner2>,<corner3>,<corner4>"
If you had another patch sitting right next to this (as happens often with
sPatch or Moray), you could map the exact same texture to it but use something
like

uv_vectors <1,0>,<2,0>,<2,1>,<1,1> // syntax is "uv_vectors
<corner1>,<corner2>,<corner3>,<corner4>"
(depending on which side of this patch the other is on) so that the two textures
fit seamlessly together.

(see inline image at  http://www-f9.ijs.si/~matevz/docs/MegaPov/megapov.html)

I'll have to a lot of experiments and see what I can figure out.


Post a reply to this message

From: clipka
Subject: Re: 3D uv mapping of bezier patches
Date: 22 Jun 2016 20:32:54
Message: <576b2e36@news.povray.org>
Am 22.06.2016 um 22:06 schrieb Bald Eagle:

>> Contrary to what Jerome posted, the UV coordinates are not interpolated
>> between 3 points, but between all 4 of them.
> 
> Interesting.   The ways docs are written, it strongly suggests that Bezier
> patches are subdivided into triangles, which would lead one to assume that it
> was interpolated in the same manner.

AFAIK, Bezier patches are subdivided into quadrilaterals, which in turn
are divided into two triangles each for no other reason than to ensure
that each of the fundamental elements is guaranteed to be perfectly planar.

> I understand the general concept of the uv-mapping.  It's a projection of sorts.

Technically it is indeed a projection, but that term might be misleading
since it is usually associated with simple linear projections where each
point in 2D texture space has an entire infinite straight line or ray in
3D geometry space mapped to it. In UV mapping, rules for how geometry
space is mapped to texture space are only defined for the surface of the
object in question.

> My real present interest is to use 6 patches for the face of a cube and uv-map
> the cube.  They're not "uvw" vectors, so I'm struggling to understand what
> programmers of modelers do in order to get all of the uv-mapping of 3D objects
> to map "smoothly", or "as expected".

In practice, UV mapping is rarely ever seamless. In all but the most
trivial cases there will be locations where the object's surface is
contiguous but the corresponding texture is "ripped apart". It is the
artist's responsibility to make sure that the texture portions at both
sides of the seam match up -- or that the seam is hidden away where it's
the least obvious.

There are also tools that allow to paint directly on a (virtual) 3D
shape, automatically painting on both sides of any seams.


Post a reply to this message

From: LanuHum
Subject: Re: 3D uv mapping of bezier patches
Date: 23 Jun 2016 15:45:00
Message: <web.576c3bb5e97512957a3e03fe0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I did find this:
>
> 8.6.4. Other changes related to UV mapping
>
> Author: Nathan Kopp
> Modified (4 corners for bicubic_patch) by: Mike Hough
>
> I've added a new keyword, uv_vectors. This keyword can be used in bicubic
> patches (type 0, 1, 2 and 3) to set the UV coordinates for each of the four
> corners of the patch. This goes right after the control points and right before
> the texture. The default is
>
> uv_vectors <0,0>,<1,0>,<1,1>,<0,1> // syntax is "uv_vectors
> <corner1>,<corner2>,<corner3>,<corner4>"
> If you had another patch sitting right next to this (as happens often with
> sPatch or Moray), you could map the exact same texture to it but use something
> like
>
> uv_vectors <1,0>,<2,0>,<2,1>,<1,1> // syntax is "uv_vectors
> <corner1>,<corner2>,<corner3>,<corner4>"
> (depending on which side of this patch the other is on) so that the two textures
> fit seamlessly together.
>
> (see inline image at  http://www-f9.ijs.si/~matevz/docs/MegaPov/megapov.html)
>
> I'll have to a lot of experiments and see what I can figure out.

uv_vectors <0,0>,<0.25,0>,<0.25,1>,<0,1>
uv_vectors <0.25,0>,<0.5,0>,<0.5,1>,<0.25,1>
uv_vectors <0.5,0>,<0.75,0>,<0.75,1>,<0.5,1>
uv_vectors <0.75,0>,<1,0>,<1,1>,<0.75,1>

0 = 0% image width or image height
0.25 = 25% image width or image height
0.5 = 50% image width or image height
0.75 = 75% image width or image height
1 = 100% image width or image height

x>1 or y>1 - bad value


Post a reply to this message

From: clipka
Subject: Re: 3D uv mapping of bezier patches
Date: 24 Jun 2016 04:03:01
Message: <576ce935$1@news.povray.org>
Am 23.06.2016 um 21:42 schrieb LanuHum:

> uv_vectors <0,0>,<0.25,0>,<0.25,1>,<0,1>
> uv_vectors <0.25,0>,<0.5,0>,<0.5,1>,<0.25,1>
> uv_vectors <0.5,0>,<0.75,0>,<0.75,1>,<0.5,1>
> uv_vectors <0.75,0>,<1,0>,<1,1>,<0.75,1>
> 
> 0 = 0% image width or image height
> 0.25 = 25% image width or image height
> 0.5 = 50% image width or image height
> 0.75 = 75% image width or image height
> 1 = 100% image width or image height
> 
> x>1 or y>1 - bad value

Actually, values smaller than 0 or larger than 1 are also perfectly
fine, as POV-Ray's textures are defined throughout the entire R(3)
coordinate space. Even when textures are defined in terms of images,
those images are repeated /ad infinitum/ in the X and Y directions and
extruded in the Z direction to define a 3D texture (unless the `once`
keyword is used, in which case the remainder of the XY plane is filled
with a default value rather than repetitive copies of the image).

Even in 3D engines that define their textures exclusively in terms of
UV-mapped 2D images, the images are usually implied to repeat in UV
space, and UV coordinates beyond the [0..1] range are frequently
employed to cover a model with a repetitive pattern.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.