POV-Ray : Newsgroups : povray.unofficial.patches : uv_mapping bug? Server Time
2 Sep 2024 16:18:33 EDT (-0400)
  uv_mapping bug? (Message 1 to 5 of 5)  
From: smellenbergh
Subject: uv_mapping bug?
Date: 21 Aug 1999 14:09:06
Message: <1dwwklf.1g22tih19rk8nuN@dialup286.leuven.skynet.be>
Rendering a gradient with uv_mapping seems to have a bug when
using the gradient pattern: no mapping is done with gradient z ! With
gradient x and gradient y it renders fine. This is the case with the
sphere, lathe and box objects.
Rendering a bicubic_patch with uv_mapping has a problem with all
gradients. With gradient x the gradient goes in the z-direction. With
gradient y it goes in the x-direction and with gradient z no mapping is
done.

Rendering the scene below will show the problem. The top row shows
gradient x, gradient y and gradient z with the 'classic' gradient.
The bottom row shows the same gradients with uv_mapping.

//************** Scene with uv_mapping bug ? *************
// Change Obj_Switch for different objects
#declare Obj_Switch = 0; //0 =Sphere;  1= Lathe;  2= Bicubic_patch

#declare C_Map =
        color_map {
                [ 0.0 color rgb < 1.0, 1.0, 1.0 > ]
                [ 0.3 color rgb < 1.0, 1.0, 1.0 > ]
                [ 0.3 color rgb < 1.0, 0.0, 0.0 > ]
                [ 0.6 color rgb < 1.0, 0.0, 0.0 > ]
                [ 0.6 color rgb < 0.211505, 0.530358, 0.728481 > ]
                [ 1.0 color rgb < 0.211505, 0.530358, 0.728481 > ]
        }

#if (Obj_Switch = 0)
        #declare Object = sphere  { < 0.0, 0.0, 0.0 >, 0.5 }
#end
#if (Obj_Switch = 1)
        #declare Object = 
                lathe  {
                        quadratic_spline
                        6, 
                        <0.0, 0.000000 >,
                        <0.00000, 0.00645 >,
                        <0.86452, 0.09677 >,
                        <0.28387, 0.35484 >,
                        <0.24516, 0.48 >,
                        <0.00000, 1.00645 >
                        scale <0.7, 0.8, 0.7>
                }
#end
#if (Obj_Switch = 2)
        #declare Object =
                bicubic_patch  {
                        type 1 flatness 0.0 u_steps 4 v_steps 3
                        < -0.6, -1, 0.5 >,      < -0.33, 0.0, 0.5 >,
< 0.33 , 0.0, 0.5 >,    < 0.5, -1, 0.6 >,
                        < -0.5, 0.0, 0.33 >,    < -0.33, -0.2, 0.33 >,
< 0.33, -0.2, 0.33 >,   < 0.5, 0.0, 0.33 >,
                        < -0.5, 0.0, -0.33 >,   < -0.33, -0.2, -0.33 >,
< 0.33, -0.2, -0.33 >,  < 0.5, 0.0, -0.33 >,
                        < -0.6, -1, -0.5 >,     < -0.33, 0.0, -0.5 >,
< 0.33, 0.0, -0.5 >,    < 0.5, -1, -0.6 >
                        translate y*0.6
                }
#end


//Top row with classic gradient
object  {
        Object
        pigment { gradient x color_map { C_Map } scale 0.5 }
        translate <-1.3, 0.4, 0.6>
}
object  {
        Object
        pigment { gradient y color_map { C_Map } scale 0.5 }
        translate <0, 0.4, 0.6>
}
object  {
        Object
        pigment { gradient z color_map { C_Map } scale 0.5 }
        translate <1.3, 0.4, 0.6>
}

//Lower row with uv_mapping
object  {
        Object
        uv_mapping
        pigment { gradient x color_map { C_Map } scale 0.5 }
        translate <-1.3, -0.6, 0>
}
object  {
        Object
        uv_mapping
        pigment { gradient y color_map { C_Map } scale 0.5 }
        translate <0, -0.6, 0>
}
object  {
        Object
        uv_mapping
        pigment { gradient z color_map { C_Map } scale 0.5 }
        translate <1.3, -0.6, 0>
}


