Jump to content

3d coordinates of the scene to 2d image coordinates


Recommended Posts

Hi im in houdini with a geometry that has a texture.

i render with a camera that has transform information such as translate, rotate, also the pixel aspect, focal lenght and aperture etc

 i render in 1920 x 1080

if i know the geometry points position in the 3d scene, how can i calculate in which coordenates in 2D 1920x1080 those points gonna finish at?

 

 

  • Like 1
Link to comment
Share on other sites

I'm not sure if Houdini has a quick and easy way to do this...?

Here's an article with a lot of detail about the process in a more general sense: https://www.scratchapixel.com/lessons/3d-basic-rendering/computing-pixel-coordinates-of-3d-point/mathematics-computing-2d-coordinates-of-3d-points

Don't know if that helps at all though.

Link to comment
Share on other sites

This might not be entirely correct (it's late), but you can use the transform node in VOPs to convert from world space to camera space. Then setup a wrangle node like this:

vector res = chv('res'); // Screen resolution
float focal = radians(chf('Focal_length')); // Cameras focal length in radians
float angle = 2 * atan(0.5 / focal); // View angle

float frustum = 2 * -@P.z * tan(focal * 0.5); // Cameras frustum size depending on the distance
vector screen = set( (@P.x / frustum) + 0.5, (@P.y / frustum) + 0.5, 0 ); // Relative screen positions
v@screen_pixel = set(res * screen); // Absolute screen positions in pixels

screen_pixel.hipnc

Edited by konstantin magnus
Link to comment
Share on other sites

  • 2 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...