POV-Ray : Newsgroups : povray.binaries.images : Snow-on-Tree Macro : Snow-on-Tree Macro Server Time
9 Aug 2024 21:14:58 EDT (-0400)
  Snow-on-Tree Macro  
From: Tim Nikias
Date: 9 Dec 2004 14:15:51
Message: <41b8a467@news.povray.org>
So, for those interested: I'm currently working on a set of macros to drop
snow onto objects, see my thread in p.b.g "Ingenious snow placement?".

The input to actually save parsing time when competing against the brute
force method (just dropping buckets of particles onto the object) is the
topview image. It can be generated with a simple script which measures the
boundary-box using min- and max_extent and matches an orthographic camera to
look at the object. The object has to be white, the background black.

Once this image is generated, the macro will subdivide the image with a
regular grid into cells. Each cell's edges are checked if they intersect the
white of the image (this is cleverly done using trace() and a heightfield)
or, if that fails, if the entire cell is actually inside the object's
topview (by checking if the center is inside). Of course, small objects
might get lost, but the macros are designed for a single object with a
rather proper boundary-box, and that "getting-lost" issue is always the case
for discrete sampling...

Once the cells are determined full or empty, full cells will receive the
brute force method and get one bucket of trace(). The empty cells don't get
buckets, and thus, I save lots of parsing time! Additionally, particles will
drop straight through the object and will also hit surfaces underneath the
first surface, but it checks if the normal is actually pointing towards the
sky, to see if I've just hit the bottom of a surface.

And the small overhead due to the pretesting phase is worth it! The macro
ran on the tree in the image below (using the topview also supplied, but
with 1000x1000 dimensions for better accuracy) in 53 seconds. It generated
53.000 cells and discarded 42.000 empty cells (that's 80% of the volume!)
and dropped 80 particles in each active cells. I got 40.000 surface hits
that way, which are displayed in the 3D-Image of the tree.

Now I need to write macros to add further detail, like accumulation of snow
at walls and in edges and such. Also, the described technique above is only
meant to be used to generate an initial, crude set of positions, which I can
use as starting points for more detailed traces.

Comments and suggestions welcome (though I don't expect many, after all, I'm
just presenting some simple algorithm :-)

Regards,
Tim

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


Post a reply to this message


Attachments:
Download 'tree_top.jpg' (21 KB) Download 'tree_snow.jpg' (34 KB)

Preview of image 'tree_top.jpg'
tree_top.jpg

Preview of image 'tree_snow.jpg'
tree_snow.jpg


 

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