POV-Ray : Newsgroups : povray.binaries.images : Funky Granules Server Time
30 Nov 2026 01:15:33 EST (-0500)
  Funky Granules (Message 1 to 17 of 17)  
From: Loki
Subject: Funky Granules
Date: 14 Apr 2006 06:10:01
Message: <web.443f748e848f4a273d13d5660@news.povray.org>
Hi all,

Just a pic demonstrating a macro I knocked up this morning.  It takes any
object that has a defined interior and finite bounding box and
'granularizes' it into blocks of a user defined resolution.  This example,
in keeping with the RSOCP kind of idea, was a granular version of a simple
difference of two spheres.

If anyone is interested in the code I can post it, though in its present
form it is pretty rough and ready.  It does what I needed it to, but if
anyone want to inprove on it feel free.

(BTW, I should apologise to Slime, if he still posts on here, for abandoning
our POV-pong match ages ago - things got very busy for me very quickly and
I've been away from POV for a while.)

L
-


Post a reply to this message


Attachments:
Download 'granule.jpg' (152 KB)

Preview of image 'granule.jpg'
granule.jpg


 

From: Bob H
Subject: Re: Funky Granules
Date: 14 Apr 2006 07:18:31
Message: <443f8507$1@news.povray.org>
Not sure how you could have done this, it's a fascinating thing. I'd think 
it were done in a non-SDL way if you hadn't said "macro".


Post a reply to this message

From: Tim Cook
Subject: Re: Funky Granules
Date: 14 Apr 2006 09:31:24
Message: <443fa42c$1@news.povray.org>
mmmm, Lego-sculpturizer

it work with meshes?

-- 
Tim Cook
http://home.bellsouth.net/p/PWP-empyrean

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

From: Loki
Subject: Re: Funky Granules
Date: 14 Apr 2006 10:55:00
Message: <web.443fb66aa9f0c1853e48c3860@news.povray.org>
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;
  Extents(GrObj,MinExt,MaxExt)
  #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 {
            <Cx,Cy,Cz>-(Res/100),<Cx,Cy,Cz>+(Res*1.01)
          }
        }
        #end
        #local Cx = Cx + Res;
      #end
      #local Cy = Cy + Res;
    #end
    #local Cz = Cz + Res;
  #end
    texture {
      Text
    }
  }
#end


Call it by using
GRANULE(Object,Resolution,Texture)

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

L
-


Post a reply to this message

From: kurtz le pirate
Subject: Re: Funky Granules - granules.jpg (1/1)
Date: 14 Apr 2006 13:51:52
Message: <kurtzlepirate-EE6B85.19514814042006@news.povray.org>
In article <web.443fb66aa9f0c1853e48c3860@news.povray.org>,
 "Loki" <nomail@nomail> wrote:

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


yes, a funny macro... and so simple ! great work loki ;)



-- 
klp


Post a reply to this message


Attachments:
Download 'granules.jpg' (52 KB)

Preview of image 'granules.jpg'
granules.jpg


 

From: Mike Kost
Subject: Re: Funky Granules
Date: 14 Apr 2006 16:20:36
Message: <44400413@news.povray.org>
Tim Cook wrote:
> mmmm, Lego-sculpturizer
> 
> it work with meshes?
> 

Why not take it all the way to it's silly conclusion...

Thanks for posting the SDL, Loki!

Mike
--
http://povray.tashcorp.net


Post a reply to this message


Attachments:
Download 'legos.png' (80 KB)

Preview of image 'legos.png'
legos.png


 

From: DJ Wiza
Subject: Re: Funky Granules
Date: 15 Apr 2006 03:54:33
Message: <4440a6b9@news.povray.org>
Awhile ago, I made a macro similar to this one, but it was based on a 
function.  It was more similar to an isosurface that approximated it 
with cubes.

I wonder what kind of result I could get if I used a blob with spheres...

-DJ

