POV-Ray : Newsgroups : povray.general : Using a function in a height_field declaration : Re: Using a function in a height_field declaration Server Time
15 May 2024 05:29:49 EDT (-0400)
  Re: Using a function in a height_field declaration  
From: Kenneth
Date: 15 Feb 2023 13:00:00
Message: <web.63ed1a6b43a1dd889b4924336e066e29@news.povray.org>
[yesbird wrote:]
> This small playground localizes this issue (shifting by Y):
[scene code snip]
>
> I discovered that the height_field function moves the rendered object along
> the Y axis by 1 unit without scaling and this effect increases proportional
> to the scaling amount.

This 'y-movement' that you are seeing-- actually not real movement at all-- is
the typical 'look' and behavior of a height_field when a particular kind of
function is used for it...or even a particular kind of image_map function.

A height_field is just a floating 'shell' surface, which ideally expects to see
function values (or image_map pigment values) that go from 0.0 to 1.0. IF those
values do so, you would see parts of the height_field extend all the way down to
y=0, no matter how large you scaled it afterward. But if the values given to the
function actually start at + 0.4 for example (like a gray rgb 0.4 in an
image_map as it's 'darkest' value), then the function will create the lowest
surface of the HF shell at y=0.4, not y=0  (assuming a final HF y-scale of 1.0).
The shell then appears to float above the surface-- and naturally appears to
move higher as you scale everything up, like Bald Eagle mentioned earlier.

In your example code and image, you're using

#declare FnPoly0_2 = function { pattern {
         granite poly_wave 0.2 scale 0.7
         }
}

then scaling your height_field afterward by <2,2,2>.

I suspect that the poly_wave is adding a positive 'bias' value to the function,
causing *extra* floating of the HF because the function no longer has any zero
values(?). Remove that wave type to see how some parts of the HF then almost
touch y=0, more or less.

A better explanatory example would be to try this function instead-- just an
infinitely-thin surface at y=0.4. It's flat HF 'shell' naturally floats above
the ground (unless you scale y to almost zero!)

#declare FnPoly0_2 = function(y) {x + .4}

then...

#declare HF_Poly0_2_2 = height_field {
     function 10, 10 { FnPoly0_2(y) }
     scale   <2, 2, 2>
     pigment {Red}}

Change the y-scale to see the *apparent* movement.

You will need a non-orthographic camera to see the thin shell; use this one
instead:

camera {
  perspective
  location  <1.5, 2, -3>
  look_at   <.75, .4,  .4>
  right     x*image_width/image_height
   angle 67
}


Post a reply to this message

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