This is a crude version of a raycasting plugin that realizes a very straightforward approach to adding soft shadows inside SketchUp. Since I'm no professional coder but an architect at this point it's very slow and is useless for complicated models. It takes two parameters - Precision, which determines probing resolution according to grid = model.bounds.diagonal / precision and Rays which denotes number of rays cast from each point of grid.
[anchor= goto=http://sketchucation.com/forums/viewtopic.php?f=323&t=51950&p=545855#p545855:1hef2rd6]Download it here![/anchor:1hef2rd6]
Here is an explanatory image. Shading took 2-3 seconds.
The plugin works like this:
- Extract faces from selection and compute each of them
- Make grid of points and compute each - lightmap method extending Sketchup::Face class
- Cast an array of rays from a point invoking model.raytest method, calculate exposure translate to r, g, b values - exposure method extending Array class
- Write 24-bit BMP texture for each face in a folder "filename_occlusion" along your SketchUp file - Bitmap class
- Position textures on faces
I would appreciate any comments on how I can speed it up and whether this plugin might be of any use.
%(#0000FF)[Version history:
Mon Aug 10, 2009 Modified ray casting algorithm - more even ray casting, resulting also in approx. 2 times more rays cast
Mon Aug 10, 2009 Modified lightmap algorithm - shading time reduced approx. 2 times by reducing number of occlusion calls, added Bitmap.expand method to do the same task, deleted some unused code
Tue Aug 11, 2009 Added Bitmap.blur - texture smoothing
Tue Aug 11, 2009 Added progress info, removed unused parts of code
Wed Aug 12, 2009 Removed Save panel, instead when model is not saved "temp_occlusion" folder is created in the Plugins folder, added Mac compatibility
Wed Nov 25, 2009 Added Sun Exposure Time mode and changed the name of the plugin, rewritten many parts of code, making it a bit faster.]
NOTE -
See Dan Rathbun's Qpik::SimpleRays Tools