Loki wrote:
> 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;
>   Extents(GrObj,MinExt,MaxExt)
>   #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 {
>             <Cx,Cy,Cz>-(Res/100),<Cx,Cy,Cz>+(Res*1.01)
>           }
>         }
>         #end
>         #local Cx = Cx + Res;
>       #end
>       #local Cy = Cy + Res;
>     #end
>     #local Cz = Cz + Res;
>   #end
>     texture {
>       Text
>     }
>   }
> #end
> 
> 
> Call it by using
> GRANULE(Object,Resolution,Texture)
> 
> where Object and Texture are previously declared, and Resolution is a float
> indicating the size of each cube.
> 
> L
> -
> 
>


Post a reply to this message

From: Tim Nikias
Subject: Re: Funky Granules
Date: 15 Apr 2006 07:46:15
Message: <4440dd07@news.povray.org>
> 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.

Just a note for those interested in using this on meshes:
If you've got a well-defined mesh, with which I mean it has no coincident
surfaces and no holes (which is also known as waterproof), you'd just need a
macro which'll shoot a ray in some random direction. When it hits a surface
of the mesh, continue from there and count how many times you hit a surface
on a mesh whilst travelling along the ray to the outside of the mesh. If the
resulting number is uneven, the original starting point is inside the mesh,
otherwise it's outside.
This even works for multiple mesh objects that intersect, but like I said,
no coincident surfaces and the meshes all have to be completely closed for
the counting to work properly.

I've done this for various things, especially my Liquid Surface Simulation
Macros to get the water to properly interact with meshes.

Regards,
Tim

-- 
aka "Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Bob H
Subject: Re: Funky Granules
Date: 15 Apr 2006 09:32:11
Message: <4440f5db@news.povray.org>
Ah yes, LEGO blocks. Makes perfect sense to be used like that.

BTW, if anyone else is wondering, be sure to #include "shapes.inc" for 
Extents() to work in that macro. Another thanks to Loki for sharing this.

And here's the logo put into the logo.


Post a reply to this message


Attachments:
Download 'povlogospovlogo.jpg' (32 KB)

Preview of image 'povlogospovlogo.jpg'
povlogospovlogo.jpg


 

From: Anthony D'Agostino
Subject: Re: Funky Granules
Date: 15 Apr 2006 15:42:12
Message: <44414c94$1@news.povray.org>
Thanks for posting the macro. Nice render! What kind of light setup did you
use? GI, HDRI, or area light?


Post a reply to this message

From: Loki
Subject: Re: Funky Granules
Date: 16 Apr 2006 04:20:01
Message: <web.4441fd94a9f0c18547cd66460@news.povray.org>
"Anthony D'Agostino" <gam### [at] contastnet> wrote:
> Thanks for posting the macro. Nice render! What kind of light setup did you
> use? GI, HDRI, or area light?

Were you referreing to my original pic?  It's radiosity-only lighting.  I
rarely use light_sources any more.

L
-


Post a reply to this message

From: Loki
Subject: Re: Funky Granules
Date: 16 Apr 2006 08:10:01
Message: <web.444232f3a9f0c18547cd66460@news.povray.org>
Just another pic along the same lines, this one heading closer to what I
actually wanted the macro for.  This is a granularized version of an
isosurface of a granite pigment, again lit with radiosity only.  It looks a
bit 'busy' on the eye, but a bit of focal blur would no doubt clam that
down.  Was just a quick render though.

L
-


Post a reply to this message


Attachments:
Download 'granule landscape.jpg' (163 KB)

Preview of image 'granule landscape.jpg'
granule landscape.jpg


 

From: kurtz le pirate
Subject: Re: Funky Granules - granulesHF.jpg (1/1)
Date: 16 Apr 2006 10:59:06
Message: <kurtzlepirate-F0AB93.16590116042006@news.povray.org>



Post a reply to this message


