kleer001 Posted March 18, 2016 Share Posted March 18, 2016 Given a camera name and a point in space how do I figure out how big a pixel will be there? Quote Link to comment Share on other sites More sharing options...
djiki Posted March 19, 2016 Share Posted March 19, 2016 if you render points, each point have PSCALE attribute (if attribute doesn't exist, default value is 0.01) which define how large "sphere" or circle will be.at render time. Mathematical point have no size so it would be invisible. So your question is incomplete. Better question would be How large area is covered by single rendered pixel at some distance from camera in camera projection space? U can visualize that. Create some noise pattern in photoshop that each pixel have noticeable different color, save it, and use it as projection texture from your camera.on grid which is parented to that camera and oriented to be perpendicular to it. In quick shading mode with constant shading option you will see that patern on the grid in viewport. Now if you move that grid along Z axis away from cam and look it from user view (not from projecting camera) you will see pixels increases when you muve it away from cam. Thats the size of pixel at that specific distance. Also notice if you are looking through projected cam doesnt matter how grid is away from it you can not see pixels change it's size because you are looking through camera projected space. Quote Link to comment Share on other sites More sharing options...
anim Posted March 20, 2016 Share Posted March 20, 2016 string cam = "/obj/cam1"; vector res = chv(cam + "/res"); float aperture = chf(cam + "/aperture"); float focal = chf(cam + "/focal"); vector pos = ptransform(cam,@P); float pxwidth = length(pos)*aperture/focal/res.x; f@pscale = pxwidth / 2.0; // use half of pixel width if pscale is radius otherwise use just pxwidth 5 Quote Link to comment Share on other sites More sharing options...
kleer001 Posted April 1, 2016 Author Share Posted April 1, 2016 Thanks so much Tomas! I had some suspicion it might be a matter of simple multiplication. Quote Link to comment Share on other sites More sharing options...
djiki Posted April 2, 2016 Share Posted April 2, 2016 That is a simple cam projection (like viewport) calculation and it doesn't take into account lens parameters like focus distance, f-stop, circle of confusion, lens distortion which rendered pixel size at some distance depends on them too. It will give you results at SOP level related to viewport cam (that is probably only you want) but If you are writing your custom DOF shader or COP VOP node and you need rendered pixel real size at some distance you will have to include math with those parameters too. 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.