POV-Ray : Newsgroups : povray.binaries.images : Re: blurring bump map image in pov ? : Re: blurring bump map image in pov ? Server Time
10 Aug 2024 13:18:47 EDT (-0400)
  Re: blurring bump map image in pov ?  
From: Shay
Date: 30 Jul 2004 13:39:37
Message: <410a87d9$1@news.povray.org>
Jaap wrote:

You're trying it the hard way. Pov can blur very well just by adding 
together several faint copies of a function, each translated in a 
different direction.

Here's a little macro to "blur" a function. Probably a better way to do 
it, but this works. This macro builds the function as a string and then 
includes the string. See the parse_string.tmp file this will create to 
get a look at the function.

#macro Blur_Function ( OLD_FUNC, NEW_FUNC, OFFSET, SAMPLES )
   #include "strings.inc"
   #local String = concat (
     "#declare ",
     NEW_FUNC,
     " = function {\n",
     #local c0 = 0; #while ( c0 < SAMPLES )
       #local Sample = vrotate(<0,OFFSET,0>,z*c0/SAMPLES*360);
       OLD_FUNC,
       "(x+",
       str(Sample.x,0,-1),
       ",y+",
       str(Sample.y,0,-1),
       ",z)/SAMPLES +\n"
     #local c0 = c0 + 1; #end
     "0}" // to catch the trailing +
   )
   Parse_String ( String )
#end

// NWE_FUNC and OLD_FUNC will be strings, so
// the usage will be something like this

#declare Unblurred = function{pattern{object{ some text }}}

// Then blur the function
Blur_Function ( "Unblurred", "SmallBlur", .025, 10 )
// now blur it again
Blur_Function ( "SmallBlur", "LargeBlur", .01, 10 )
// you can use as many as 34 samples with this.

  -Shay


Post a reply to this message

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