12 Replies Latest reply on Feb 13, 2013 12:25 PM by [Jongware]


    Steve Fairbairn Level 5

      Does anyone know if there's an Illustrator equivalent to Photoshop’s Displacement Map?


      I need to be able to horizontally displace an area of vertical stripes using a specific greyscale displacement map.

      It’s fairly simple in Photoshop but I would much prefer vector output.


      O.k., I could do it in Photoshop and then vectorize the result with Live Trace, but is there a less roundabout method?

        • 1. Re: Displacement
          Steve Fairbairn Level 5

          Here’s an example: The centre of this stripy square has been displaced horizontally by the width of two stripes.

          Picture 5.png

          The stripes need to be very smooth and accurate but Live Trace gives me many more anchor points than I want.

          • 2. Re: Displacement
            [scott] Level 6

            I don't think it's possible in AI, Steve. The only thing that even remotely comes close would be an envelope mesh, but that would take careful manual manipulation. I don't think there's anything automated anywhere.

            • 3. Re: Displacement
              Jacob Bugge MVP & Adobe Community Professional



              My excuse for being as silly as follows is the return of something white.


              For such a moderate displacement as the one shown, I might consider this:


              1) A series of straight stroked (grey) paths (ungrouped expanded effect or something),

              2) Changing the shape of key path(s) to follow (the local part of) the displacement map (maybe reshape (at one/a few position(s) maybe with adjustment of handles) + dragging out handles at top and bottom, with fewest possible Anchor Points),

              3) Deleting intermediate paths (to be replaced by displaced ones),

              4) Creating blend(s) between key path(s) and undisplaced ones and possibly adjusting by adjusting key paths (maybe with repeated reshaping at same or new Anchor Points and/or adjusting handles),

              5) Expanding blends.

              • 4. Re: Displacement
                Steve Fairbairn Level 5


                I don't think there's anything automated anywhere.

                That’s what I feared. (Just checking too see if there’s anyone out there who’s into such deep and devious trickery!)


                Jacob: Your method is almost impossible because you can’t really do this kind of thing with blends.

                That is, the steps in blends like this are equal whereas the steps in such a displacement are not.

                It would mean a disproportionate amount of work and a lot of eyestrain.


                By the way, the displaced stripes above produce a ring moiré when combimed with straight (undisplaced stripes

                • 5. Re: Displacement
                  [Jongware] Most Valuable Participant

                  Just maybe it can be scripted...


                  What sort of greyscale displacement map would you use? In what direction should lines be displaced -- only horizontally, as in your example image? How much per unit of gray?


                  Is your input all straight lines, with just two anchors, and would the script thus need to divide it into segments of an appropriate length, or are they already divided up? Would you want straight line segments only, or curved ones?

                  • 6. Re: Displacement
                    Larry G. Schneider Adobe Community Professional & MVP





                    Sigur Ros   A chance has come up to possibly attend a concert by them (sorry for the lack of proper accents). Do they do a good show? They will be touring the US in coming months and friends who are visiting us from London in April suggested this.

                    • 7. Re: Displacement
                      Steve Fairbairn Level 5

                      Sorry Larry but I’m not a great fan of Sigur Rós and have never witnessed a concert by them.

                      A bit too soft and dreamy for my (old Stones) taste.


                      But you can listen to a lot of their stuff on YouTube, so if you like it go for it !

                      • 8. Re: Displacement
                        Larry G. Schneider Adobe Community Professional & MVP

                        Thanks, Steve. Only saw the Stones once live in 1972 with Stevie Wonder as the opening act.

                        • 9. Re: Displacement
                          Steve Fairbairn Level 5

                          Jongware: It is clear that you know how displacement maps work in Photoshop.

                          I would probably require something very similar.


                          The map for the example I made was very simple; a radial gradient, white in the centre and black at the edge within a black square.

                          I entered a value for horizontal displacement that corresponded to the width of 2 stripes (found by trial and error).


                          If I had entered a larger number I would have achieved a greater number of moiré rings in the diagram below


                          Picture 6.png


                          It might prove useful to be able to displace horizontally and vertically at some time.

                          The line segments are definitely curved, optimally with as few anchors as possible, and note that the original stripes have to be long thin rectangles because after displacing their width varies very slightly.

                          • 10. Re: Displacement
                            [Jongware] Most Valuable Participant

                            Just as I initially thought: it is possible using scripting -- and in particular, using Scriptographer, as this extends Illustrator's fairly poor scripting abilities up to handling bitmap graphics with grace.


                            See this image: left is a bitmap copied straight out of Photoshop, right is a grid of lines using the image as displacement map.


                            Unfortunately, my lack of Illustrator scripting skills betray me (again!), and I cannot get a good grip on how to adjust existing artwork along the lines of the same map. So far, I got this code:


                            /* Poor Man's Displacement Map */
                            /* A Jongware Script 10-Feb-2013 */
                            var rasters = document.getItems({
                                type: Raster,
                                selected: true
                            var image = null;
                            if (rasters.length < 1)
                                      url = Dialog.fileOpen ('Select a displacement map', '*.png', new File("~/Desktop"));
                                      if (url != null)
                                                image = new PlacedFile(url);
                                                image = image.embed();
                            } else
                                      image = rasters[0];
                            sampleWidth = 200;
                            for (x=0; x<sampleWidth; x++)
                                      xsample = x*image.width/sampleWidth;
                                      // Add a vertical line
                                      var myPath = new Path();
                                      myPath.add(new Point(x, 0));
                                      myPath.add(new Point(x, 100));
                                      myPath.strokeColor = new RGBColor(0,0,0);
                                      seg = 1;
                                      for (y=1; y<100; y++)
                                                // image coordinates are reverse of Illustrator's
                                                // hence the 100-y
                                                ysample = (100-y)*image.height/100;
                                                value = 1-image.getPixel(xsample, ysample).gray;
                                                myPath.insert(seg, new Point(x-8*value, y));


                            .. feel free to post it on the Scripting forum; perhaps someone else can leverage it up to something you can use.


                            This is not regular Javascript! It uses Jürg Lehni's (and others) Scriptographer plugin for Illustrator CS4. Unfortunately, Jürg discontinued working on Scriptographer for CS6; see the web site for his argumentation. (It's a pity Adobe doesn't want to discuss integrating Sg into Illustrator, as its capabilities vastly surpass their own script integration, as this my short script shows.)


                            Signing off for now with a displaced signature:

                            Screen Shot 2013-02-11 at 12.45.52 AM.png

                            • 11. Re: Displacement
                              Kurt Gold Adobe Community Professional

                              Just a confirmation, Jongware: Your script does work inside the Scriptographer environment. Admittedly with some astonishing results.


                              Perhaps Steve has some suggestions for improvement ?

                              • 12. Re: Displacement
                                [Jongware] Most Valuable Participant

                                Kurt, I have some ideas on how to continue towards Steve's ultimate goal. It should be possible to put an image behind native artwork, have the script find intersections of this artwork with the image, then add and displace single vertexes according to the gray scale values.


                                As things go, my time is limited, my resources scant, and Illy is really a troubling beast to script -- even with the added leverage of Sg.