Author Topic: Problem with rendering difference between manual and python  (Read 1536 times)

2024-06-21, 09:54:14

raffaele.tortora88

  • Users
  • *
  • Posts: 3
    • View Profile
Goodmorning everyone,
i've the following problem. I have a c4d file which render well with right illumination when i render it from Cinema4D manually. Instead, when i run mi python script all is dark, illumination doesn't work.
I use following code:

    # Crea un nuovo bitmap
    bmp = bitmaps.BaseBitmap()
    if bmp is None:
        return

    # Ottieni le impostazioni di rendering correnti
    rd = doc.GetActiveRenderData()
    # Imposta la risoluzione del bitmap
    bmp.Init(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]))

    # Esegui il rendering
    result = c4d.documents.RenderDocument(doc, rd.GetData(), bmp, c4d.RENDERFLAGS_EXTERNAL)
    if result == c4d.RENDERRESULT_OK:
        bmp.Save(output_file, c4d.FILTER_PNG)
        print("Rendering completed successfully.")
    else:
        print("Error during rendering.")

Seems there are some settings (like Global Illumination) which are not used when i run render from script.

Can you give me some support?

Thanks in advance

2024-06-21, 16:39:50
Reply #1

BigAl3D

  • Active Users
  • **
  • Posts: 963
    • View Profile
Why are you rendering with a Python script? Just curious.

2024-06-21, 19:27:29
Reply #2

John_Do

  • Active Users
  • **
  • Posts: 250
    • View Profile
The gamma correction is missing on the version saved through Python. I think it's handled by C4D Picture Viewer but it's bypassed in this case, so you have to find a way to add it to your bitmap before saving.



2024-06-24, 10:57:55
Reply #3

raffaele.tortora88

  • Users
  • *
  • Posts: 3
    • View Profile
Hi,
thank you very much for your reply.
My project regard rendering automation. I've developped a python script which elaborate a JSON with some operations (import object in scene, change material, move object...) and at the end make render.

John_Do, i've tried to execute gamma correction on saved image but with not good results. Can you please suggest me which kind of correction have you made on the example picture you have posted?

Thank you very much.

2024-06-24, 14:24:41
Reply #4

John_Do

  • Active Users
  • **
  • Posts: 250
    • View Profile
John_Do, i've tried to execute gamma correction on saved image but with not good results. Can you please suggest me which kind of correction have you made on the example picture you have posted?

It's just an Exposure layer in Photoshop with the gamma value set to 2.2, nothing fancy!

2024-07-04, 16:25:48
Reply #5

raffaele.tortora88

  • Users
  • *
  • Posts: 3
    • View Profile
i've resolved the problem changing creation of bmp using method MultipassBitmap:
# Ottieni le impostazioni di rendering correnti
    rd = doc.GetActiveRenderData()
    # Crea un nuovo bitmap
    # bmp = bitmaps.BaseBitmap()
    bmp = bitmaps.MultipassBitmap(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]), c4d.COLORMODE_RGB)
    bmp.AddChannel(True,True)
    if bmp is None:
        return
    # Imposta la risoluzione del bitmap
    #bmp.Init(x=int(rd[c4d.RDATA_XRES]), y=int(rd[c4d.RDATA_YRES]), depth=32)
    # Esegui il rendering
    result = c4d.documents.RenderDocument(doc, rd.GetData(), bmp, c4d.RENDERFLAGS_EXTERNAL)
    if result == c4d.RENDERRESULT_OK:
        bmp.Save(output_file, c4d.FILTER_PNG)
        print("Rendering completed successfully.")
    else:
        print("Error during rendering.")

Thanks you all for your suggestions