How does the Displace effect work?

Hi,

I'm trying to get my head around the Displace effect.

I mean, I've used the Displace effect a couple of times, but... how does it really work? So far I've tried just experimenting (trial an error), and by looking at what others have made.

But I don't understand (yet) how they work. Now.. I have to admit I don't even know what the Displacement Amount and Texture Size values actually do either, so it's a bit harder to figure it out by myself.

On top of that, I'm under the impression that the colours in the map texture do matter, but I don't know why.

Is there a resource you can point me towards?

(I'm fine with technical stuff, but I'd appreciate a tldr explanation if it's possible)

Do you choose your displacement maps by trial and error? By previous experience? Or are you able to see the map texture and get an idea of the effect they will have?

JulianDracos

Best Answers

  • MonsenMonsen Administrator 🖼️ 46 images Cartographer
    edited October 2021 Accepted Answer

    The displacement is based on a normal map. A normal map is basically a grid of vectors encoded using RGB values so you can store it as an image. The vector encoded in each pixel basically determines the direction for the displacement effect at that point.

    The texture size tells CC3+ how to scale the texture you pick. If you want a single displacement image to cover the entirety of your map, set the effects units to map units, and the texture size to a value equal to the width (or height) of your map. If the value is lower than your map size, the displacement image will tile (which is usually the way you would use it).

    The displacement amount is basically the strength of the effect, i.e how much the pixels should be displaced. May need som experimenting to get this right, and don't be afraid of going to pretty large values.

    [Deleted User]Loopysueroflo1GlitchAleD
  • jslaytonjslayton Moderator, ProFantasy Mapmaker
    Accepted Answer

    The basic idea for how effects in CC3 work is that CC3 converts the current sheet's drawing entities into a raster image of that sheet, then applies effects to that intermediate sheet image to get a final sheet image. All of the individual final sheet images are composited together to get a final drawing output image that you see onscreen or write to disk during export.

    The displace effect takes a raster image stored on disk and use the pixels in that image as offsets for each pixel in the intermediate sheet image, allowing each pixel in the sheet image to be picked from some other location than the starting one. The red and green components of each pixel tell the direction to fetch the pixel from (red is horizontal, green is vertical, blue is ignored), while the effects "Displacement" parameter says how far away to fetch the pixel from. To make sure that things scale correctly, the "Texture Size" parameter says how many units (as specified by the "Effect Units" setting) the whole image occupies. For folks who like to see more mathematically-looking stuff, it's something along the lines of destinationSheetImage(x,y) = sourceSheetImage((x,y) + displacementImage((r-128)*scale,(g-128)*scale)) for each x and y in the sheet image.

    Then we get to the mystery "Image is a bump map" effect setting. When this checkbox is off, the input image directly specifies the displacements in the red and green image channels as described above. When it's checked, pixels in the input image are treated as grayscale height values and the normal map is computed as the gradient of that height image during loading. It's difficult to paint a pretty normal map by hand. You have to think in terms of individual channels and not red-green-yellow-brown-never blue-never white. It's usually a lot easier (maybe just for me, I'm not an artist) to think in terms of "this is high and this is low" and let the system figure out the crazy color stuff to point in the right direction. You can take a picture of some hay, for example, and call it a paper texture. That won't work particularly well for a straight normal displacement map, but will often work well for a bump displacement map.

    Why would anyone ever want to use a displacement map? A displacement map can be used to give fine-grained details to what would otherwise likely be a fairly dull drawing with straight lines. Careful choice of displacement map can give something similar to paper grain if chosen well. A displacement map with less high-frequency noise can give an effect reminiscent of a slightly-shaky scribe's hand. Combining two displacement effects on the same sheet can get shaky effects accompanied by paper grain. A regular pattern (for example, the @Filters\Images\balls.png file provided with CC3+) can give an interesting effect, looking like a dot pattern gone wrong at certain settings. The idea of this filter is to add things that might be too tedious to do directly by hand (then again, maybe it's just my natural laziness).

    LoopysueMonsenroflo1

