pixelCenter


#1

Hello

I want to be able to have a 3d world space position (a locator) translated into a 2d screen space position.
The samplerInfo node has an attribute “pixelCenter” that seems to provide exactly that…

from the docs:
Pixel Center gives you the location of the pixel in the final image that corresponds to the point being sampled.

but how do I access these data?

I also looked at this script
http://www.185vfx.com/2003/03/convert-a-3d-point-to-2d-screen-space-in-maya/
but I found that if I work with an extreme device aspect ratio (like 2000 by 200 pixels) and I position an object exactly in the lower left corner of the resolution gate, it does not return exactly 0 for x and y. More like 0 and 0.4, meaning it thinks the y position is almost halfway into the total height of the image.

Any suggestions would be helpful.

thanks, C


#2

I think samplerInfo is working only at rendertime and I believe it outputs it’s informations only for the shaders.

The infos from the website should work, but it doesn’t take the camera film back into account.
Wich means you either have to modify the code so it does, or change your film back aspect ratio so that it matches your image’s aspect ratio.

Pascal.


#3

Thanks Pascal,

I modified the script, as you suggested, and it works perfect now.
Actually the script had some consideration for film back aspect built in, only it did not compensate for image aspect in the render settings.
Got it working now.

Cheers, C


#4

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.