Author Topic: incorrect alpha with opacity  (Read 2289 times)

2023-03-08, 11:17:07

Tok_Tok

  • Active Users
  • **
  • Posts: 121
    • View Profile
Hello,

I'm having a bit of a problem. When I render a glass material with 0.5 opacity value the alpha channel is not the same when saved to a PNG. It's much less visible. Doing the reflections in post is a pain in the a** because of the bloom&glare that's in the image.

Example:


How can I fix this?

2023-03-08, 14:15:29
Reply #1

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13130
  • Marcin
    • View Profile
Hi, are you a C4D or Max user?

If you render your scene ("Corona VFB") with pure black background and then do your compositing in PS, is it any better or is there still a problem?
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2023-03-08, 16:08:14
Reply #2

Tok_Tok

  • Active Users
  • **
  • Posts: 121
    • View Profile
I'm on Max

The problem persists with a black background and to my suprised I actually have the problem with a normal basic glass shader. When saving to a PNG the alpha channel is not correct.

The last time I worked with Corona was with version 6 I think, I don't think this was an issue at that time.

-Joep

2023-03-08, 17:59:57
Reply #3

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13130
  • Marcin
    • View Profile
Just to make sure:

You would like to render your scene once (some solid glass objects) and then load it into Photoshop or other post-processing tool and change the background color?
Then you would like to get results as similar as possible to rendering the same scene in 3ds Max with a different background? (for example blue, yellow, red, whatever color)

Please confirm that this is what you would like to do.

It was surprising to me, but for some reason this is really hard to do (at least with solid glass boxes). I haven't found a good way to do it yet using CMasking, Alpha, Cryptomatte, Photoshop, and Fusion. :)
What I have noticed is that if you enable mask propagation for your glass objects, this works fine in CMasking render elements, but not in the default Alpha element. This seems to be unexpected so I will log it, but unfortunately it does not help with the above scenario.
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2023-03-09, 10:07:33
Reply #4

Tok_Tok

  • Active Users
  • **
  • Posts: 121
    • View Profile
Yes, partly. The bg color cannot change too much obviously because then it would be visible in the alpha, there is no way around that as the semitransparant pixels are set to certain color. I know the background color of the presentation but there is a slight gradient so to do this correctly I need an alpha channel. At the moment the alpha channel just isn't correct because the result in photoshop is not the same as in the VFB, which should be the case according to an old video about compositing on the Corona youtube channel. Like I said, this used to work in older versions of corona. FYI I'm using the Legacy material, I'll try if the new material has the same error but this should work either way.

I guess it's harder to do with glass boxes because it's much easier to spot the errors. With a more complex object it's also wrong be harder to see. But still the difference is huge, VFB vs Photoshop.

Can you tell me how Mask Propagation works for you? I enabled it in the material but don't see any difference in the Cmasking element. Cmasking element only gives opaque masks as for as I know.

2023-03-09, 10:12:52
Reply #5

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13130
  • Marcin
    • View Profile
Ok, I think one solution is to rebuild the image from CESSENTIAL render elements. I am attaching an example with background color changed in Photoshop.

Quick how to:
Set up your scene
Go to Scene > Scene Environment > Overrides, set Direct, Reflections, and Refractions environment overrides to pure black
Add all render elements starting with CESSENTIAL
Render
Click-and-hold on the Save icon in the VFB, select "Save all"
Save as EXR with alpha channel, 32-bit
Load your files into Photoshop (I recommend using the EXR-IO plugin as it gives some extra controls, for example on how to treat transparency)
Create a solid color layer for the background
Place your direct lighting layer as the bottom layer (above the background layer) and leave its blending mode at "Normal"
Select all layers above direct lighting and set their blending modes to "Linear Dodge (Add)"
You can then change the background color

More info: https://docs.chaos.com/display/CRMAX/Render+Elements#expand-BasicRenderElementCompositing
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2023-03-09, 10:14:29
Reply #6

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13130
  • Marcin
    • View Profile
And I just realized the glass objects have the black "borders" again... :/
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2023-03-09, 10:19:53
Reply #7

Tok_Tok

  • Active Users
  • **
  • Posts: 121
    • View Profile
Aren't those black borders from the environment? This looks correct to me.

I just discovered that when I save the alpha channel as a separate jpg (also tried tiff) the output image is a lot different than what I see in my VFB. So that's very strange, the saved image should be at least the same as what I see in my VFB.

2023-03-09, 10:25:52
Reply #8

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13130
  • Marcin
    • View Profile
This is the VFB result with the same scene - no black borders.
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2023-03-09, 10:28:08
Reply #9

Tok_Tok

  • Active Users
  • **
  • Posts: 121
    • View Profile
Ah yes I see.

Did you change the teapot to be half transparent later? Because that's also not changing in the renders you did before.

2023-03-09, 10:29:20
Reply #10

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13130
  • Marcin
    • View Profile
It's not half-transparent, it's just lit by the purple environment lighting. :)

But that may be causing some issues, let me double check...

Update: nope, it doesn't change the black borders
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2023-03-09, 10:33:56
Reply #11

Tok_Tok

  • Active Users
  • **
  • Posts: 121
    • View Profile
Oke so the way I fix it now it saving the alpha separately and adding that as a mask in photoshop. Then I adjust the mask with a Levels adjustment until it looks similar. But I just noticed that I see lose some reflection and can't get it back.

But are extra steps I don't want to have to make so I'm still curious why this is happening and if it will be fixed soon. Maybe I should try to go back to an older version see if this is also happening.
« Last Edit: 2023-03-09, 10:40:23 by Tok_Tok »

2023-03-09, 12:02:23
Reply #12

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13130
  • Marcin
    • View Profile
I think I have one solution here, but I would like to make sure I understand the issue first.

You would like to render your scene once in 3ds Max, then load it into PS, and change the background color so that you get the correct direct visibility, reflections, and refractions?

Or maybe it is something completely different?

What is your end goal?
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2023-03-09, 12:16:52
Reply #13

Tok_Tok

  • Active Users
  • **
  • Posts: 121
    • View Profile
I need to be able to save an image as a PNG with an alpha channel so that they guy who I send it to can put it in his Powerpoint presentation. The background of that presentation is similar to the background color I set in 3ds max but the brightness or tone can vary a little. In the past this wasn't a problem but now it is. So I shouldn't need photoshop to do anything. The reflections and transparency need to be the same as in my VFB. In my scene I have only my environment as a background.

Hope this is clear :)

2023-03-09, 14:50:38
Reply #14

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13130
  • Marcin
    • View Profile
How exactly are you changing the transparency of your glass materials?
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us