POV-Ray : Newsgroups : povray.general : Using a function in a height_field declaration Server Time
19 May 2024 14:13:16 EDT (-0400)
  Using a function in a height_field declaration (Message 11 to 20 of 58)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Kenneth
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 07:25:00
Message: <web.63eb79dd43a1dd889b4924336e066e29@news.povray.org>
"yesbird" <nomail@nomail> wrote:
> > Another quick example.
> >
>
> Do not see anything, except "Black Square" by kazimir Malevich:
>

Although you #declared your height_field as HF00, you forgot to actually use it
in the scene. A simple mistake. ;-)

......
#declare HF00 = height_field {
     function 800, 800 { Fn02(x,y,z) }
     smooth
     pigment { color Orange }
     translate <-0.5,0,-0.5>
     scale <2,0.05,2>
}

object{HF00} // or simply  HF00, which also works...sometimes...depending on
// other code that comes before its use. Stick to object{HF00} for now.

----------
By the way: Somewhere in the documentation, it states that when using a function
for a height_field, and creating that function from a pigment/pattern like
granite, the function 'sees' (or uses) only a 2-dimensional 'slice' of the 3-D
pattern-- and in the x/y plane, not the x/z plane as you might imagine.
Otherwise,
           function { pattern { granite scale 0.5 } }

IS fully 3-dimensional.

(I HOPE I have this information correct.)


Post a reply to this message

From: yesbird
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 07:40:00
Message: <web.63eb805843a1dd8868fd655b10800fb2@news.povray.org>
> Although you #declared your height_field as HF00, you forgot to actually use it
> in the scene. A simple mistake. ;-)

Ooo, thanks for correction, the reason was a 'blind' copy/paste ...
Now I see, that relief is really beautiful, will use this function for
landscaping :)
--
YB


Post a reply to this message

From: yesbird
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 08:35:00
Message: <web.63eb8cd543a1dd8868fd655b10800fb2@news.povray.org>
Yet another mystery. In following example 50 is resolution, but how to set range
for x,z ? Only small part of surface is visible.

---------------------------------------------------
#version 3.8;
global_settings { assumed_gamma 1 }

camera
{ location <1,1,1> * 2
  look_at <0,0,0>
  angle 50
}

light_source { <10,10,10>, rgb <1,1,1> }

height_field
{
  function 50, 50 { sin (sqrt (x*x + y*y)) / (sqrt (x*x + y*y)) }
  smooth
  scale <1, 0.3, 1>
  pigment { green 0.8 }
}
---------------------------------------------------
YB


Post a reply to this message

From: Kenneth
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 11:00:00
Message: <web.63ebab6243a1dd889b4924336e066e29@news.povray.org>
"yesbird" <nomail@nomail> wrote:
> Yet another mystery. In following example 50 is resolution, but how to set range
> for x,z ? Only small part of surface is visible.
>

Ah, that's simple too:

By default, a height_field is only 1X1 units square (x and z). That's the way
POV-ray creates it, regardless of the resolution that you give to the function.

So, you would need to simply scale-up the entire height_field afterward-- say,
10X10. BUT, that also requires that you change two other things, to keep the
height_field looking nice and detailed:

1) increase the given resolution of the function. That is, instead of
        function 50,50{...}
it should now be  function 50*10,50*10 {...}. Or 500,500. Of course, this higher
resolution takes longer to process, because there are now more triangles that
have to be created. By the way, the resolution is not the square size of the
height_field, but its 'detail'... the number of triangles.

2) (optional)  If you want the granite pattern to look 'the same size'
as in your original 1X1 render-- but spread over the larger area-- you
will need to either scale-down the original pattern by 1/10, OR use a
function trick to do it afterward:
     #declare HF00 = height_field {
     function 500, 500 { Fn02(x*10,y*10,z*10) }

(Actually, the z does not need this when making a height_field; z is
ignored.)

The interesting thing to notice is that a function's 'scaling' is the opposite
of what would seem normal-- 10 instead of 1/10.


Post a reply to this message

From: Kenneth
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 12:00:00
Message: <web.63ebbdaf43a1dd889b4924336e066e29@news.povray.org>
"yesbird" <nomail@nomail> wrote:
> Yet another mystery. In following example 50 is resolution, but how to set range
> for x,z ? Only small part of surface is visible.
>
> height_field
> {
>   function 50, 50 { sin (sqrt (x*x + y*y)) / (sqrt (x*x + y*y)) }
>   smooth
>   scale <1, 0.3, 1>
>   pigment { green 0.8 }
> }

That's because the sine waves are too 'large' to see in the 1X1 height_field.

Try this function 'scaling' trick for an interesting-- if odd-looking -- result.
(I changed your light_source position to <10,4,10> to make it easier to see, and
gave the function a higher resolution):

function 200, 200 { sin (sqrt (x*x + y*y)*20) / (sqrt (x*x + y*y)*20)}

As you can see, playing around with function values can be quite fun!


Post a reply to this message

