POV-Ray : Newsgroups : povray.general : macro or include file to make rocks ?? : Re: macro or include file to make rocks ?? Server Time
31 Jul 2024 00:32:20 EDT (-0400)
  Re: macro or include file to make rocks ??  
From: Trevor G Quayle
Date: 26 Jan 2008 10:10:01
Message: <web.479b4c4124083e7c2ae8612c0@news.povray.org>
"Trevor G Quayle" <Tin### [at] hotmailcom> wrote:
> john <joh### [at] worldcom> wrote:
> > I want to make a base for a sculpture.
> >
> > I want to have a stone with the top surface polished and the sides
> > very rough as if they had just been excavated from a quarry.
> >
> > Does anyone know of a macro or include file that can generate
> > something like this.  Ideally I would like to be able to define the
> > dimensions and also the roughness of the vertical surfaces while
> > leaving the top flat and polished.
> >
> > John
>
> Try intersecting 4 heightfields (for the sides) with a box (for the top and
> bottom).  You can apply whatever pattern/scale to the heightfields to get the
> look you want.  I have a macro I made up somewhere that does just this with all
> six sides that could be modified easily.  I'll see if I can dig it up.  It
> shouldn't be too difficult to figure out on your own if you know how to use
> heightfields with internal patterns or functions.
>
> -tgq

Okay, I modified my macro.  Hope it makes sense to you, there are a few
variables.

f_stone is a predeclared function pattern for the rouhg surface.  I combined
three patterns to varying proportions (f_1, f_2, f_3).

CRN1,CRN2: corners of the overall box that the stone is made from.
BScal: scale of the bump pattern, this keeps the bumps the same size when the
size of stone is changed.
Dpth: depth of the bump pattern, as with BScal, independent of stone size.
RES: heightfield resolution (make larger for good renders, smaller for fast
renders
Smth: turn on/off heightfield smoothing (true/false)

Hope this is some use for you.  Let me know if you have any questions about it.

//START
#declare f_1= function{pattern{bumps   scale 0.5}} #declare f1=0.10*1;
#declare f_2= function{pattern{granite scale 1.0}} #declare f2=0.03*1;
#declare f_3= function{pattern{dents   scale 0.1}} #declare f3=0.02*1;

#declare f_stone =function (x,y,z,i,j,k,B,Dpth) {
  1-Dpth*( ((f_1(x*i/B,y*k/B,z)*f1 + f_2(x*i/B,y*k/B,z)*f2 +
f_3(x*i/B,y*k/B,z)*f3)/(f1+f2+f3) -0.5) + 0.5 )/j
}

#declare SBRND=seed(1);

#macro StoneBlock (CRN1,CRN2,BScal,Dpth,RES,Smth)
  #local ZX=RES/(RES-2);
  #macro HF(xx,yy,zz,OS)
    #local HF1=
      height_field{
        function RES,RES {pattern{ function {
          f_stone((2*x-1)*ZX,(2*y-1)*ZX,OS*1000,xx,yy,zz,BScal,Dpth)
        }
       }
      }
      #if (Smth) smooth #end
    }
    object{HF1 translate y*(1-max_extent(HF1).y) translate -1/2 scale
<ZX*xx,yy,ZX*zz>}
  #end
  #local Siz=CRN2-CRN1;
  intersection{
    #local xx=Siz.x;
    #local yy=Siz.y;
    #local zz=Siz.z;
    //object{HF(xx,yy,zz,rand(SBRND)) rotate x*0}  //removed for flat top
    //object{HF(xx,yy,zz,rand(SBRND)) rotate x*180}//removed for flat bottom
    object{HF(xx,zz,yy,rand(SBRND)) rotate x*90}
    object{HF(xx,zz,yy,rand(SBRND)) rotate x*270}
    object{HF(yy,xx,zz,rand(SBRND)) rotate z*90}
    object{HF(yy,xx,zz,rand(SBRND)) rotate -z*90}
    box{<-xx/2,-yy/2,-zz/2><xx/2,yy/2,zz/2>}
    translate Siz/2+CRN1
    bounded_by{box{CRN1,CRN2}}
  }
#end

object{StoneBlock(<-1,-1/2,-1>*30,<1,1/2,1>*30,100,4,100,false) pigment{rgb 1}
translate y*20}
//END


Post a reply to this message

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