Answers

  • LoopysueLoopysue ProFantasy 🖼️ 39 images Cartographer

    The effect can also use an ordinary png image to generate the displacement.

    Not being a technical person I can't explain the exact maths, but the visual appearance of the image or normal map should give you an idea of what the displacement will look like.

    roflo1AleD
  • MonsenMonsen Administrator 🖼️ 46 images Cartographer
    edited October 2021 Accepted Answer

    The displacement is based on a normal map. A normal map is basically a grid of vectors encoded using RGB values so you can store it as an image. The vector encoded in each pixel basically determines the direction for the displacement effect at that point.

    The texture size tells CC3+ how to scale the texture you pick. If you want a single displacement image to cover the entirety of your map, set the effects units to map units, and the texture size to a value equal to the width (or height) of your map. If the value is lower than your map size, the displacement image will tile (which is usually the way you would use it).

    The displacement amount is basically the strength of the effect, i.e how much the pixels should be displaced. May need som experimenting to get this right, and don't be afraid of going to pretty large values.

    [Deleted User]Loopysueroflo1GlitchAleD
  • Interesting... So how do the 3 vectors (R,G,B) translate to a 2 dimensional plane?

  • Colors are not vectors. Vectors are two dimensional, point, lines, and curves that can be any color. These make the shapes. Probably the easiest way to think about it is that vector graphics use mathematical formulas to determine what to display. Meanwhile bitmap, often referred to as raster graphics, use pixels to make an image.

    What this means in practice is that bitmap images have a set number of pixels. This is not going to change. The larger the image is scaled, the larger those square pixels are going to be. Eventually it gets so big we talk about pixelization.

    On the other hand with vectors, there are not a set number of pixels. Based upon what is programed, the screen will render the image that is appropriate for the size. So a large image will not suffer from pixelization. It is drawn each time.

    This is why graphic cards do not improve CC3 performance. It is the CPU calculating all of the vectors and rendering the drawing as you zoom in, out, turn on effects, etc. and not the GPU doing the work.

    Glitch[Deleted User]AleD
  • MonsenMonsen Administrator 🖼️ 46 images Cartographer
    edited October 2021

    @JulianDracos you are mixing vector drawing entities here with mathematical vectors. A normal map is just a grid of (mathematical) vector represented as as an image. Each pixel represents a single vector, where the three directions are encoded as the red, blue and green channel in the pixel respectively. Thus, when a normal map is used with the distort effect, each vector tells which direction to move the pixel at that position in the rendered map.

    This is also very similar to how roof shading is done with CD3 buildings.


    @roflo1 I don't know exactly how it is done internally, but I assume it calculated as a 3D-space and then projected down to the 2D plane, and the projection used for the actual distort.

    Loopysueroflo1[Deleted User]AleD
  • @Monsen I am not an expert on these file types, but I am not sure if I got anything substantially incorrect. At least in how other vector programs describe how they work.

    Affinity, which makes both vector and raster design programs writes: "Vectors are drawn objects that are created using mathematical algorithms. They are made up of paths (think wireframe outlines!) which form the skeletal structure of the line, curve, shape, or text you draw. Each vector object’s path is controlled by adjusting nodes on the object’s path or by manipulating a surrounding bounding box; in addition, the object’s stroke and fill appearance can change with respect to colour, opacity, effect or adjustment."

    That same point that drawings are being made by following a mathematical formula are repeated here: https://www.shutterstock.com/blog/raster-vs-vector-file-formats and https://www.webdesigndev.com/raster-vs-vector/

    If CC3 does not work this way, then maybe it is not vector graphics? Or at least not how that term is being used in the graphical design space.

    I've always seen the difference as raster is a limited number of square pixels that make up an image, meanwhile vector is a set of mathematical instructions for drawing the image. Hence, in the former you can get pixelation, but in the later, it is unlikely because the image is redrawn to fit the scale.

  • MonsenMonsen Administrator 🖼️ 46 images Cartographer

    The point you are missing is that this question isn't about how CC3+ works, but rather about the Displace effect, which uses a normal map to generate the distortion. This doesn't have anything at all to do with vector vs raster or vector artwork. Your understanding is fine enough when it comes to these concepts, you have just missed the context of this discussion.

    A normal map uses color values to encode mathematical vectors as pixels, and these vectors aren't visible drawings like a vector line or polygon, but rather a mathematical vector that describes a direction in space. These vectors are expressed using 3 numbers, representing X, Y and Z directions. This is basically just maths encoded in an image form, and is used to calculate the final transform, for example to make the lovely ripples in Sue's Marine Dungeon maps.

    Loopysueroflo1
  • jslaytonjslayton Moderator, ProFantasy Mapmaker
    Accepted Answer

    The basic idea for how effects in CC3 work is that CC3 converts the current sheet's drawing entities into a raster image of that sheet, then applies effects to that intermediate sheet image to get a final sheet image. All of the individual final sheet images are composited together to get a final drawing output image that you see onscreen or write to disk during export.

    The displace effect takes a raster image stored on disk and use the pixels in that image as offsets for each pixel in the intermediate sheet image, allowing each pixel in the sheet image to be picked from some other location than the starting one. The red and green components of each pixel tell the direction to fetch the pixel from (red is horizontal, green is vertical, blue is ignored), while the effects "Displacement" parameter says how far away to fetch the pixel from. To make sure that things scale correctly, the "Texture Size" parameter says how many units (as specified by the "Effect Units" setting) the whole image occupies. For folks who like to see more mathematically-looking stuff, it's something along the lines of destinationSheetImage(x,y) = sourceSheetImage((x,y) + displacementImage((r-128)*scale,(g-128)*scale)) for each x and y in the sheet image.

    Then we get to the mystery "Image is a bump map" effect setting. When this checkbox is off, the input image directly specifies the displacements in the red and green image channels as described above. When it's checked, pixels in the input image are treated as grayscale height values and the normal map is computed as the gradient of that height image during loading. It's difficult to paint a pretty normal map by hand. You have to think in terms of individual channels and not red-green-yellow-brown-never blue-never white. It's usually a lot easier (maybe just for me, I'm not an artist) to think in terms of "this is high and this is low" and let the system figure out the crazy color stuff to point in the right direction. You can take a picture of some hay, for example, and call it a paper texture. That won't work particularly well for a straight normal displacement map, but will often work well for a bump displacement map.

    Why would anyone ever want to use a displacement map? A displacement map can be used to give fine-grained details to what would otherwise likely be a fairly dull drawing with straight lines. Careful choice of displacement map can give something similar to paper grain if chosen well. A displacement map with less high-frequency noise can give an effect reminiscent of a slightly-shaky scribe's hand. Combining two displacement effects on the same sheet can get shaky effects accompanied by paper grain. A regular pattern (for example, the @Filters\Images\balls.png file provided with CC3+) can give an interesting effect, looking like a dot pattern gone wrong at certain settings. The idea of this filter is to add things that might be too tedious to do directly by hand (then again, maybe it's just my natural laziness).

    LoopysueMonsenroflo1
  • edited October 2021

    Thanks @jslayton ... between your explanation and the initial one from @Monsen, I think that pretty much rounds everything that I needed to know.

    I'm not an artist either, but I do know my way around GIMP ... and since I know how to draw into each of the RGB channels separately, this should allow me to fiddle with the filter+map.

  • LoopysueLoopysue ProFantasy 🖼️ 39 images Cartographer
    edited October 2021

    For anyone else who's ears have just pricked up on hearing that you can do your own normal maps in GIMP...

    You can start with a height map (make sure it really is a height map with black as the deepest part and white as the highest part) and use Filters->Generic->Normal Map.


    roflo1
  • jslaytonjslayton Moderator, ProFantasy Mapmaker

    The "Image is a bump map" checkbox on the Displace effect will take the bump map (which is a term for a specific kind of height map) and calculate the normal map internally. On a regular normal map, the Z component of the unit vector is encoded into the B channel of the color, but the Displace effect completely ignores the blue channel of the image that it reads.

    Loopysueroflo1AleDWeathermanSweden
Sign In or Register to comment.