POV-Ray : Newsgroups : povray.advanced-users : Pattern showing *change* in slope : Re: Pattern showing *change* in slope Server Time
3 Jul 2024 06:14:38 EDT (-0400)
  Re: Pattern showing *change* in slope  
From: Reactor
Date: 28 Aug 2009 18:25:00
Message: <web.4a9858dd38d8f2bb457ff4630@news.povray.org>
SharkD <mik### [at] gmailcom> wrote:

> Thanks! However, all I see is black. Here are the relevant portions of
> my scene.
>
> -Mike
>
> //START
> #local hf_pigment1 = pigment
> {
>  image_map {png "hf_big.png"}
>  rotate x * 180  // flipped
> }
> #local hf_function1 = function {pigment {hf_pigment1}}
>
> #local dv_D =  1/1024;
> #local dv_Sqr =  function(x) {x * x}
> #local dv_G =  function(x,y,z)
> {
>  sqrt
>  (
>   dv_Sqr(hf_function1(x - dv_D,y,z).gray + hf_function1(x +
> dv_D,y,z).gray - 2 * hf_function1(x,y,z).gray)
>   +
>   dv_Sqr(hf_function1(x,y - dv_D,z).gray + hf_function1(x,y -
> dv_D,z).gray - 2 * hf_function1(x,y,z).gray)
>  )
> }


The dy component is being subtracted twice, when it should be subtracted for one
value, then added.


#local dv_G = function(x,y,z)
{
    1/dv_D *
    sqrt
    (
        dv_Sqr(   hf_function1(x - dv_D,y,z).gray
                + hf_function1(x + dv_D,y,z).gray
                - 2 * hf_function1(x,y,z).gray )

       +dv_Sqr(   hf_function1(x,y - dv_D,z).gray
                + hf_function1(x,y + dv_D,z).gray
                - 2 * hf_function1(x,y,z).gray )
    )
}

Also, isn't that the first derivative (i.e. slope), not the second?  The
function is roughly analogous to what you would want to do with, say, the
surface normal of the object (i.e. measure the normal's rate of change), or the
values that are returned from the slope pattern.

If you use this directly as a pigment, you should clip it between 0 and 1.
Personally, I would also probably rotate the image and evaluate in the xz plane
because it is easier for me to think of, but either way will work.


-Reactor


Post a reply to this message

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