Get RAW Pixel color in COP?

   3588   10   2
User Avatar
Member
86 posts
Joined: Jan. 2015
Offline
Is it possible to get the RAW pixel color inside of vops/vex for COPs? We have 32bit images where we encode an object's id in the raw rgb values, but I can't seem to find a variable that gives me access to those values (only the rgb float values seem to be available).
User Avatar
Member
1736 posts
Joined: May 2006
Offline
I might be misunderstanding your question, but you should be able to get at those values with a texture vop.

You can see in the attached hip I make an image with arbitrary crazy rgb values, then in a point vop I can read that back in as rgb, and the full precision of the number is maintained.

Attachments:
cops_read_value.hip (135.0 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
86 posts
Joined: Jan. 2015
Offline
Sorry more specifically, with a 32bit Integer image depth, I would like to get the integer color values.
User Avatar
Member
86 posts
Joined: Jan. 2015
Offline
mestela
You can see in the attached hip I make an image with arbitrary crazy rgb values, then in a point vop I can read that back in as rgb, and the full precision of the number is maintained.

I need to be able to get the color value inside of a COP VOP Generator (sorry should have been more specific). In the example scene you offered (thanks btw), the color depth is 16bit float, and the colors are accessible via the R -G - B outputs in the generator VOP's global node. There doesn't seem to be a global output for the integer color values.
User Avatar
Member
86 posts
Joined: Jan. 2015
Offline
Like I can see the integer values when I use the pixel inspector (hitting the ‘i’ key in the Composite view), but I can't get them in the vop node.
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
Colors are floats in cops.
User Avatar
Member
1736 posts
Joined: May 2006
Offline
Ah right, now I get you.

Hmm, nothing leaps out I'm afraid. I saw that there's unpack_intfromsafefloat, but I suspect the int values it's expecting aren't the same as what cops is generating. Maybe you could read the black and white points that are exposed as parameters when you define a 32bit integer, and use those to multiply the floating point version?
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
86 posts
Joined: Jan. 2015
Offline
After playing around a bit more I was able to figure out how to get the integer values. I can take the incoming rgb value and do:
$RGB * ((2 ^ 31) - 1) / 2

…and write that out to a new 32f plane. For context (2 ^ 31) - 1 is the limit of a 32b integer, and I have no idea why I have to divide by two but it works so I'm not gonna knock it.
User Avatar
Member
385 posts
Joined: July 2018
Offline
The color picker in COPS shows only 4 digits of precision, 0.6028 and is the rounded version of the Cd attribute i am importing from SOPs 0.60275.
I can see the final exr in photoshop also has the rounded value so its not the color picker.

My default depth is 32bit FP
So i guess its not the exporter either

Is there a fix?
Edited by papsphilip - March 15, 2022 14:15:25

Attachments:
1.JPG (31.2 KB)
2.JPG (63.3 KB)
3.JPG (35.2 KB)

User Avatar
Member
8520 posts
Joined: July 2007
Online
chendryx
and I have no idea why I have to divide by two but it works so I'm not gonna knock it.
it may be a signed 32bit integer, so half precision for negative and half for positive, in which case divide by 2 would make sense
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
86 posts
Joined: Jan. 2015
Offline
tamte
it may be a signed 32bit integer, so half precision for negative and half for positive, in which case divide by 2 would make sense
ah that's a good point!
  • Quick Links