POV-Ray : Newsgroups : povray.binaries.scene-files : Cartographic fun with eval_pigment - CylMap macro Server Time
2 Sep 2024 00:15:23 EDT (-0400)
  Cartographic fun with eval_pigment - CylMap macro (Message 1 to 1 of 1)  
From: Jörg 'Yadgar' Bleimann
Subject: Cartographic fun with eval_pigment - CylMap macro
Date: 26 Nov 2003 14:13:58
Message: <3FC50A19.46F8937@gmx.de>
High!

Originally, I looked for a method to generate spherical heightfields
with 24-bit vertical resolutions from bitmaps, but
when playing around with eval_pigment, I finally found a way to produce
simple cylindrical maps from pigment patterns
assigned to spheres, which had bothered me for years...

...and here is the macro!

#include "c:\Programme\POV-Ray for Windows v3.5\include\functions.inc"


// Generates simple cylindrical maps out of spherical prodedural pigment
patterns
// Parameters:
// pigm - name of the pigment to be mapped
// rad  - radius of the sphere which surface is to be mapped
// res  - map resolution in degrees per pixel
// w    - width of the map in pixel
// Note: to generate a seamless, undistorted map,
// the camera angle must be atan(w/camera_distance)/(pi/180)*2, and it
is
// recommended to use the orthographic camera. I included such a camera
within the macro,
// in case different settings are needed, a new camera must be defined
// after invoking the macro.

#macro CylMap(pigm, rad, res, w)
  #local a=90;
  #while (a>=-90)
    #local b=0;
    #while (b<360)
      box
      {
        <(b-180)*(w/180), a*((w/2)/90), 0>, <(b+res-180)*(w/180),
(a-res)*((w/2)/90)>
        texture
        {
          pigment { eval_pigment(pigm,
          rad*<sin(b*(pi/180))*cos(a*(pi/180)),
           sin(a*(pi/180)), cos(b*(pi/180))*cos(a*(pi/180))>) }
          finish { ambient 1 }
        }
      }
      #declare b=b+res;
    #end
    #declare a=a-res;
  #end
  camera
  {
    orthographic
    location <0, 0, -10>
    look_at <0, 0, 0>
    up <0, 1, 0>
    right <2, 0, 0>
    angle atan(w/d)/(pi/180)*2
  }
#end

For demo images see p.b.i.!

Next, I'll go for Mercator's projection!

See you in Khyberspace!

Yadgar


Post a reply to this message

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