POV-Ray : Newsgroups : povray.binaries.images : Copying pigments with crackle (124k jpg) : Re: Copying pigments with crackle (124k jpg) Server Time
1 Aug 2024 12:20:51 EDT (-0400)
  Re: Copying pigments with crackle (124k jpg)  
From: stbenge
Date: 29 Jul 2008 16:34:06
Message: <488f7ebe@news.povray.org>
Blue Herring wrote:
> This is really nifty, I'm trying to bend my brain around how it works :)

To be honest, I only have a vague idea myself, though I still managed to 
get what I was after... Perhaps my subconscious mind knows all the 
details...

> This reminds me of something I ran into a while back that Rune Johansen 
> did with pigments, though I think the methods are different: 
> http://runevision.com/3d/povgoodies/#216

Yeah, that's not the same at all. I think those patterns may use 
functions as well, or possibly pattern warps or looped pigment_maps.

> I haven't tried it, but it might be slightly faster if you eliminate 
> some interim pigments and some of the grayscale conversions, and return 
> the function:

Thanks for pointing that out! Here's an updated version of the macro:

#macro pcc(pgmt, Mod)
  #local pgmt2 =
   function{
    pattern{
     pigment_pattern {pgmt}
    }
   }
  #local pg1=
   function{
    pattern{
     crackle form x*.75
    }
   }
  function{
   pgmt2(
    (pow(pg1(x+Mod,y,z),2)-pow(pg1(x-Mod,y,z),2))/(Mod*1.2),
    (pow(pg1(x,y+Mod,z),2)-pow(pg1(x,y-Mod,z),2))/(Mod*1.2),
    (pow(pg1(x,y,z+Mod),2)-pow(pg1(x,y,z-Mod),2))/(Mod*1.2)
   )
  }
#end

It now works in all three dimensions, and the underlying crackle pattern 
is scaled 100%, allowing you to do stuff like this more easily:

plane{z,0
  pigment{
   crackle
   pigment_map{
    [0 rgb 0]
    [.5
     pcc(
      pigment{
       spiral1 1 sine_wave scale 0.75
      }
      ,.00001
     )
     color_map{[0 rgb<0,.3,.4>][1 rgb<.5,1,.75>]}
    ]
   }
  }
}

Sam


Post a reply to this message

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