[Info] Ambient Occlusion -> Simple Rays

Re: [Plugin] Ambient Occlusion - Smoothing

Postby tbd » Wed Aug 12, 2009 2:50 pm

qpik wrote:Has anyone tried it on a normal model which has more than 10 faces? How long does it take to render?


tried on a selection of 47 faces (nothing complicated) - 8min 42sec on Quad Core 2.4ghz. a bit too slow ;)
render in Podium of the complete model (106 faces) was 31 sec.

qpik wrote:I still consider porting it to C++ (which I would have to learn :)) but it seems pointless


as you said that 90% is wasted in raytest I see no point in porting to another language except if you want to implement raytesting based on 3D data.
0
SketchUp Ruby Consultant | Podium 1.x developer
http://plugins.ro
User avatar
tbd 
 

Re: [Plugin] Ambient Occlusion - Smoothing

Postby qpik » Sun Aug 16, 2009 7:08 pm

How about doing the raytest in Javascript via Webdialog?
Would that be faster than Ruby?

Kuba
0

qpik 
 

Re: [Plugin] Ambient Occlusion - Smoothing

Postby qpik » Mon Nov 23, 2009 9:47 pm

Hello there.

Since I need to calculate sun exposure time in my current project I've added this functionality to the plugin. Here you can see an example. Yellow corresponds to 10h exposure, blue is no exposure.

sun_exposure_time.jpg

It is based on peculiar polish building code (which requires an apartment to have at least 3 hours of direct sunlight on vernal equinox between 7am and 5pm) making this version useful in Poland. It can be easily adjusted though to fit any location and sun position.

ps. My previous question is still actual - Would doing the raytest in Javascript via Webdialog be faster than Ruby?
0

qpik 
 

Re: [Plugin] Ambient Occlusion - Smoothing

Postby MartinRinehart » Mon Nov 23, 2009 11:42 pm

qpik wrote:How about doing the raytest in Javascript via Webdialog?
Would that be faster than Ruby?


To get this to happen at all in Ruby is heroic. I'm impressed.

Neither Ruby nor JavaScript is a compiled language. C++ may be an order of magnitude better.
0
Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

MartinRinehart 
 

Re: [Plugin] Ambient Occlusion - Smoothing

Postby qpik » Wed Nov 25, 2009 12:06 pm

Does anyone know if there is a way of creating a faster replacement for

Code: Select all
model.raytest

method?

I've found a Ruby PNG library. That's a step towards layering textures in Sketchup (using PNG alpha).

Kuba

ps. Would anybody like to cooperate on this plugin?
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby Wacov » Sat Nov 28, 2009 3:04 pm

This is really amazing. I mean, if you could do the raytesting separately with a faster language, it'd be really useful.
0

Wacov 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby thomthom » Sat Nov 28, 2009 3:12 pm

The .raytest method is running in SU's C. Not calculated using Ruby. Ruby just calls the C method.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby qpik » Sun Nov 29, 2009 8:44 pm

Does that mean that model.raytest algorithm is inherently slow?
So I would need to write my own in C.
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby thomthom » Sun Nov 29, 2009 8:47 pm

What I meant was that the .raytest is probably written in C already.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby Jim » Sun Nov 29, 2009 8:49 pm

Yeah, to make it faster wouldn't you need to export the geometry so an external routine could both loop and perform the raytest?
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby qpik » Sun Nov 29, 2009 8:55 pm

But I would have to export geometry for that one external routine.
Is there other way?

thomthom wrote:What I meant was that the .raytest is probably written in C already.

I've got that, I just wonder what makes it slow then and how to write a faster one.

I guess I have to prepare myself for switching to C. Even for my simple use, which is lately sunlight exposure analysis, it's simply too slow, when run on part of the city centre model.

Kuba

ps. Many thanks for all the help so far.
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby Wacov » Mon Nov 30, 2009 10:49 pm

