POV-Ray : Newsgroups : povray.general : Using a function in a height_field declaration : Re: Using a function in a height_field declaration Server Time
23 Feb 2024 14:54:59 EST (-0500)
  Re: Using a function in a height_field declaration  
From: Cousin Ricky
Date: 13 Feb 2023 19:45:48
Message: <63ead9bc$1@news.povray.org>
On 2023-02-13 18:15 (-4), yesbird wrote:
> Very interesting !
> Could you share the scene, please ? May be I will use this trick in my POV-Lab

Here is an example with a user-defined function:

---------[BEGIN CODE]----------
#version 3.7;
global_settings { assumed_gamma 1 }

#declare MyFunction = function (x, y)
{ (2 - cos (x * 2*pi) - cos (y * 2*pi)) / 4
}

height_field
{ function 20, 20 { MyFunction (x, y) }
  smooth
  translate -<0.5, 0, 0.5>
  scale <4, 2, 4>
  pigment { green 0.5 }
}

camera
{ location <-2.913, 2.985, -10.873>
  look_at y
  angle 26.2648
}
#default { finish { diffuse 0.6 ambient rgb 0.15005 emission 0 } }
light_source
{ <-5.804, 12.609, -10.054>, rgb 1391125
  fade_power 2 fade_distance 0.0098425
  spotlight point_at y
  radius 38.861 falloff 90 tightness 0.25
}
box { -1, 1 scale <13, 14, 13> pigment { rgb 1 } }
plane
{ y, 0
  pigment { checker rgb 0.05 rgb 1 }
}
----------[END CODE]-----------

You can also define the function directly inside the height_field statement:

height_field
{ function 20, 20 { (2 - cos (x * 2*pi) - cos (y * 2*pi)) / 4 }
  ...
}


Post a reply to this message

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