sketchucation logo sketchucation
    • Login
    1. Home
    2. qpik
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Q
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 51
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: [Info] Ambient Occlusion -> Simple Rays

      Thank you TBD. That saved me some time checking Ruby documentation πŸ˜„ I hope i fixed the bugs you pointed out in your first post. Let me know if it works on Mac.

      Also thanks to all for motivating posts. I cannot resist though to see dead end for this plugin.
      Has anyone tried it on a normal model which has more than 10 faces? How long does it take to render?

      I still consider porting it to C++ (which I would have to learn πŸ˜„) but it seems pointless, as it's much easier I think to add texture baking to Podium or Kerkythea (if it's not there yet).

      Kuba

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      @unknownuser said:

      unfortunately no 😞
      the only way is to take the 3d data and do the ray testing yourself, but definitely not in Ruby as it is too slow.

      That is to say that this plugin has very little usability. It's just to slow. 😞

      TBD: It's probably a trivial question, but how do I extract file name from path on both Windows and Mac?

      Anyway. I found that there is a strange thing with SketchUp resizing textures. Sometimes it's smother and sometimes it produces 'waves'. For example it gives nice result while using P:10, R:10 or P:25, R:10, but not with P:20, R:10 or P:50, R:10. (where P stands for Precision and R for Rays in AO settings)

      Kuba

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      TBD
      Thank you for your suggestions. When the file is saved the script shouldn't ask for directory any more.
      My biggest concern is model.raytest, it takes up to 90% of calculation time.
      Can you tell me if you see any chance of speeding this plugin up? Is there a way to replace model.raytest? Is Ruby just to slow?

      Another example showing different settings for different sizes of faces rendered separately.

      example.jpg
      Kuba

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      I have added Bitmap.blur method to smooth out textures. I helps to save on calculation time, since now fairly good result can be obtained setting Rays to 5.

      Here is an image showing the difference. Both shaded using Precision 10, Rays 10, but right one uses blur 3 times.

      blur.jpg
      Does anyone have an idea how to replace model.raytest method with faster counterpart? Maybe there is a way to access OpenGL from Ruby?

      Kuba

      ps. Just a tip. I turn on 'Use sun for shading' and set both 'Dark' and 'Light' to 100 just to remove Sketchup shading.

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      Pixero
      So you mean to cut down on time by reducing single ray casting procedure, not number of them? That means that instead of using existing model.raytest method I would have to write my own. I'll think about it.
      About ambient occlusion method. As i know it from Wikipedia it's based on casting rays from point evenly over a "hemisphere". I plan adding narrowing that angle, but combined with changing it's direction will produce different effect, it will give soft sunlight (fixed direction) or point light (point.vector_to source direction) shadows, where the size of the light source (softness of shadows) will be determined by that angle.

      Speeding up is crucial for this plugin. I haven't even tried it with complex geometry, because I expect it to run for ages. I don't wan't to add too much functionality before finding out weak points and rewriting it .
      I need someone to point out those areas of code which slow it down the most. Maybe Ruby can't do it much faster.

      Kuba

      ps. About values for Resolution and Rays - do you think those default 10,10 are optimal?

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      Daniel S
      I will think about your idea. I would have to trace lightmap for "isolines" of equal brightness.

      Pixero
      But it would have to check for each ray this max_distance condition, am I right? Rays here don't bounce, they check only if they hit nothing/background.

      xrok1
      I planned this as next stage of developement for it seems quite complicated to me. The simplest way would be to create faces offset by small distance from the original textured face (the same way Daniel S overlays shadow in his model). But then brightness would have to be translated to opacity, which requires PNG format which I'm not familiar with (yet). The other way would be to merge shadow texture with existing one aquired by something similar to 'Make unique texture'.

      Kuba

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      Daniel S
      I thought about it first. Before I learned reading/writing BMP files.
      But my goal was to render soft shadows.
      I can only imagine creating hundreds of tiny faces to simulate smooth color transition.

      If you have better idea I could implement it.

      Kuba

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      Dave R
      Nice image. Thanks for posting
      I have to work on blurring and smoothing the shadows as well as on casting rays.

      I've re-uploaded occlusion.rb. (don't know if this is a good way of posting rewritten code)

      Now the plugin will ask you to save the file so you don't have to worry about it.

      Kuba

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      Ok. The problem is obvious.
      I worked on an already saved model. I got the same error when working on a new model.
      The plugin looked for the path via model.path method and returned nil since it couldn't find it. Maybe better solution would be to create a temporary folder in SketchUp/Plugins and then delete it after all the textures are inside the model.

      Kuba

      posted in Plugins
      Q
      qpik
    • RE: [Info] Ambient Occlusion -> Simple Rays

      Dave R
      I don't know what causes the problem. The plugin works only with faces front side only. Did you see any new material appear in Material window after running the plugin?

      Daniel S
      It's a problem with SketchUp file path. Are you using Windows or Mac SketchUp version?
      I'm sure that ray casting algorithm can be modified to include sun position.

      Kuba

      posted in Plugins
      Q
      qpik
    • [Info] Ambient Occlusion -> Simple Rays

      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.

      simple_rays.jpg
      The plugin works like this:

      1. Extract faces from selection and compute each of them
      2. Make grid of points and compute each - lightmap method extending Sketchup::Face class
      3. 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
      4. Write 24-bit BMP texture for each face in a folder "filename_occlusion" along your SketchUp file - Bitmap class
      5. 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

      posted in Plugins
      Q
      qpik
    • 1 / 1