POV-Ray : Newsgroups : povray.binaries.images : Funky Granules : Re: Funky Granules Server Time: 23 May 2018 01:25:24 GMT
  Re: Funky Granules  
From: Loki
Date: 14 Apr 2006 14:55:00
Haven't tested it with meshes but I don't expect it would work in all cases
as it requires the use of an inside(obj,vect) test.  I think the POV docs
state that meshes can have an inside if they form a closed shape and you
specify the inside_vector, but I rarely use meshes where I can get away
with SDL, CSG or macros so haven't tried it out.

It basically works by sampling points within the bounding box of an object
with a user-set resolution, testing whether each point is inside the
object, and creating a union of cubes for the inside points.  The same
method can be used with a merge instead of a union if you want to create a
well-behaved transparent version of the same.  Render times are OK, as it's
just a collection of simple primitives, but for high resolution sampling the
parse time (and probably memory usage) can skyrocket.

As I mentioned the method is a but clunky and can no doubt be improved, but
it achieved what I wanted it to so I'm not going to pursue it any further.

Here's the SDL, since it sounds like a couple of people are interested:

#macro GRANULE(GrObj,Res,Text)
  #local MinExt = 0;
  #local MaxExt = 0;
  #local MinCxLim = Res*floor((MinExt.x)/Res);
  #local MinCyLim = Res*floor((MinExt.y)/Res);
  #local MinCzLim = Res*floor((MinExt.z)/Res);
  #local MaxCxLim = Res*ceil((MaxExt.x)/Res);
  #local MaxCyLim = Res*ceil((MaxExt.y)/Res);
  #local MaxCzLim = Res*ceil((MaxExt.z)/Res);
  #local Cz = MinCxLim;
  union {
  #while ( Cz < MaxCzLim )
    #local Cy = MinCxLim;
    #while ( Cy < MaxCyLim )
      #local Cx = MinCxLim;
      #while ( Cx < MaxCxLim )
        #if ( inside(GrObj,<Cx+(Res/2),Cy+(Res/2),Cz+(Res/2)>) )
        object {
          box {
        #local Cx = Cx + Res;
      #local Cy = Cy + Res;
    #local Cz = Cz + Res;
    texture {

Call it by using

where Object and Texture are previously declared, and Resolution is a float
indicating the size of each cube.


Post a reply to this message

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