camera {
        location < 0.0, 3, -5 >
        angle 40
        look_at < 0.0, 0.0, 0.0 >
}

light_source { <0, 50, -60> rgb 1.5 }


-- 
e-mail:sme### [at] skynetbe

http://users.skynet.be/smellenbergh


Post a reply to this message

From: Nathan Kopp
Subject: Re: uv_mapping bug?
Date: 21 Aug 1999 23:43:01
Message: <37BF725F.A4ECF606@Kopp.com>
It's not really a bug, just a mis-understanding.  You see, the UV-mapping
implemented here simply maps the X and Y of the texture to the U and V of
the object.  It takes a slice of the texture from the XY plane (Z=0) and
wraps that slice around the object.

Any slice of gradient z parallel to the XY plane will have a uniform color,
since the texture will only change in the z direction.

-Nathan

smellenbergh wrote:
> 
> Rendering a gradient with uv_mapping seems to have a bug when
> using the gradient pattern: no mapping is done with gradient z ! With
> gradient x and gradient y it renders fine. This is the case with the
> sphere, lathe and box objects.
> Rendering a bicubic_patch with uv_mapping has a problem with all
> gradients. With gradient x the gradient goes in the z-direction. With
> gradient y it goes in the x-direction and with gradient z no mapping is
> done.
> 
> Rendering the scene below will show the problem. The top row shows
> gradient x, gradient y and gradient z with the 'classic' gradient.
> The bottom row shows the same gradients with uv_mapping.
> 
> //************** Scene with uv_mapping bug ? *************
> // Change Obj_Switch for different objects
> #declare Obj_Switch = 0; //0 =Sphere;  1= Lathe;  2= Bicubic_patch
> 
> #declare C_Map =
>         color_map {
>                 [ 0.0 color rgb < 1.0, 1.0, 1.0 > ]
>                 [ 0.3 color rgb < 1.0, 1.0, 1.0 > ]
>                 [ 0.3 color rgb < 1.0, 0.0, 0.0 > ]
>                 [ 0.6 color rgb < 1.0, 0.0, 0.0 > ]
>                 [ 0.6 color rgb < 0.211505, 0.530358, 0.728481 > ]
>                 [ 1.0 color rgb < 0.211505, 0.530358, 0.728481 > ]
>         }
> 
> #if (Obj_Switch = 0)
>         #declare Object = sphere  { < 0.0, 0.0, 0.0 >, 0.5 }
> #end
> #if (Obj_Switch = 1)
>         #declare Object =
>                 lathe  {
>                         quadratic_spline
>                         6,
>                         <0.0, 0.000000 >,
>                         <0.00000, 0.00645 >,
>                         <0.86452, 0.09677 >,
>                         <0.28387, 0.35484 >,
>                         <0.24516, 0.48 >,
>                         <0.00000, 1.00645 >
>                         scale <0.7, 0.8, 0.7>
>                 }
> #end
> #if (Obj_Switch = 2)
>         #declare Object =
>                 bicubic_patch  {
>                         type 1 flatness 0.0 u_steps 4 v_steps 3
>                         < -0.6, -1, 0.5 >,      < -0.33, 0.0, 0.5 >,
> < 0.33 , 0.0, 0.5 >,    < 0.5, -1, 0.6 >,
>                         < -0.5, 0.0, 0.33 >,    < -0.33, -0.2, 0.33 >,
> < 0.33, -0.2, 0.33 >,   < 0.5, 0.0, 0.33 >,
>                         < -0.5, 0.0, -0.33 >,   < -0.33, -0.2, -0.33 >,
> < 0.33, -0.2, -0.33 >,  < 0.5, 0.0, -0.33 >,
>                         < -0.6, -1, -0.5 >,     < -0.33, 0.0, -0.5 >,
> < 0.33, 0.0, -0.5 >,    < 0.5, -1, -0.6 >
>                         translate y*0.6
>                 }
> #end
> 
> //Top row with classic gradient
> object  {
>         Object
>         pigment { gradient x color_map { C_Map } scale 0.5 }
>         translate <-1.3, 0.4, 0.6>
> }
> object  {
>         Object
>         pigment { gradient y color_map { C_Map } scale 0.5 }
>         translate <0, 0.4, 0.6>
> }
> object  {
>         Object
>         pigment { gradient z color_map { C_Map } scale 0.5 }
>         translate <1.3, 0.4, 0.6>
> }
> 
> //Lower row with uv_mapping
> object  {
>         Object
>         uv_mapping
>         pigment { gradient x color_map { C_Map } scale 0.5 }
>         translate <-1.3, -0.6, 0>
> }
> object  {
>         Object
>         uv_mapping
>         pigment { gradient y color_map { C_Map } scale 0.5 }
>         translate <0, -0.6, 0>
> }
> object  {
>         Object
>         uv_mapping
>         pigment { gradient z color_map { C_Map } scale 0.5 }
>         translate <1.3, -0.6, 0>
> }
> 
> camera {
>         location < 0.0, 3, -5 >
>         angle 40
>         look_at < 0.0, 0.0, 0.0 >
> }
> 
> light_source { <0, 50, -60> rgb 1.5 }
> 
> --
> e-mail:sme### [at] skynetbe
> 
> http://users.skynet.be/smellenbergh


