1
$\begingroup$

I wrote a Python script to automate my rendering workflow (run from command line with --background).

The problem is that the resulting colors are different from the desired colors that are rendered in the GUI. Python result appears washed-out. Same incorrect result when the script is executed in Blender GUI.

Files are saved as .png. Blender 2.91.2.

GUI result (correct): enter image description here

Python (incorrect): enter image description here

Relevant Python code (simplified):

scene.frame_set(0)
bpy.ops.render.render(use_viewport=False, write_still=False)
bpy.data.images["Render Result"].save_render('./example.png')

A similar but not identical result is reached by changing:

  • Render Properties -> Color Management -> Display Device -> None
  • Render Properties -> Color Management -> Gamma -> 1.2 instead of 1.0

then saving the file and running the script.

It seems that there is a difference between settings in GUI and in Python. I've played a lot with different configuration values inside the Python script prior to rendering but this brought me no closer to the desired result.

This is as far as my competence goes, but I would like to better understand the issue and achieve an identical result in my Python script.

Edit: the rendered model is imported from an .fbx file

$\endgroup$
2
  • $\begingroup$ Does using save instead of save_render work? (I think you might be going through the color transform twice.) Otherwise you could use write_still=True after setting the scene to render to the file you want. $\endgroup$
    – scurest
    Jan 24 at 21:42
  • $\begingroup$ @scurest - bpy.data.images["Render Result"].save() throws Image 'Render Result' does not have any image data. Setting scene.render.filepath and using write_still=True instead of save_render gives the same result. $\endgroup$ Jan 24 at 22:34
0
$\begingroup$

Gotcha!

My script would pull a HEX color value and try to set it onto an RGB material node primitively without adjusting for gamma correction. The following answer helped me:

How set Hex in RGB Node? (Python)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.