POV-Ray : Newsgroups : povray.binaries.images : uv mapping uv-mappable objects from scratch : Re: uv mapping uv-mappable objects from scratch Server Time
18 Apr 2024 18:53:48 EDT (-0400)
  Re: uv mapping uv-mappable objects from scratch  
From: Bald Eagle
Date: 21 Aug 2019 06:35:00
Message: <web.5d5d1d64236c7e684eec112d0@news.povray.org>
"Mr" <mauriceraybaud [at] hotmail dot fr>> wrote:


> Hi, to make sure I understand correctly, this is pov code only, no bitmap? did
> you post the scene somewhere?

Hi Maurice,

The image data comes from png that I made in POV-Ray a while back (I believe I
was trying to recreate TOK's NURBS object....)

IIRC, that's not really relevant - you can create the same png "in memory"
without saving it to a render, and use that as you would any other.

But the code to _uv_map_ the image data onto the sphere is all SDL, not a
mechanism in the source code.   It's just a simple sphere - I haven't had a
chance to elaborate on this any.


It's dirt simple, but it of course took me WAY too long to see the path to
success.  But that IS the path to success, now, isn't it - persistence.




#version 3.8;
global_settings {assumed_gamma 1.0 }
#include "colors.inc"
#include "functions.inc"
#include "math.inc"


camera {
 //location <0, 40, 2.5>
 location <1.0, 0, -3.5>
 right x*image_width/image_height
 up y
 look_at <1.0, 0, 0>
 //look_at <0, 0, 0.01>
}

light_source {<1, 0, -10> rgb 1}
background {Gray10}

#declare U = function (X, Y, Z) {(0.5 + atan2 (N(Z, X,Y,Z), N(X, X,Y,Z))/(2*pi)
)}
#declare V = function (X, Y, Z) {(0.5 + asin(N(Y, X,Y,Z))/pi)}

#declare USphere = function (X, Y, Z) { U (X, Y, Z)}
#declare VSphere = function (X, Y, Z) { V (X, Y, Z)}

#declare Image = pigment {image_map {png "Grid.png" once}}
#declare ImageMap = function {pigment {Image}}

#declare RGBPigment =

   pigment {
          average
          pigment_map {
              [
                  function { ImageMap (USphere (x,y,z), VSphere (x,y,z), 0).red
}
                  color_map {
                      [ 0 red 0 ]
                      [ 1 red 3 ]
                  }
              ]
              [
                  function { ImageMap (USphere (x,y,z), VSphere (x,y,z),
0).green }
                  color_map {
                      [ 0 green 0 ]
                      [ 1 green 3 ]
                  }
              ]
              [
                  function { ImageMap (USphere (x,y,z), VSphere (x,y,z), 0).blue
}
                  color_map {
                      [ 0 blue 0 ]
                      [ 1 blue 3 ]
                  }
              ]

    } // end pigment map
   } // end pigment

union {
sphere {0, 0.5 texture {pigment {RGBPigment} finish {specular 0.4}} rotate y*0
translate -x*0.5}
sphere {0, 0.5 texture {pigment {RGBPigment} finish {specular 0.4}} rotate y*90
translate x*0.5}
sphere {0, 0.5 texture {pigment {RGBPigment} finish {specular 0.4}} rotate y*180
translate x*1.5}
sphere {0, 0.5 texture {pigment {RGBPigment} finish {specular 0.4}} rotate y*270
translate x*2.5}
translate -y*0.5
}
box {0, 1 scale <1, 1, 0.01> texture {pigment {Image} finish {specular 0.4}}
translate <0.5, 0.25, 0>}


Post a reply to this message

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