Post a reply to this message

From: smellenbergh
Subject: Re: uv_mapping bug?
Date: 22 Aug 1999 04:35:13
Message: <1dwxn1c.dzd38212wkyeoN@dialup45.leuven.skynet.be>
Nathan Kopp <Nat### [at] Koppcom> wrote:

> It's not really a bug, just a mis-understanding.  You see, the UV-mapping
> implemented here simply maps the X and Y of the texture to the U and V of
> the object.  It takes a slice of the texture from the XY plane (Z=0) and
> wraps that slice around the object.
> 
> Any slice of gradient z parallel to the XY plane will have a uniform color,
> since the texture will only change in the z direction.
> 
> -Nathan
> 
Oh, I see: a mis-understanding indeed. But also a bit disappointed.
Couldn't you use a slice of the texture from the XZ plane and wrap that
around the object for gradient z (this is also true for the mandel
pattern).
Well that explains it for the sphere, lathe and box objects. But there
is still a problem with the bicubic_patch object. With gradient x the
gradient goes in the z-direction. With gradient y it goes in the
x-direction
Just render the scene below and you will see the problem. 

 
//******** Scene with uv_mapping bug ? *************
// Change Obj_Switch for different objects
#declare Obj_Switch = 2; //  2= Bicubic_patch
 
