• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

[REQ] Displacement ruby

Scheduled Pinned Locked Moved Plugins
32 Posts 14 Posters 4.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    solo
    last edited by 13 Jul 2008, 19:59

    Okay ruby masters this is probably science fiction, nevertheless I will ask the question.

    Is it possible to create a physical mesh from lets say a bump image, similar to the way a Heightfield terrain is created?

    As most folk know it's possible to do this using displacement tool in many apps, as displacement creates actual mesh and not just an illusion of it as bump mapping does. Could such a feature be created in ruby?

    I include some images to help explain.

    Simple shape

    http://img231.imageshack.us/img231/2861/dis1jd1.jpg

    The above shape after 'Sub-smooth' with 3 iriterations.

    http://img329.imageshack.us/img329/4955/dis2nf3.jpg

    Now using an image as reference to displacement then create this?

    http://img399.imageshack.us/img399/2859/dis3ju6.jpg

    http://www.solos-art.com

    If you see a toilet in your dreams do not use it.

    1 Reply Last reply Reply Quote 0
    • I Offline
      ilay7k
      last edited by 13 Jul 2008, 20:18

      ha...millions... of faces
      Why?
      example, 1) for rhino: developers "hide" this behavior under rdk command(extractdisplmesh)/anyway scene will be so heavy/ it normally actions at rendering process
      2) for cinema4d: realtime engine for showing displ/map in mograph displ.deformer//i think you want such like this
      http://img329.imageshack.us/img329/2682/c4dzt3.th.jpg

      ...

      1 Reply Last reply Reply Quote 0
      • W Offline
        Whaat
        last edited by 13 Jul 2008, 20:41

        I've thought about creating such a script. The main difficulty is getting the pixel (RGB) value from the texture at a given point. If anyone knows how do this, let me know.

        SketchUp Plugins for Professionals

        1 Reply Last reply Reply Quote 0
        • I Offline
          ilay7k
          last edited by 13 Jul 2008, 20:43

          Dale, Highfield-map generator?
          maybe through ogl libs

          1 Reply Last reply Reply Quote 0
          • S Offline
            solo
            last edited by 13 Jul 2008, 20:53

            Ilay7k, for landscapes and terrains it would be an SU killer for sure, but for other purposes like if you remember Silvershadows method of doing a cobble stone sidewalk, this would be a snap.
            It can also be used for product modeling where only one or two surfaces needs a physical relief.

            How about this use?


            http://img413.imageshack.us/img413/5622/planeju8.jpg

            http://www.solos-art.com

            If you see a toilet in your dreams do not use it.

            1 Reply Last reply Reply Quote 0
            • S Offline
              solo
              last edited by 13 Jul 2008, 23:43

              As mentioned above, cobblestones or such mesh could be achieved using a simple bump image and if you have a seamles image like below then a small or low poly mesh can be generated which can be made into a component and tiled to form a cobble road as below without killing the model.

              The image:

              http://img214.imageshack.us/img214/6815/cobblebumpzg3.jpg

              The resulting mesh:

              http://img228.imageshack.us/img228/7590/cobbl1qpc3.jpg

              The mesh made into a component and tiled:

              http://img214.imageshack.us/img214/1857/cobbledisplacementkq5.jpg

              http://www.solos-art.com

              If you see a toilet in your dreams do not use it.

              1 Reply Last reply Reply Quote 0
              • P Offline
                princedragoncok
                last edited by 14 Jul 2008, 00:01

                Your examples are highly convincing solo. I'm all support for a displacement ruby. It seems you already have it however.. how did you create those models?

                1 Reply Last reply Reply Quote 0
                • S Offline
                  solo
                  last edited by 14 Jul 2008, 00:09

                  I used a third party app, Vue 6 xstream and used the displacement feature, then baked it to polygons and exported it as .3ds.
                  The workflow is a little tedious and was hoping that if we could apply a texture to a given surface then select the surface and have an option to 'turn to mesh' which would then through the miracle coding of someone like Whaat become a 3d mesh with an option to reduce the polys if neccesary (already a ruby)

                  Just thoughts .... dreams.

                  Another example.


                  http://img296.imageshack.us/img296/6533/weavean9.jpg

                  http://www.solos-art.com

                  If you see a toilet in your dreams do not use it.

                  1 Reply Last reply Reply Quote 0
                  • tbdT Offline
                    tbd
                    last edited by 14 Jul 2008, 07:44

                    @unknownuser said:

                    getting the pixel (RGB) value from the texture at a given point. If anyone knows how do this, let me know.

                    some ideas:

                    1. convert texture to .raw and read it via ruby file commands (as I did it in 2004 Terol script)

                    2. direct image parsing - too complicated (several formats, compression)

                    3. server based - image upload to server, converted to an Array and returned back to Ruby

                    SketchUp Ruby Consultant | Podium 1.x developer
                    http://plugins.ro

                    1 Reply Last reply Reply Quote 0
                    • plot-parisP Offline
                      plot-paris
                      last edited by 14 Jul 2008, 08:08

                      solo, let me tell you, that your illustrations are impressive. it makes perfectly clear, what you want to achieve with that script and what the benefits are.

                      I would love to have such a ruby.
                      like you said:

                      @solo said:

                      ...but for other purposes like if you remember Silvershadows method of doing a cobble stone sidewalk, this would be a snap.

                      this would really help to push realism of SketchUp models much further (towards "Silvershadow-realism"... 😄 )

                      1 Reply Last reply Reply Quote 0
                      • jujuJ Offline
                        juju
                        last edited by 14 Jul 2008, 08:23

                        OMG, I would SO pay for this, so long as it is not server based.

                        Save the Earth, it's the only planet with chocolate.

                        1 Reply Last reply Reply Quote 0
                        • K Offline
                          kwistenbiebel
                          last edited by 14 Jul 2008, 08:53

                          It's a nice idea.
                          However, I think current Sketchup will have difficulties with the polycount.

                          I rather see some advanced uv-mapping tools to get displacement maps on complexer surfaces so we can render displacement with the photoreal render engine of choice.

                          But I can understand a displacement2mesh plugin could be useful to people that want to see the displacement in their default Sketchup output.

                          1 Reply Last reply Reply Quote 0
                          • bigstickB Offline
                            bigstick
                            last edited by 14 Jul 2008, 10:20

                            What about Didier's heightfield generator script here:- http://www.crai.archi.fr/RubyLibraryDepot/Ruby/em_geo_page.htm
                            The documentation is here:- http://www.crai.archi.fr/RubyLibraryDepot/Ruby/Heightfield_gen.pdf

                            I tried it because I wanted to generate a rippled water plane, but couldn't get it to work at all. As they say however, "your mileage may vary".

                            1 Reply Last reply Reply Quote 0
                            • K Offline
                              kwistenbiebel
                              last edited by 14 Jul 2008, 11:22

                              I didn't know there was a ruby script like that.Thank you for the link Bigstick.

                              I just tried using Didiers script (heightfield.rb), but it doesn't do anything at all in my case.
                              I converted a greyscaled displacement .jpg texture to a Ascii .pgm pixel image in Xnview (as suggested in the tutorial) and tried to load it through the ruby. Maybe I am doing something wrong, but I couldn't get it to generate geometry out of it.

                              As the ruby was created in 2004, maybe it isn't adapted to sketchup 6?

                              1 Reply Last reply Reply Quote 0
                              • I Offline
                                ilay7k
                                last edited by 14 Jul 2008, 14:22

                                Didier, thank you
                                i have such problem with loading pgm(in skp 5):
                                i attach images

                                Format; P2 (PGM) Width; 828 x Height; 177 Greyscale; 256 levels.
                                Number of points; 16
                                Empty mesh initialized.
                                Mesh altitude range; 100.0
                                Patch Length X; 0.0476058993229746
                                Patch Width Y; 0.223693629205114
                                Altitude Step Z; 0.392156862745098
                                Create group; Yes
                                Destination layer; Layer0
                                Error; #<NoMethodError; undefined method `*' for nil;NilClass>
                                (eval);196;in `hf_create_points'
                                (eval);193;in `upto'
                                (eval);193;in `hf_create_points'
                                (eval);181;in `upto'
                                (eval);181;in `hf_create_points'
                                (eval);28;in `hf_gen'
                                (eval);324
                                (eval);324;in `call'
                                

                                anybodies know any kind console convertor bmp2ansipgm or raw?
                                add: i use total commander addition - image lister by ivory


                                contains test.PGM and test.bmp

                                1 Reply Last reply Reply Quote 0
                                • S Offline
                                  solo
                                  last edited by 14 Jul 2008, 14:30

                                  Irfanview can do it, and it's a free app.

                                  Link Preview Image
                                  IrfanView - Official Homepage - One of the Most Popular Viewers Worldwide

                                  IrfanView ... one of the most popular viewers worldwide.

                                  favicon

                                  (www.irfanview.com)

                                  http://www.solos-art.com

                                  If you see a toilet in your dreams do not use it.

                                  1 Reply Last reply Reply Quote 0
                                  • Didier BurD Offline
                                    Didier Bur
                                    last edited by 14 Jul 2008, 14:32

                                    Hi,

                                    @unknownuser said:

                                    maybe it isn't adapted to sketchup 6?

                                    it is not, you are right. But it could be (one line of code to change...)
                                    I'm testing it right now. But it is sooooo sloooow !
                                    This kind of feature requests a C++ prog IMHO.100x100 pixels -> 19600 faces, execution time: 2mn (!)

                                    DB

                                    1 Reply Last reply Reply Quote 0
                                    • Didier BurD Offline
                                      Didier Bur
                                      last edited by 14 Jul 2008, 14:35

                                      Hi Ilayk,
                                      The error comes from that the options providers have changed from SU5 to SU6.
                                      If you decrypted the script, go to line 110:
                                      u = opt[3][2]
                                      and change it to:
                                      u = opt[0][2]

                                      That's all, it will work after that,

                                      DB

                                      1 Reply Last reply Reply Quote 0
                                      • I Offline
                                        ilay7k
                                        last edited by 14 Jul 2008, 15:58

                                        strange
                                        it's same(can't normally get size of mesh...)

                                        Format; P2 (PGM) Width; 1680 x Height; 1509 Greyscale; 256 levels.
                                        Number of points; 16
                                        Empty mesh initialized.
                                        Mesh altitude range; 100.0
                                        Patch Length X; 23.4485281358547
                                        Patch Width Y; 26.1074792706233
                                        Altitude Step Z; 0.392156862745098
                                        Create group; Yes
                                        Destination layer; Layer0
                                        Error; #<NoMethodError; undefined method `*' for nil;NilClass>
                                        D;/Program Files/gsu6/Plugins/heightfield_gen.rb;196;in `hf_create_points'
                                        D;/Program Files/gsu6/Plugins/heightfield_gen.rb;193;in `upto'
                                        D;/Program Files/gsu6/Plugins/heightfield_gen.rb;193;in `hf_create_points'
                                        D;/Program Files/gsu6/Plugins/heightfield_gen.rb;181;in `upto'
                                        D;/Program Files/gsu6/Plugins/heightfield_gen.rb;181;in `hf_create_points'
                                        D;/Program Files/gsu6/Plugins/heightfield_gen.rb;28;in `hf_gen'
                                        D;/Program Files/gsu6/Plugins/heightfield_gen.rb;324
                                        D;/Program Files/gsu6/Plugins/heightfield_gen.rb;324;in `call'
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • Didier BurD Offline
                                          Didier Bur
                                          last edited by 14 Jul 2008, 16:28

                                          Ok I forgot this one, line 190:

                                          def hf_create_points
                                          opt = Sketchup.active_model.options
                                          # u = opt[3][2] Version 5
                                          u = opt[0][2] # Version 6
                                          ...
                                          

                                          😳

                                          DB

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 1 / 2
                                          1 / 2
                                          • First post
                                            1/32
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement