POV-Ray : Newsgroups : povray.advanced-users : Pattern showing *change* in slope : Re: Pattern showing *change* in slope Server Time
3 Jul 2024 06:11:32 EDT (-0400)
  Re: Pattern showing *change* in slope  
From: Tim Attwood
Date: 8 Sep 2009 16:59:01
Message: <4aa6c595$1@news.povray.org>
> Please point me to the part where it describes POV SDL.

The derivative of a surface is really 2D, but here's the
x component. It's just the change in the slope (dx) with
the interval xstep. With an image it really isn't smooth up
close, so you need to make sure that the interval is large 
enough to avoid the artefacts, and small enough to still
get an accurate slope.

camera {
  orthographic
  location <0,0,1>   
  look_at  <0,0,0>
  right 1*x 
  up 1*y
}

// input heightfield image
#declare fn1 = function {pigment {image_map {png "plasma3.png"}}};

// derivative 
#declare xstep = 0.01; 
#declare dx = function { (fn1(x,y,z).grey-fn1(x-xstep,y,z).grey) -
                         (fn1(x+xstep,y,z).grey-fn1(x,y,z).grey) };

// remap to drawable colors
#declare fcolor = function { select( dx(x,y,z)+0.5, 0, 
                             select( dx(x,y,z)-0.5, dx(x,y,z)+0.5,1))};

box { // this box fits exactly in view
  <-0.5, -0.5, 0>, <0.5, 0.5, 0>
  texture {
    pigment { 
       image_map {
          function 200,200 {fcolor(x-0.5,y-0.5,z)}
       }    
    }
  }
}


Post a reply to this message

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