Page MenuHome

Project from View broken
Confirmed, NormalPublic

Description

System Information
Operating system: Win7
Graphics card: Titan X

Blender Version
Broken: 2.83.2
Worked: not sure

When using Project from View to texture some simple geometry with an image, vertices that are somewhat far away or behind the camera (or some unknown threshold) do not project correctly.

Create geometry where some of the geometry stretches far out of camera view, or is angled behind the camera.

The attached file is a very simple scene with a project from view unwrap, and one vertex has gone a little crazy and is in the wrong place. Instead of being far to the bottom right, it ends up far to the upper right.

blend file with packed image

Event Timeline

I can confirm this, but this seems like a limitation than a bug. Issue is that you are projecting vertices from behind camera. Also do you have reason adding @Sergey Sharybin (sergey) as subscriber?

You can cut your mesh like this to produce sensible UV

I was thinking, that maybe we can clip vertices behind camera like in following patch, but I don't think it would be possible to maintain correct geometry.

diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c
index 00fef29587c..3e655e529da 100644
--- a/source/blender/blenlib/intern/uvproject.c
+++ b/source/blender/blenlib/intern/uvproject.c
@@ -68,8 +68,8 @@ void BLI_uvproject_from_camera(float target[2], float source[3], ProjCameraInfo
     }
   }
   else {
-    if (pv4[2] == 0.0f) {
-      pv4[2] = 0.00001f; /* don't allow div by 0 */
+    if (pv4[2] >= 0.0f) {
+      pv4[2] = -0.00001f; /* Don't allow div by 0 and clip everything behind camera. */
     }

     if (uci->do_persp == false) {

I can confirm this, but this seems like a limitation than a bug. Issue is that you are projecting vertices from behind camera. Also do you have reason adding @Sergey Sharybin (sergey) as subscriber?

The reason Sean CCed me is because I've asked so. To me it is not so obvious why some of the points behind camera are projecting wrong. It is also not something what is intuitive from the projection happening in the motion solver.

You can cut your mesh like this to produce sensible UV

This wouldn't work for VFX usages, where camera is not still and might move/rotate, and projection happens from image sequence.

I was thinking, that maybe we can clip vertices behind camera like in following patch, but I don't think it would be possible to maintain correct geometry.

For the simple case this works, but if you subdivide the mesh few times in edit mode and project form view again then the UVs are broken again.

Interesting puzzle eh :)

If you need clearer example, I have moved camera a bit closer to corner of one plane so you can see better the situation. Edges coming from behind camera looks like they are diverging the closer they get to camera, but in reality they are converging to one single vertex. That's why I think it is impossible to make good UV, unless one vertex can be somehow represented by more "virtual" vertices in UV editor.


Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Mon, Sep 14, 6:23 PM

I can confirm this, ...

Please do so :)