thomthom wrote:The .raytest method is running in SU's C. Not calculated using Ruby. Ruby just calls the C method.


Ok.


I guess I don't know what I'm talking about, but doesn't SU's raytest method extract more information than you need for your plugin? Maybe that's why it's so (comparatively) slow.
0

Wacov 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby thomthom » Mon Nov 30, 2009 11:22 pm

Possibly. I guess it depends on what you need it for.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby qpik » Tue Dec 01, 2009 12:05 am

Wacov wrote:I guess I don't know what I'm talking about, but doesn't SU's raytest method extract more information than you need for your plugin? Maybe that's why it's so (comparatively) slow.

I thought exactly the same, as it returns "the first thing that the ray hits". I suppose it means "the closest thing". For my purpose it's enough to get first-on-the-list hit end exit.
That might do the trick.
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby qpik » Tue Dec 01, 2009 12:22 pm

I quickly wrote this, but it worked MUCH slower than original method.

Code: Select all
def raytest2 ray
 hit = false
 entities = self.entities
 entities.each { |face|
   if face.kind_of?(Sketchup::Face) and face.classify_point(ray[0]) > 4
    plane = [face.vertices[0].position, face.normal]
    intersection = Geom.intersect_line_plane(ray, plane)
    if intersection and face.classify_point(intersection) < 8
     hit = true
     break
   end
  end
 }
 return hit
end

This could be optimized by passing pre-sorted face array (based on results from previous tests) instead of browsing entities array, but I doubt it would speed it up much.
What do you think?
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby thomthom » Tue Dec 01, 2009 12:30 pm

qpik wrote:plane = [face.vertices[0].position, face.normal]

You can use face.plane instead

qpik wrote:This could be optimized by passing pre-sorted face array (based on results from previous tests) instead of browsing entities array, but I doubt it would speed it up much.
What do you think?

hmm... If you only iterate the entities collection once then it won't help to pre-process to filter out only faces. Infact, that would mean more iterations. But if you need to iterate the face multiple times, then you will save time on pre-filtering.

qpik wrote:I thought exactly the same, as it returns "the first thing that the ray hits". I suppose it means "the closest thing". For my purpose it's enough to get first-on-the-list hit end exit.

Isn't that the same thing?

qpik wrote:I quickly wrote this, but it worked MUCH slower than original method.

You're writing a ruby method to be faster than a C method - that C method must be doing a lot of extra processing in order to be able to out-perform it in Ruby.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby qpik » Thu Dec 17, 2009 12:47 am

thomthom wrote:You can use face.plane instead

Somehow I didn't notice that one in the API :)

thomthom wrote:hmm... If you only iterate the entities collection once then it won't help to pre-process to filter out only faces. Infact, that would mean more iterations. But if you need to iterate the face multiple times, then you will save time on pre-filtering.

I meant to sort the collection before proceeding to the next testing point. The faces that got hit before might as well be the first to get hit by rays cast from adjacent point.

thomthom wrote:
qpik wrote:I thought exactly the same, as it returns "the first thing that the ray hits". I suppose it means "the closest thing". For my purpose it's enough to get first-on-the-list hit end exit.

Isn't that the same thing?

I suppose model.raytest doesn't break after first positive ray hit, but returns the closest one from an array of all.

thomthom wrote:
qpik wrote:I quickly wrote this, but it worked MUCH slower than original method.

You're writing a ruby method to be faster than a C method - that C method must be doing a lot of extra processing in order to be able to out-perform it in Ruby.

That is certainly true. That is why I managed to connect with a DLL using Win32api.call (BTW thanks to TBD for his SUDLL example).
Now I'm on my way to moving everything to C. I hope this will finally give a speed boost.

I'm looking into Ruby-OpenGL as well for another approach.
Here is an example - viewtopic.php?f=180&t=20893&p=209966#p209966
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby thomthom » Thu Dec 17, 2009 8:30 am

