1
$\begingroup$

enter image description herethe question seems quite simple but I can't find the solution : I generate an image from ia with a depth map associated. I want then to deform a subdivided plan with this map. No problem with displace node. However, I would like the direction of distortion to be relative to the camera rather than relative to the normals, which means that the rear of the projection would be larger than the front, depending on the focal length. Please refer to the attached image. thank you for your help!

$\endgroup$
1
  • $\begingroup$ Hello and welcome. Please use a title that matches the content of the post. It should read like a question, be descriptive but succinct, unique and identifying, summarizing the problem so anyone searching for similar issues is likely to find this. Remove anything superfluous, avoid vague words like "this", "help with", "issue", "like in image" "question about", instead describe what "it" is. Your title is the first thing visitors see, answers you get depend heavily on it. See What is the problem of asking “How do I do this?" $\endgroup$ Commented Sep 10 at 20:58

1 Answer 1

1
$\begingroup$

It's hard to do the full calculation in a Shader node network, because while you can get a Camera "View Vector" in camera coordinates, it's difficult to convert that to a world space displacement that you can feed to the Material Output node.

So, I think the right approach is to create a Geometry Nodes modifier on the plane, to calculate an appropriate unit vector displacement toward the camera and store it in a named attribute (here, "from_camera")

enter image description here

and a separate shader node network on the subdivided plane to scale these displacements by the depth map to calculate a world space displacement:

enter image description here

Note that the Geometry Node portion can run on a low-poly version of the plane (even just a 4-point plane) because its results will be interpolated. The subdivided geometry of the plane doesn't need to be "real" -- it can be generated by a Subdivision modifier placed after the Geometry Nodes modifier in the stack:

enter image description here

In my testing, I used a "Grid" instead of a "Plane", but the results should be the same.

Here's my result:

enter image description here

If I move the camera closed and exaggerate the depth map with the "Map Range" node, you can see it's deforming in the direction of the camera:

enter image description here

Here's my Blend file with an example setup.

$\endgroup$
1
  • $\begingroup$ thank you very much,but I can't still manage to obtain something good...! $\endgroup$ Commented Sep 10 at 16:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.