Convert vertex color from linear on import to sRGB on export

   716   9   1
User Avatar
Member
73 posts
Joined: April 2020
Online
Hello Experts,

I have what I think must be a simple task, but the things I've tried aren't behaving as I'd hoped. I have a part I import in *.glb format. I believe Houdini assumes a linear color space for this part on import? (How can I check that this is really the case?) The part uses vertex color. I need to export the same part in sRGB space -- again using vertex color. This means I need to get the converted colors actually onto the vertices.

I've tried using ctransform() in a wrangle, running the wrangle over vertices, and assigning each new color to the vertex in question. The problem is, if I leave the "from space" argument along and just use rgb as the "to space" nothing changes. Does this mean I'm wrong about how the part was imported? But I'm also unclear on what I should enter for the "from space". The options are "rgb", "hsl", "hsv", "XYZ", "Lab", and "tmi". But how can I tell which, if any of those, matches the import color space?

Any suggestions for what to do would be most welcome.

In my example I start with a part I create, since I'm unfortunately not allowed to share the part I'm actually using. But I see the same behavior with the actual part, so I hope this is okay. Also, I'm using primitives instead of vertices in the example, since it's just easier. I'm running Houdini version 19.5.435.

Thanks very much,
Mary

Attachments:
color-test.hip (117.1 KB)

User Avatar
Member
8554 posts
Joined: July 2007
Offline
you most likely want to use ocio_transform() not ctransform()

the easiest is to use VOPs since OCIO Transform VOP has the dropdowns with colorspaces to choose from
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
73 posts
Joined: April 2020
Online
Thank you, Tomas -- I really appreciate all the answers you have given me to so many questions.

I think it's looking like I need to do some learning about OCIO.

Best wishes,
Mary
User Avatar
Member
73 posts
Joined: April 2020
Online
Hello Tomas (or anyone else),

Your help did the trick for all the parts I had to convert that had vertex color. I assume it's possible to do the same thing for parts with textures instead -- but I'm not seeing how. Do you have suggestions? I tried hooking up texture attributes instead of Cd in the VOP you suggested, but clearly I'm either doing this wrong or it's not the right approach, because the color of the textures isn't being converted.

Thanks so much,
Mary
User Avatar
Member
17 posts
Joined: May 2023
Offline
Gama 2.2 to 1
User Avatar
Member
7770 posts
Joined: Sept. 2011
Online
mgbaker
Hello Tomas (or anyone else),

Your help did the trick for all the parts I had to convert that had vertex color. I assume it's possible to do the same thing for parts with textures instead -- but I'm not seeing how. Do you have suggestions? I tried hooking up texture attributes instead of Cd in the VOP you suggested, but clearly I'm either doing this wrong or it's not the right approach, because the color of the textures isn't being converted.

Thanks so much,
Mary

In what context are we asking about? I'm not aware of any where texture conversion take place. The bake texture nodes I think can convert to an srgb color space when the target format requires it, but I don't know if they are ocio aware. The other exporter tools that include textures like gltf or fbx or usdz do a simple file copy without conversion afaik.
User Avatar
Member
73 posts
Joined: April 2020
Online
Thanks, jsmack. Here's the context: I need to automate bringing in a bunch of glb files that have textures. They come in using "Utility - Linear - sRGB" space and this makes the dark colors too dark. I *was* doing an attributefrommap to convert them to point color and then converting that color to "Input - Generic - sRGB - Texture". But the meshes and textures of the input files have been refined, so that now you can see that converting to attributefrommap makes the results look pretty ragged even when I bump up the mesh density a lot. So unless I can find a way around that, I'd like to make sure I export the models with textures using the sRGB color space. I was hoping there is a way to do that. Unless that doesn't make sense?

Thanks, liang, for responding. Unfortunately I don't think I understand your response -- would you be willing to expand on it?

Thanks so much,
Mary
User Avatar
Member
73 posts
Joined: April 2020
Online
Poking around I've found Houdini's "iconvert" which sounds like it would convert images to different color spaces. But it doesn't seem to be doing that. For instance, the following command makes no difference to the colors:

iconvert original_file.png converted_file.png --fromcolorspace "Utility - Linear - sRGB" --tocolorspace "Input - Generic - sRGB - Texture"

Does anyone know how I can use this correctly? Or does it not do what I was hoping it would do?

Thanks again,
Mary
User Avatar
Member
8554 posts
Joined: July 2007
Offline
If you want to convert the texture files you can use hoiiotool, which is houdini's branch of oiiotool included with Houdini install

Or use OpenImageIO TOP
Edited by tamte - March 17, 2024 18:38:07
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
73 posts
Joined: April 2020
Online
Thanks, Tomas! hoiiotool works very well for me!

Best wishes,
Mary
  • Quick Links