POV-Ray : Newsgroups : povray.bugreports : CLipka: Possible BUG Found!!! :-) : Re: CLipka: Possible BUG Found!!! :-) Server Time: 20 Jul 2019 23:59:29 GMT
  Re: CLipka: Possible BUG Found!!! :-)  
From: Kenneth
Date: 13 Feb 2016 05:20:01
Sven Littkowski <jam### [at] yahoocom> wrote:

> But using now a heightfield, I get an error message.

The HF_Cylinder macro can be a bit daunting to work with when it uses an
image_map as a function. I re-worked your code, to give you a good introduction
to it. (Also take a look at 'Function Image' in the documentation.)

For everything to work correctly, start with a 'standard' cylinder size (1.0
length, with radius .5, not 1.0). To have the proper 'equalized' x and y
triangle resolutions in the heightfield (no squashing or stretching of
triangles), the macro's x-resolution needs to be int(pi)*res, not just res. You
can see what I mean by reducing the resolution to 10,10, to see the triangle

To reproduce your image_map correctly on the cylinder, the image itself needs to
have a width-to-height ratio of pi:1.0 (using the appropriate image resolution
that you want, of course.)

--- code ---
#declare Fn_1 =
  image_map{jpeg "your_image.jpg" once interpolate 2}
  // this image needs to be pi-units wide by 1.0 tall, NOT square.

// You can use these two modifiers to 'reverse' the imagery, to see it
// correctly on the INSIDE. HOWEVER, this does not reverse the *depth* of
// the heightfield. The only way to do that (that I know of) is to invert
// the image_map's colors (in Photoshop, for example.)
                //scale <-1,1,1>
                //translate <1,0,0>

 HF_Cylinder( function{Fn_1(x,y*1.7,z).gray}, // *Needs* the function 'wrapper'
                 1, // UseUVheight:  0 or 1 // ON-- IMPORTANT
                 0, // UseUVtexture: 0 or 1
 <int(100*pi),100>, // Resolution.
                 1, // Smooth: 0 or 1
                "", // FileName, ""=no file,
           <0,0,0>, // EndA,
         <0,1.7,0>, // EndB-- if this y-value is different from 1.0,
                    // change the function's y-value above to compensate.
                .5, // Radius. Keep this at .5 for 1:1 reproduction of
                    // the image_map around the circumference.
                0.3 // Depth
             ) //-------------------------
scale < 0.58, 0.67, 0.58 >
rotate < 90.0, 0.0, 0.0 >
scale < 1500.0, 1500.0, 2500.0 >

Unlike a regular height_field, the image_map eats INTO the cylinder (but with
the correct 'positive' grayscale height values.) For example, if your image_map
has white values that are 1.0 in brightness, that part of the corresponding
cylindrical heightfield will by at the outer radius of the cylinder surface;
darker image colors will eat *into* the cylinder.

The HF_Cylinder macro reproduces the image_map correctly on the OUTSIDE, not the
inside. To get it to look correct on the INSIDE instead, you can 'flip' the
image left-to-right in the image_map's code as I've mentioned, OR by making the
x-value in function(x,y,z) into (-x + 1). This along with a color-INVERTED
image_map will give you the correct heightfield INSIDE the cylinder.

If you want to MAKE the cylinder taller than 1.0 (EndB above), you need to
compensate for that by increasing the triangle Y-resolution.

Have fun experimenting!

Post a reply to this message

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