#declare C_Map =
         color_map {
                 [ 0.0 color rgb < 1.0, 1.0, 1.0 > ]
                 [ 0.3 color rgb < 1.0, 1.0, 1.0 > ]
                 [ 0.3 color rgb < 1.0, 0.0, 0.0 > ]
                 [ 0.6 color rgb < 1.0, 0.0, 0.0 > ]
                 [ 0.6 color rgb < 0.211505, 0.530358, 0.728481 > ]
                 [ 1.0 color rgb < 0.211505, 0.530358, 0.728481 > ]
         }
 
 #if (Obj_Switch = 2)
         #declare Object =
                 bicubic_patch  {
                         type 1 flatness 0.0 u_steps 4 v_steps 3
                         < -0.6, -1, 0.5 >,      < -0.33, 0.0, 0.5 >,  <
0.33 , 0.0, 0.5 >,    < 0.5, -1, 0.6 >,
                         < -0.5, 0.0, 0.33 >,    < -0.33, -0.2, 0.33 >,
 < 0.33, -0.2, 0.33 >,   < 0.5, 0.0, 0.33 >,
                         < -0.5, 0.0, -0.33 >,   < -0.33, -0.2, -0.33 >,
 < 0.33, -0.2, -0.33 >,  < 0.5, 0.0, -0.33 >,
                         < -0.6, -1, -0.5 >,     < -0.33, 0.0, -0.5 >,
 < 0.33, 0.0, -0.5 >,    < 0.5, -1, -0.6 >
                         translate y*0.6
                 }
 #end
 
 //Top row with classic gradient
 object  {
         Object
         pigment { gradient x color_map { C_Map } scale 0.5 }
         translate <-1.3, 0.4, 0.6>
 }
 object  {
         Object
         pigment { gradient y color_map { C_Map } scale 0.5 }
         translate <0, 0.4, 0.6>
 }
 object  {
         Object
         pigment { gradient z color_map { C_Map } scale 0.5 }
         translate <1.3, 0.4, 0.6>
 }
 
 //Lower row with uv_mapping
 object  {
         Object
         uv_mapping
         pigment { gradient x color_map { C_Map } scale 0.5 }
         translate <-1.3, -0.6, 0>
 }
 object  {
         Object
         uv_mapping
         pigment { gradient y color_map { C_Map } scale 0.5 }
         translate <0, -0.6, 0>
 }
 object  {
         Object
         uv_mapping
         pigment { gradient z color_map { C_Map } scale 0.5 }
         translate <1.3, -0.6, 0>
 }
 
 camera {
         location < 0.0, 3, -5 >
         angle 40
         look_at < 0.0, 0.0, 0.0 >
 }
 
 light_source { <0, 50, -60> rgb 1.5 }
 

-- 
e-mail:sme### [at] skynetbe

http://users.skynet.be/smellenbergh


Post a reply to this message

From: Nathan Kopp
Subject: Re: uv_mapping bug?
Date: 22 Aug 1999 19:48:55
Message: <37C08CFE.EA92DB48@Kopp.com>
smellenbergh wrote:
> 
> Oh, I see: a mis-understanding indeed. But also a bit disappointed.
> Couldn't you use a slice of the texture from the XZ plane and wrap that
> around the object for gradient z (this is also true for the mandel
> pattern).
> Well that explains it for the sphere, lathe and box objects. But there
> is still a problem with the bicubic_patch object. With gradient x the
> gradient goes in the z-direction. With gradient y it goes in the
> x-direction

Guess I didn't clear up the misunderstanding completely.

With a bi-cubic patch, gradient x doesn't go in the 'z' direction, but
in the 'u' direction.  It just happens that in your scene, the surface
'u' direction is in the world 'z' direction.

The surface of an object is only 2 dimensional, whereas textures in POV
are 3 dimensional.  At some point, only one slice of the 3d texture can
be mapped to the 2d surface coordinates.

You can use the XZ plane of a texture if you want to: you simply have to
rotate the texture so that the XZ plane lies in the XY plane.

  rotate 90*x  // this should do the trick

-Nathan


Post a reply to this message

From: smellenbergh
Subject: Re: uv_mapping bug?
Date: 24 Aug 1999 12:56:16
Message: <1dx1s7x.10gs3ef16q8esuN@dialup428.leuven.skynet.be>
Nathan Kopp <Nat### [at] Koppcom> wrote:

> With a bi-cubic patch, gradient x doesn't go in the 'z' direction, but
> in the 'u' direction.  It just happens that in your scene, the surface
> 'u' direction is in the world 'z' direction.
> 
> The surface of an object is only 2 dimensional, whereas textures in POV
> are 3 dimensional.  At some point, only one slice of the 3d texture can
> be mapped to the 2d surface coordinates.
> 
> You can use the XZ plane of a texture if you want to: you simply have to
> rotate the texture so that the XZ plane lies in the XY plane.
> 
>   rotate 90*x  // this should do the trick
> 
> -Nathan

Thanks for the explanation. It finally makes sense.
Obviously not a bug :-) .

-smellenbergh
-- 
e-mail:sme### [at] skynetbe

http://users.skynet.be/smellenbergh


Post a reply to this message

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