qpik wrote:I suppose model.raytest doesn't break after first positive ray hit, but returns the closest one from an array of all.

that would be very odd. if it did produce a full array before returning I think it should return the full array.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby qpik » Thu Dec 17, 2009 9:49 am

But then how would it find out the closest intersection?

ps. I write all this out of my head, I'm not familiar with 3d algorithms.
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby tomasz » Thu Dec 17, 2009 9:50 am

qpik wrote:I suppose model.raytest doesn't break after first positive ray hit, but returns the closest one from an array of all.

I think it does break after first positive hit. Make sure you check if the object is not hidden or on a hidden layer, otherwise your rays will stop too early when hidden layer present in a model.
0

tomasz 
SU2TH & SU2KT Developer
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby qpik » Thu Dec 17, 2009 10:36 am

Yeah, but how would the method know if the first hit is the closest?
It could be for example some distant face that got hit first, because it was first in the collection.
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby thomthom » Thu Feb 25, 2010 11:10 am

Did you ever find any improvements that could be made?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby qpik » Tue Mar 16, 2010 3:14 pm

I planned writing new method in C and calling it via Win32api... but I never find time and enough determination to do it. I wish somebody else did it instead :), someone who knows C, unlike me.
0

qpik 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays

Postby thomthom » Tue Mar 16, 2010 3:37 pm

I'm also an C ignorant... :(
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Ambient Occlusion -> Simple Rays (sun, solar)

Postby KiraNL » Sun Jul 10, 2011 6:59 pm

Any chance this ever might come out which works for round shapes?
Love to use this as subtile shadows over the textures, sort of lighting baking.
0

KiraNL 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays (sun, solar)

Postby seikun » Mon Feb 27, 2012 7:21 am

how can i download the plug-in
0

seikun 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays (sun, solar)

Postby Gaieus » Mon Feb 27, 2012 9:15 am

It's attached to the first post of the topic. But it is not yet tested on SU version 9 - so it may not work for you (unless you made a typo when registering in which case, could you correct it, please?).
;)
0
User avatar
Gaieus 
 

Re: [Plugin] Ambient Occlusion -> Simple Rays (sun, solar)

Postby tomasz » Mon Feb 27, 2012 10:00 am

Hi Kuba,

Nice to see another Polish architect in action as a programmer. :)
I am getting more and more comfortable with C++, but I do not expect to be able to help you within next few months.
I won't forget you effort and if I will find time, I will see whether I can help you with the raytest issue.
0

tomasz 
SU2TH & SU2KT Developer
 

Re: [Plugin] Ambient Occlusion -> Simple Rays (sun, solar)

Postby Dan Rathbun » Sat Dec 22, 2012 4:57 am

    This "plugin" (using the term liberally,) has been NOMINATED for QUARANTINE.

    see: [Candidate] Quarantine: Ambient Occlusion by qpik
    0
      I'm not here much anymore. But a PM will fire email notifications.
      User avatar
      Dan Rathbun 
      PluginStore Author
      PluginStore Author
       

      Re: [Plugin] Ambient Occlusion -> Simple Rays (sun, solar)

      Postby Dan Rathbun » Mon Jan 07, 2013 9:49 am

        NOTICE: Preliminary Overhaul of the SimpleRays plugin !

        Developers' forum: [Plugin] Qpik::SimpleRays OVERHAUL

        I did this overhaul so we can remove SimpleRays from the Quarantine List

        Jakub, where are you ?

        :?:
        0
          I'm not here much anymore. But a PM will fire email notifications.
          User avatar
          Dan Rathbun 
          PluginStore Author
          PluginStore Author
           

          SketchUcation One-Liner Adverts

          by Ad Machine » 5 minutes ago



          Ad Machine 
          Robot
           

          PreviousNext


           

          Return to Plugins

          Who is online

          Users browsing this forum: ayboo, hafidfebriant15, Phùng khắc Mạnh and 12 guests

          Visit our sponsors: