Jump to content

How to get unpremultiplied values from .png with rawcolormap()


Knabbelhimself

Recommended Posts

Hi everybody,

I have already posted this question on the SideFX Technical Discussion forum but had no luck so far. Maybe someone here could help me? 

I am trying to get raw color values from an RGBA .png file with the vex function rawcolormap() but it appears that I can only get pre-multiplied values. When using .tif, color values appear to be correct. I am loading the the image as linear even though it is in gamma 2.2 to prevent gamma conversion. Here is my vex code:
 

vector4 rgba = rawcolormap(chs("texture_map"), U, V, "srccolorspace", "linear");

v@Cd.x = rgba.r;
v@Cd.y = rgba.g;
v@Cd.z = rgba.b;
@Alpha = rgba.a;


For testing I have created a simple test image where all color channels have a value of 1.0 and the alpha channel has a gradient from 0 to 1. Please see attached image.
Opening the image in Photoshop and Gimp shows unpremultiplied color channels. When using above VEX code, color channels are premultiplied against the alpha channel. And opening the image in Mplay, results are even more confusing. Pixel inspection here shows values that I can only recreate by opening the image (which is in gamma 2.2) defined as linear and then applying a second gamma conversion from linear to sRGB.

unpremultplied_png_houdini.thumb.png.5bb51e185b273dfa78a2c8dd8e5b06f4.png

Does anybody know why this is and how to work around this problem? 
Thanks to anyone taking an interest. 
Cheers

Edited by Knabbelhimself
Link to comment
Share on other sites

After some further testing I am still struggling with this. I have found a workaround by first loading the texture in a cop network with the file cop which has a “leave unpremultiplied” option and then referencing the file cop as texture in the attrib wrangle.

Is there no such option available in VEX to avoid the detour through a cop network?

Also with a function named “rawcolormap” would the expectation not be to receive unpremultiplied values by default as it is less destructive?

Thanks

file_unpremultiplied.png

Link to comment
Share on other sites

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...