Jump to content

Recommended Posts

Posted

I'm looking into the Displacement map feature in Affinity Photo (which works really nicely as a live filter, BTW).

I was wondering if there is a simple explanation of the mathematical basis for how it works? I found Normal Maps to be fairly well explained online, but I could not find a similar explanation for Displacement Maps. 

As far as I can tell, values > 50% will move the pixel up and left, whereas values < 50% will move them down and right. Is there any more nuance that one should know?

Posted
Quote

Displacement mapping is a technique used in computer graphics to add details to the surface of a 3D model. While other mapping methods, such as bump mapping and normal mapping, only affect the lighting, displacement mapping modifies the actual shape by displacing the surface vertices along their normal. 

It allows for creating complex shapes and details, like wrinkles on the skin or scales on the lizard, by casting shadows which look realistic from every angle.

How it works

A displacement map is a texture that stores the height information of the 3D model.

The map is a grayscale image where lighter values represent larger displacement and darker values represent smaller displacement.

The displacement values are then used to push the vertices along the normal vectors of the 3D models, thus effectively changing the shape.

In displacement mapping,

  • Every vertex on the surface of the 3D model is displaced along its normal vector (n) by an amount that is determined by the value (d) from the displacement map.

  • The displacement is then applied to the original position (p) of each surface point.

The mathematical expression is as follows.

 
         p=p+d(p)n
 

Where,

  • p′ is the new position of the surface point after displacement

  • p is the original position of the surface point

  • d(p) is the displacement value obtained from the displacement map for the given surface point

  • n is the normal vector at the surface point

 

See related ...

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Posted

Affinity offers two methods to interpret displacements. 
the older one is using red/green color channels for x/y direction, and seems to be Affinity specific (incompatible with Photoshop version of filter using the same name).

my laymen’s interpretation: the delta between neighboring pixels color values defines the distance the pixel is shifted (displaced), multiplied with the strength factor.

the newer method is called sobel 3x3

https://en.wikipedia.org/wiki/Sobel_operator

And (when memory serves me well) more in line how other apps implement this function and what v_kyr described.

For practical uses, you cannot shift every pixel independently from neighboring pixels, because always the delta is used to calculate both direction and distance. I mention this because I tried to use the live filter version as a kind of surrogate for the (destructive) move tool to shift pixel content and controlling direction with the other layer content, but this makes such an approach impossible.

 

Mac mini M1 A2348 | MBP M3 

Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.