Change render Space (Color Profile) - how?
-
Dear Dev Team,
I have a plugin that renders (Standard C4d Renderer - fastest for plain color at the time) a flat color rendering (no dithering, shading, or lights) of object display color (yes plain object color, no textures). Input and output have to be the exact same color, to evaluate if the camera "sees" an object. This plugin worked before 2025.2 with "sRGB linear" workflow.
Render output looks like this (the more objects the more colors of course):

Quick solution for me is to change the "Render space" to legacy "sRGB linear workflow"

Question: -> how would I do that in python ? (and back to the users render Color-space so it does not mess up the users settings)Is there a better way to get Input object color and rendered color to be exactly the same with no color space change? A color transform on the bmp? how would I do that?
thank you for your time
-
Hey @mogh,
the answer can be found in the OCIO examples, specifically here. In the example I do the exact opposite from what you want to do, I convert a scene from legacy/basic mode to OCIO. Its inverse would look somewhat like what I show below. I hope this helps.
Cheers,
Ferdinand"""Demonstrates how to convert a document from OCIO color management to basic color management. """ import c4d op: c4d.BaseObject | None # The primary selected object in the scene, can be None. doc: c4d.documents.BaseDocument # The currently active document. def main() -> None: """Runs the example. """ # The document is already in basic mode, so no conversion is needed. if doc[c4d.DOCUMENT_COLOR_MANAGEMENT] == c4d.DOCUMENT_COLOR_MANAGEMENT_BASIC: return c4d.gui.MessageDialog("The document is already in basic mode. No conversion is needed.") # Get the converter, and the active render space, which by default will be ACEScg. converter: c4d.modules.render.SceneColorConverter = c4d.modules.render.SceneColorConverter() renderSpace: str = doc.GetOcioRenderingColorSpaceNames()[0] # Initialize the converter with: # doc, from-low , from-high , to converter.Init(doc, renderSpace, renderSpace, "scene-linear Rec.709-sRGB") # Convert everything in the document (we pass the document itself as the second argument). The # undo management is only needed so that our DOCUMENT_COLOR_MANAGEMENT below is reversible. The # ConvertObject call creates undo steps on its own with the default flag we pass. doc.StartUndo() doc.AddUndo(c4d.UNDOTYPE_PRIVATE_DOCUMENTDATA, doc) if not converter.ConvertObject(doc, doc): print(f"Failed to color convert document '{doc}'.") # Finally, set the color management mode to basic/legacy. It is absolutely important that we do # things in this order, otherwise SceneColorConverter will not work correctly. doc[c4d.DOCUMENT_COLOR_MANAGEMENT] = c4d.DOCUMENT_COLOR_MANAGEMENT_BASIC doc.EndUndo() c4d.EventAdd() if __name__ == "__main__": main() -
Hi Ferdinand
Thank you for your Answer,I am trying to implement this, ... atm a lot of uncertain stuff at my end .... quick follow up question
How do i set the Color Profile of an object Color ? ( dragging object color to console only gives the vector )

Thank you
-
Hey @mogh,
you cannot do that, because we do not provide access to GUIs as always, only to the data structures that stand behind them. When you see this dropdown in a document, it means it is in OCIO mode. Which in turns means all colors are in render space; which is the main idea of OCIO that all computations happen in render space. All color read and write operations happen in render space, i.e., ACEScg by default. You can use a color converter to convert a color from for example sRGB to render space. But there is no color space setting for a color, that is just UI fluff. See GetSetColorValuesInSceneElements.
I would recommend to read:
Cheers,
Ferdinand