traiano Posted June 16, 2017 Share Posted June 16, 2017 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? 1 Quote Link to comment Share on other sites More sharing options...
localstarlight Posted June 16, 2017 Share Posted June 16, 2017 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. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted June 16, 2017 Share Posted June 16, 2017 (edited) 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 June 16, 2017 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
traiano Posted June 17, 2017 Author Share Posted June 17, 2017 thank you very much konstantin and steve, i will proceed with these stufff you mention. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted June 17, 2017 Share Posted June 17, 2017 Hmm ok, after reading jsmack`s post in your other thread about this on the SideFX forums this would be the code, I guess: string cam = chs('Camera'); vector res = chv('Resolution'); v@pos = toNDC(cam, @P); v@pix = @pos * res; What are you trying to do, anyways? Quote Link to comment Share on other sites More sharing options...
traiano Posted June 19, 2017 Author Share Posted June 19, 2017 I'm doing sinthetic data to train neural networks with cg rendering Quote Link to comment Share on other sites More sharing options...
traiano Posted June 19, 2017 Author Share Posted June 19, 2017 Konstantin the coordenates doesnt seem to match in the render output, screen pixel x is almost similar to what it should be, screen pixel y seems to be inverted Quote Link to comment Share on other sites More sharing options...
traiano Posted June 19, 2017 Author Share Posted June 19, 2017 For houdini the lower right corner of a render output seems to be 1280 x 0 instead of 1280 x 720 Quote Link to comment Share on other sites More sharing options...
traiano Posted June 19, 2017 Author Share Posted June 19, 2017 toNDC is not predicting well the pixel in the output Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted June 19, 2017 Share Posted June 19, 2017 I guess its assuming a square shaped image. probably the height value has to be multiplied by the aspect ratio. Quote Link to comment Share on other sites More sharing options...
traiano Posted June 28, 2017 Author Share Posted June 28, 2017 the aspect radio is 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.