Attachments:
Download 'granules.jpg' (1 KB) Download 'granuleshf.jpg' (55 KB)

Preview of image 'granuleshf.jpg'
granuleshf.jpg


 

From: Anthony D'Agostino
Subject: Re: Funky Granules
Date: 16 Apr 2006 18:45:46
Message: <4442c91a$1@news.povray.org>
> Were you referreing to my original pic?  It's radiosity-only lighting.

Yes, the csg sphere on the checkered floor. I've been trying to do the same 
thing with a python script, blender, and yafray. I haven't used POV in a 
while. Is "radiosity-only lighting" some sort of Ambient Occlusion? In other 
words, a very large sky-dome surrounds the entire scene and the object is 
lit based on how much each point on the surface can see the sky?


Post a reply to this message

From: Anthony D'Agostino
Subject: Re: Funky Granules
Date: 16 Apr 2006 18:49:06
Message: <4442c9e2$1@news.povray.org>
> Just another pic along the same lines, this one heading closer to what I
> actually wanted the macro for.  This is a granularized version of an
> isosurface of a granite pigment, again lit with radiosity only.  It looks 
> a

Radiosity only? I can see a very slight reddish hue on the left side of the 
cubes. Is this from a gradient-colored sky?


Post a reply to this message

From: Loki
Subject: Re: Funky Granules
Date: 17 Apr 2006 07:10:01
Message: <web.444376c1a9f0c185d79451f00@news.povray.org>
> Radiosity only? I can see a very slight reddish hue on the left side of the
> cubes. Is this from a gradient-colored sky?

Yes, I light things like this quite a lot.  It can be time consuming to
render, and takes a lot of tweaking sometimes, but tends to give some nice
results.

A couple of tips.  Sometimes images lit like this can look very washed out.
Try increasing the brightness of your sky_sphere way above rgb 1,
particularly in the primary light direction, and then reduce the overall
light level using the brighness keyword in the radiosity block.  This will
tend to increase the tonal range of the lighting, but at the expense of
making any reflections look weird - you'll need to tweak things like the
'exponent' of the reflective surfaces to make them look right again.

For example, the sky_sphere I used for the iso-granite-granules image was:

    gradient x
    color_map {
      [0 rgb <5,1,0>]
      [0.2 rgb 1]
      [0.8 rgb 2]
      [1 rgb <7,7,8>]
    }
    scale 2
    translate -x

(rotated as appropriate of course) which required a radiosity brightness of
0.6.

Also you won't get any specular highlights on surfaces as you would do with
direct lighting, but this can be countered by placing a very dim light
(i.e. rgb 0.001 or something) where the primary light would be coming from,
and then using specular values of the order of 1000.  This will give you
specular highlights as a result of the light source even though the diffuse
component is negligible.  Use light groups to make sure no other lights
affect the surface in ways you don't want.

I'm not saying this stuff is 100% brilliant, but I've used it before to get
some reasonable results.  It can be more trouble than its worth.

L
-


Post a reply to this message

From: [GDS|Entropy]
Subject: Re: Funky Granules
Date: 26 Feb 2014 18:30:00
Message: <web.530e7899a9f0c185ddb0c31e0@news.povray.org>
DJ Wiza <Kil### [at] sohcahtoanet> wrote:
> Awhile ago, I made a macro similar to this one, but it was based on a
> function.  It was more similar to an isosurface that approximated it
> with cubes.
>
> I wonder what kind of result I could get if I used a blob with spheres...
>

I was thinking the same thing, but in reverse.

Two copies of an object, scaled a little, intersection, then macro.

So, should get a surface coating on whatever your normal object is. Maybe tool
around a bit so it coats in a directional manner.

Thinking of trying this as an alternative engine to my surface coating
algorithm, maybe it'll use less memory or something.

Sweet macro though, and I'll certainly be tooling around with uses for it.

Ian


Post a reply to this message

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