TrentL Posted January 17, 2024 Posted January 17, 2024 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? Quote
v_kyr Posted January 17, 2024 Posted January 17, 2024 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 ... https://www.educative.io/answers/what-is-displacement-mapping https://www.researchgate.net/publication/228860117_Displacement_Mapping http://ptgmedia.pearsoncmg.com/images/0321335597/samplechapter/pharr_ch08.pdf https://developer.nvidia.com/gpugems/gpugems2/part-i-geometric-complexity/chapter-8-pixel-displacement-mapping-distance-functions https://www.pluralsight.com/blog/film-games/bump-normal-and-displacement-maps https://guide.alightmotion.com/effects/displacement-map ... and so on ... TrentL 1 Quote ☛ 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
NotMyFault Posted January 17, 2024 Posted January 17, 2024 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. TrentL 1 Quote 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.
Recommended Posts
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.