[Info] Ambient Occlusion -> Simple Rays

Re: [Info] Ambient Occlusion -> Simple Rays

Postby qpik » Tue Nov 18, 2014 6:58 pm

I'm back :)
0

qpik 
 

Re: [Info] Ambient Occlusion -> Simple Rays

Postby jiminy-billy-bob » Tue Nov 18, 2014 7:02 pm

1
User avatar
jiminy-billy-bob 
PluginStore Author
PluginStore Author
 

Re: [Info] Ambient Occlusion -> Simple Rays

Postby TomPendergrass » Fri Feb 06, 2015 4:34 pm

Hello SketchUcators!

I have a lot of interest in this topic. While modeling in Sketchup can be bliss, creating impressive visual displays without a full blown renderer is very difficult. Being a game developer hobbyist, this limitation keeps me in Blender for most of my game related art.

Anyways, I was curious about raytest and what it's quirks were. As was stated earlier in this thread, limiting the raytest's scanning distance *could* be the solution to faster raycasting. Unfortunately, the ruby API doesn't offer this option; I suppose all rays are infinite (or my theory is the raytests are to the bounds of the scene.)

I decided to do a test: I made a ruby method > raytest_repeating(ray, repeatCount) and cast a ray along the y axis 10,000 times. With no obstructions, it completed it's process on average around 0.15 seconds. Introducing two cubes in separate groups to intersect with, the same method took about 0.68 seconds on average. Here's the interesting part. I placed 2000 groups along the y axis and ran the same method again. This process took ~938 seconds to complete! Keeping the same cubes in the scene and moving all but two of them out of the ray path dropped the calculation back down to the 0.68 average!

In conclusion, raytest must be spending time on all objects the ray interesects, even though it only returns the closest object. It's no wonder your occlusion process drops to a crawl in dense scenes, since I assume you're casting hemispherical rays into 'infinite space', colliding with EVERYTHING along the way! I believe a possible solution to your problem is to find the faces that are in the range of a raytest (IE, nearby faces that actually effect the shading) and to dynamically hide the rest of your scene as needed. Since the raytest can ignore hidden objects, it should speed up the overall process considerably. I ran one final test with the 2000 cubes, hiding all but 2 of them. While the process was slower, 10,000 rays came back in 5.2 seconds, which is far better than 938!

I hope my findings can assist you on this wonderful creation of yours!

-Thomas Pendergrass
0
User avatar
TomPendergrass 
 

Re: [Info] Ambient Occlusion -> Simple Rays

Postby qpik » Sun May 10, 2015 12:25 am

Thanks, good to know that.
But what would be the method to define relevant shading objects, an object's area to sphere-at-the object-distance area ratio?
0

qpik 
 

Re: [Info] Ambient Occlusion -> Simple Rays

Postby TomPendergrass » Tue Mar 22, 2016 12:29 am

Hey qpik,

I know it's been a whole year, I didn't notice that you had posted back on the forum. You're right, you'd need to do a check of what is in your range, and hide everything else. I actually made a script for this way back when, but it remains to be purely experimental. What I did was accept a point in space and created a square bounding box, since bounding spheres aren't really a thing. From that I can iterate through the scene and hide any group that isn't touching my bounding box by using the .contains? method (.contains in versions before 2015 returned invalid results sometimes).

Assuming a dense scene is constructed of small groups, you could do this .contains check for every x amount of rays you cast and hide the irrelevant geometry. It's a patchy fix to a clunky raycast system, but it may fit all of your needs. If you're still interested in this topic, let me know and I'll dust off the old code and post it here.
0
User avatar
TomPendergrass 
 

Re: [Info] Ambient Occlusion -> Simple Rays

Postby qpik » Sun Apr 30, 2017 3:00 pm

Tom,
time flies and I read your post just now. I guess it depends how long does it take to hide/unhide objects in SketchUp.

I just started working on a solution using Blender viewtopic.php?f=180&t=67569
1

qpik 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Previous


 

Return to Plugins

Who is online

Users browsing this forum: delusion89, Google Bot, mcaanz93 and 8 guests

Visit our sponsors: