POV-Ray : Newsgroups : povray.newusers : Really weird image mapping results : Re: Really weird image mapping results Server Time
3 May 2024 01:08:30 EDT (-0400)
  Re: Really weird image mapping results  
From: Alain
Date: 12 Oct 2014 14:14:26
Message: <543ac502@news.povray.org>

> I've been playing around with mapping a texture onto half of an oblate spheroid,
> and I've gotten really weird results.
>
> Here's what I get:
> The image seems to be half-scaled compared to the object it gets mapped onto.
> The image has a weird "doubling" effect. (top right)
> When I display the same hemi-spheroid as a guide, my image-mapped object
> disappears, (lower right)
> but when I rotate them at different angles, I can see the image map above, and
> through the green below. (lower left)
>
> Also interesting is the "chopping" going on between the 4 views.
> It's like there's differencing going on between things that should be
> independent.
>
> .... I think the trouble may be due to the nut behind my keyboard ...
>
> //#######################################################################
> Image file:
>
http://news.povray.org/*/attachment/%3Cweb.54375641cbb3d8155e7df57c0%40news.povray.org%3E/medallion1.png
> //#######################################################################
>
> #version 3.7;
> global_settings{ assumed_gamma 1.0 }
>
....
> #declare Feet = 12;
>
> #ifdef (SDL)
>   // do nothing
> #else
>
//--------------------------------------------------------------------------------------------------------<<<<
>
//--------------------------------------------------------------------------------------------------------<<<<
> //------------------------------------------------------------- Camera_Position,
> Camera_look_at, Camera_Angle
> #declare Camera_Number = 0;
>
//--------------------------------------------------------------------------------------------------------<<<<
>
//--------------------------------------------------------------------------------------------------------<<<<
...
>
//-------------------------------------------------------------------------------------------------------<<<<
>
//-------------------------------------------------------------------------------------------------------<<<<
> camera { location Camera_Position
>          right    x*image_width/image_height
>          angle    Camera_Angle
>          look_at  Camera_Look_At
>   }
...
>
> #declare Medallion =
> texture {
>   pigment {//uv_mapping
>    image_map {
>    png "Medallion1.png"
>    once
>    //map_type 1    // planar
>    //interpolate 0
>    //once
>    //texture { pigment {Red} }
>    //texture { Gold_Metal }
>    }
>   } //rotate x*90 //scale 0.25 translate <1, 0, 0>
> }

The image is mapped from <0,0> to <1,1> (the X-Y plane) and extend along 
the Z axis to infinity.

>
> #declare Gold = texture {T_Gold_2A finish {phong 1 metallic reflection {0.2}} }
>
> #declare Sine   = function (x,y) {sin (y/sqrt (pow (x,2) + pow (y,2)) )}
> #declare Circle = function (x,y) { 1- (pow (x,2) + pow (y,2)) }

This should be:
#declare Circle = function (x,y) { 1- sqrt(pow (x,2) + pow (y,2)) }

>
>
> //##############################################################################
> #declare Hemisphere =
> union {
> difference {
>   sphere {0, 1 }
>   box {0, 1 translate <-.5, -.5, 0> scale 2}
>   texture {Medallion translate -0.5}
>   scale <18, 18, 1.5>
> }

This half sphere extend toward -Y and it's flat part is on the X-Z plane
The image is mapped relative to the X-Y plane.
You need to rotate the image_map +90*x, translate it by -0.5 along the X 
axis and scale it by 2.

> cylinder {<0,0,0>, <10, 0, 0> 0.125}
> cylinder {<0,0,0>, <0, 10, 0> 0.125}
> cylinder {<0,0,0>, <0, 0, 10> 0.125}
> }
Reference axis, beter to colour them according to their directions: Red 
for the X, Green for the Y and Blue for the Z are standard.

>
>
>
> #declare Hemispheroid =
> difference {
>   sphere {0, 1}
>   box {0, 1 translate <-.5, -.5, 0> scale 2}
>   scale <18, 18, 1.5>
>   pigment {Green filter 0.99}
> }

Coincident with the previous hemisphere. Make the sphere larger by a 
*very* small amount: sphere{0, 1.00001}
Translate the box a tiny bit lower: box {0, 1 translate <-.5, -.50001, 
0> scale 2}

Those changes will make sure that this object is realy visible.

>
> object {Hemisphere   translate <-15, 10, 0> }
> //object {Hemispheroid translate <-15, 10, 0>}
>
> object {Hemisphere   rotate x*70 translate <15, 10, 0> }
> //object {Hemispheroid translate <15, 10, 0>}
>
> object {Hemisphere   translate <-15, -10, 0> }
> object {Hemispheroid rotate x*70 translate <-15, -10, 0>}
>
> object {Hemisphere   translate <15, -10, 0> }
> object {Hemispheroid translate <15, -10, 0>}
>
>
> //##############################################################################
> #declare Quarter =
> height_field {
>   function 200,200 {
>    pattern {
>     function {Circle (x, y)}
>     // waves scale 0.1
>     // turbulence 0.8
>    }
>   }
>   translate -z*1
>   /*pigment{ gradient <0,1,0>
>   color_map{  [0   color rgb <0, 0, 0>         ]  //Black
>     [1.0 color rgb <1, 1, 1>         ]  //White
>    }
>   }*/
>   scale <10, 5, 10> * 0.5
>   rotate x * 0
>     }
>
> #declare MedallionFunction =
> difference {
>   union {
>    object {Quarter}
>    object {Quarter rotate y*90}
>    object {Quarter rotate y*180}
>    object {Quarter rotate y*270}
>    }
>   sphere {0, 1 scale 2 inverse}
>   rotate x*90
>   texture {Medallion}
> }
>
>


Post a reply to this message

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