POV-Ray : Newsgroups : povray.newusers : Sponge : Re: Sponge Server Time
29 Jul 2024 00:23:01 EDT (-0400)
  Re: Sponge  
From: Archpawn
Date: 24 Dec 2007 18:35:00
Message: <web.477040abd68f7f9f9c37dbc40@news.povray.org>
If you're interested about my second method of making a sponge, here it is:



#declare S=seed(0);
light_source
{
   <3,5,10>
   rgb 2
}
camera
{
   location <3,5,10>
   look_at 0
   angle 30
}
#declare bubtotal=1000;
#declare bubsize=function(bub){exp(bub/bubtotal)/10}  //bubsize is radius
#declare bubble=0;
#declare bubpos=array[bubtotal]
#declare bubgrid=array[bubtotal][bubtotal]
#while(bubble<bubtotal)
   #declare xarea=(1+2*bubsize(bubble))*(4+2*bubsize(bubble));
   #declare yarea=(2)*(4+2*bubsize(bubble));
   #declare zarea=2;
   #switch(rand(S)*(xarea+yarea+zarea))
      #range(0,xarea)
         #declare
bubpos[bubble]=<1+(2*rand(S)-1)*bubsize(bubble),(2*rand(S)-1)*(.5+bubsize(bubble)),(2*rand(S)-1)*(2+bubsize(bubble))>;
      #break
      #range(xarea,xarea+yarea)
         #declare
bubpos[bubble]=<(2*rand(S)-1)*1-bubsize(bubble),.5+(2*rand(S)-1)*bubsize(bubble),(2*rand(S)-1)*(2+bubsize(bubble))>;
      #break
      #range(xarea+yarea,xarea+yarea+zarea)
         #declare
bubpos[bubble]=<(2*rand(S)-1)*1-bubsize(bubble),(2*rand(S)-1)*.5-bubsize(bubble),2+(2*rand(S)-1)*bubsize(bubble)>;
      #break
   #end
   #declare bubble=bubble+1;
#end
union{
#declare bubble=0;
#while(bubble<bubtotal)
   sphere{bubpos[bubble],bubsize(bubble)
   #declare bubble2=bubble+1;
   #while(bubble2<bubtotal)

#if(vlength(bubpos[bubble]-bubpos[bubble2])<bubsize(bubble)+bubsize(bubble2))
         clipped_by{sphere{bubpos[bubble2],bubsize(bubble2) inverse}}
      #end
      #declare bubble2=bubble2+1;
   #end
   }
   #declare bubble=bubble+1;
#end
pigment{color rgb <1,.9,.2>}
clipped_by{box{<1,.5,2>,-<1,.5,2>}}
}



If you're going to make something based on taking spheres out of a box, I'd
recommend using a modified version of this, as on of the things I did to speed
up render time was to make it only draw spheres along the surface. By the way,
despite the speeding up thing there are tens of millions of tokens, so don't
think it doesn't work.

I think I got it to work with the crackle pattern. How's this one?



light_source
{
   <3,5,10>
   rgb 2
}
camera
{
   location <3,5,10>
   look_at 0
   angle 30
}
#declare F=function{pigment{
  crackle
  turbulence 0
  color_map { [0 rgb .2] [1 rgb 0] }
  scale 0.02
  }
}
intersection{
   isosurface
   {
      #declare asdf = 25;

function{max(f_noise3d(asdf*x,asdf*y,asdf*z),f_noise3d(asdf*(x+1),asdf*y,asdf*z),f_noise3d(asdf*(x+4)/2,asdf*y/2,asdf*z
/2))-.7}
      contained_by{box{<1,.5,2>*1.00001,-<1,.5,2>*1.00001}}
      max_gradient 4.631
   }
   box{
      <1,.5,2>,-<1,.5,2>
      texture{
         pigment{color rgb <1,1,.5>}
         normal{function{F(x,y,z).red}}
      }
   }
   pigment{color rgb <1,1,.5>}}
}


Post a reply to this message

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