From: yesbird
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 12:35:00
Message: <web.63ebc50343a1dd8868fd655b10800fb2@news.povray.org>
Thanks, Kenneth.

Of —Āourse I've tried to play with arguments scaling , but problem in shifting
from origin (please look at attachment). Still can't figure out how it work.

----------------------------------------------------
#version 3.8;
global_settings { assumed_gamma 1 }

camera
{ location <1,1,1> * 2
  look_at <0,-0.5,0>
  angle 50
}

light_source { <10,10,10>, rgb <1,1,1> }

#declare somb = function (x,y) { sin (sqrt (x*x + y*y)) / sqrt (x*x + y*y) };

height_field
{
  function 500, 500 { somb(x*10, y*10) }

  smooth
  scale <1, 0.3, 1>
  pigment { green 0.8 }
}
----------------------------------------------------
YB


Post a reply to this message


Attachments:
Download 'height_field.png' (34 KB)

Preview of image 'height_field.png'
height_field.png


 

From: Bald Eagle
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 13:25:00
Message: <web.63ebd17943a1dd881f9dae3025979125@news.povray.org>
"yesbird" <nomail@nomail> wrote:

> Of сourse I've tried to play with arguments scaling , but problem in shifting
> from origin (please look at attachment). Still can't figure out how it work.

You're using multiplication.division to scale.

You shift it over from the origin in the same way, just with
addition/subtraction.


So where you have (x*x), you would use ( (x+3)*(x+3) ) to shift everything to
the left.  Same works for y with up/down and z with backwards/forwards.

- BW


Post a reply to this message

From: yesbird
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 14:05:00
Message: <web.63ebda3d43a1dd8868fd655b10800fb2@news.povray.org>
> You shift it over from the origin in the same way, just with
> addition/subtraction.

I know, but why I should shift it ? We are looking straight at the origin, peak
should be there, or I am missing something ?
--
YB


Post a reply to this message

From: Kenneth
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 14:15:00
Message: <web.63ebdad843a1dd889b4924336e066e29@news.povray.org>
"yesbird" <nomail@nomail> wrote:
> Thanks, Kenneth.
>
> Of course I've tried to play with arguments scaling , but problem in shifting
> from origin (please look at attachment). Still can't figure out how it work.
>
Your camera was aimed toward -z, which confused me a bit, although I am still
not sure as to what problem you are seeing.

If you mean that the 'center' of the sine wave circle is not 'at the origin' but
at z=1 instead, that could be due to a long-standing problem with how functions
are kind of mirror-reversed when used in a height_field. (OR, maybe due to the
construction of your sin function itself?) I have not tested a function
height_field in awhile, so I am not sure if the odd mirroring problem was fixed
at some time in the past. (I thought it was.)

Anyway, here's my own version of your scene, with a different camera position.
Maybe it will help to clarify your question and my answer ;-)

--------
#version 3.8;
global_settings { assumed_gamma 1 }

camera
{ // location <1,1,1> * 2
  location <1.5,3,-2>
  look_at <.5,.3,0>
  angle 50
}

light_source { <10,10,10>, rgb <1,1,1> }

#declare somb = function (x,y) { sin (sqrt (x*x + y*y)) / sqrt (x*x + y*y) };

height_field
{
  function 500, 500 { somb(x*20, y*20) }
  smooth
  scale <1, 0.3, 1>
  pigment { green 0.8 }
  }

//----------

plane{y,0 pigment{rgb .2}}

//----- origin markers ---
  union{
cylinder{-5*x,5*x,.07 pigment{rgb .5*<0,1,1>}}
cylinder{-3*y,3*y,.07 translate .00001*z pigment{rgb <.4,1,.4>}}
cylinder{-5*z,5*z,.07 translate .00001*x pigment{rgb <.6,.6,1>}}

text {
    ttf "timrom.ttf" "x"
    .2, 0
    translate -.2*z
    scale 1
    rotate 90*x
    translate <5.5,0,0>
    pigment{rgb 1}
}

text {
    ttf "timrom.ttf" "y"
    .2, 0
    scale 1
    translate <0,3.5,0>
    pigment{rgb 1}
}

text {
    ttf "timrom.ttf" "z"
    .2, 0
    translate -.2*z
    scale 1
    rotate 90*x
    translate <0,0,5.5>
    pigment{rgb 1}
}
 scale .3
 no_shadow
 }


Post a reply to this message


Attachments:
Download 'temp test from newsgroup.jpg' (22 KB)

Preview of image 'temp test from newsgroup.jpg'
temp test from newsgroup.jpg


 

From: yesbird
Subject: Re: Using a function in a height_field declaration
Date: 14 Feb 2023 14:30:00
Message: <web.63ebe0c443a1dd8868fd655b10800fb2@news.povray.org>
> If you mean that the 'center' of the sine wave circle is not 'at the origin'

Exactly, this was a reason of confusion, now everything in on the "place",
almost ... :).
Thanks for beautiful illustration.
--
YB


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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