Equation for image to world transform

The scripting guide shows the equation for world to image transform as:

aspect = session_width / session_height * session_pixel_aspect
new_p.x = (p.x / aspect + 0.5) * session_width
new_p.y = (p.y + 0.5) * session_height

Does anyone know the equation for image to world?


It’s just the reverse:

  1. Divide by image size
  2. Offset by -0.5 to put world center at 0,0
  3. Divide x by (image aspect * pixel aspect)

Thank you!

are you able to be more specific? its close but doesn’t give me the same results as image to world transform.

Are you using scripting? If so you can use the node.imageToWorldTransform() (which is just the inverse of the node.worldToImageTransform()).

aspect = session_width / session_height * session_pixel_aspect
world_p.x = ((image_p.x / session_width) - 0.5) * aspect
world_p.y = (image_p.y /session_height) - 0.5

Awesome thank you so much!!

The only thing is that in scripting I need to convert it again like this

sfx_point_3d = node.imageToWorldTransform * fx.Point3D(x, y)
sfx_point_3d = sfx_point_3d * fx.Point3D(1.0, -1.0, 1.0)

but I obviously cant multiply a float by a float when doing it out side of scripting, is fx.point3D flipping the world space?

the result I get in scripting is this -0.117593,0.302778
the result I get outside of scripting is this -0.117592,-0.302777

so the x value is on the wrong side of the 0.0,0.0 center

Remember the origin is 0,0 and is in the center of the scene. So a -x is perfectly OK if the coordinate is left of center.
Your Y-axis inversion is working correctly (your 0.3 → -0.3).
A simple test is to set up a SQUARE session with a 1.0 aspect. The corners of the scene in world coords would be:
top-left: -0.5,-0.5
top-right: 0.5,-0.5
bottom-right: 0.5,0.5
bottom-left: -0.5,0.5

Reminder that the Silhouette coordinate system is top-down, not bottom-up like in Nuke.

I don’t believe the y axis is working correctly,

the results I am trying to replicated are the ones produced by scripting
scripting gives me the result -0.117593,0.302778. That is correct and aligns with my image in silhouette.

The result I get from the formula you provided is -0.117592,-0.302777.

I get the same result in scripting if I omit this “sfx_point_3d = sfx_point_3d * fx.Point3D(1.0, -1.0, 1.0)”
From my scripting.

so the y axis is on the wrong side of center

Oh nevermind sorry, I think I was seriously missreading my output! THank you for your help