0
$\begingroup$

I am creating synthetic documents using the following method:

I take a mesh of a page, mesh

add to it the texture from a pdf file texture

add a bit of random rotation, and render. final rendered image

All of this is done via the bpy python interface. I would need to find out the location of a point from the texture in the world of the final rendered image. Specifically, I would like to feed the rendering script a list of coordinates from the original texture and output the corresponding list of coordinates from the rendered image.

In short: what I want

Thanks!

$\endgroup$
2
  • 1
    $\begingroup$ I don't quite understand that you want to do. It seems you can use UV pass somehow $\endgroup$
    – Crantisz
    Commented Oct 14, 2021 at 13:40
  • $\begingroup$ I added an image at the end to make clear what I am trying to do. Thanks. $\endgroup$
    – saseptim
    Commented Oct 14, 2021 at 15:00

1 Answer 1

1
$\begingroup$

In cycles you can enable UV pass in view layer settings:

enter image description here

Using this layer, you can get a UV coords position of each point on render. Red color corresponds to U and Green - to V.

enter image description here

So if you want to find a specific point on source image, get X and Y coordinates and get the color from formula: RGB(X\width, Y\height, 100%), then find the closest color in UV layer. Color information should be saved in EXR to avoid Rec709 <-> sRGB color transformations.

$\endgroup$
2
  • $\begingroup$ This works great! Thanks! However, searching for each point of interest in such a large grid is quite time consuming. Does perhaps the bpy interface have a command which can do this quickly? Otherwise, I will try to build an optimized search in the area which I think the next point should be. $\endgroup$
    – saseptim
    Commented Oct 17, 2021 at 7:49
  • $\begingroup$ I managed to achieve a much faster search using gradient descent. Thanks! $\endgroup$
    – saseptim
    Commented Nov 30, 2021 at 16:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .