POV-Ray : Newsgroups : povray.advanced-users : Pattern showing *change* in slope : Re: Pattern showing *change* in slope Server Time
1 Jul 2024 06:11:35 EDT (-0400)
  Re: Pattern showing *change* in slope  
From: clipka
Date: 28 Aug 2009 07:25:22
Message: <4a97bea2$1@news.povray.org>
SharkD schrieb:
> How can I create a pattern that shows the *change* in slope of a 
> heightfield. I.e., brighter where the "curvature" is greater.

You can create this from the image you use for the height field

To begin with, make a pigment from the image; make from that a function F.

Now, create a function G computing the curvature from five function 
values from F, spaced apart by (at least) 1/BITMAP_SIZE, to compute the 
"difference in difference" both vertically and horizontally:

#declare D = 1/BITMAP_SIZE; // insert actual size of your bitmap here
#declare Sqr = function(x) { x*x }
#declare G = function(x,y,z) {
   sqrt(
     Sqr( F(x-D,y,z) + F(x+D,y,z) - 2*F(x,y,z) ) // squared curvature X
     Sqr( F(x,y-D,z) + F(x,y-D,z) - 2*F(x,y,z) ) // squared curvature Y
   )
}

finally, apply this function as a pattern to your height field.


Post a reply to this message

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