3
$\begingroup$

Bit of an issue here, trying to render this glass scene

enter image description here

Looks fine in the viewport, but when I hit render

enter image description here

Does anyone know the cause of different view port and final render, and how to fix it?

Here's my Blend File

$\endgroup$
  • $\begingroup$ Check under the outliner if you lamp object is not set to visible but non-renderable $\endgroup$ – Duarte Farrajota Ramos Jun 30 '16 at 17:40
  • $\begingroup$ It isn't. I tried creating a new lamp just in case but no luck $\endgroup$ – QFSW Jun 30 '16 at 18:23
  • $\begingroup$ You might need to add more info to your question if you want a proper answer then. Maybe render settings, scene outliner screenshot, or possibly a link to download your Blender file $\endgroup$ – Duarte Farrajota Ramos Jun 30 '16 at 18:32
  • $\begingroup$ dropbox.com/s/lzx69p1yclnt98g/NewHUD4.0.blend1?dl=0 Here is the link, I have insufficient reputation to add more than 2 $\endgroup$ – QFSW Jun 30 '16 at 19:02
  • 2
    $\begingroup$ @DuarteFarrajotaRamos there are issues with the render viewport and transparency and emissions. See answer. $\endgroup$ – cegaton Jul 1 '16 at 6:56
4
$\begingroup$

What you are experiencing is a limitation of the render viewport. Sadly it is broken and has issues displaying the mix of transparency and luminescent (emission or reflections) correctly.

Your information is there, your file is fine, but is not being displayed correctly.

Trying to view the render using the default Color+Alpha will not work.

enter image description here

You can choose to ignore the display and composite normally.You'll see that once you overlay your rendered layer image on top of something else things are correct.

For example if you overlay your image on top of a color background using Alpha Over you'll see what I mean:

enter image description here

Note that if you save the image using the .png or .Tif format the error will persist, as the alpha channel will be unassociated. (see this link for a deeper explanation)

If you save the image as an EXR file you'll be able to preserve the transparency and emission you are looking for.

somehow related posts:

https://blender.stackexchange.com/a/44148/1853

https://blender.stackexchange.com/a/44137/1853

$\endgroup$
  • $\begingroup$ Ah nice one, I stumbled around but couldn't figure anything else out. I did notice that turning off alpha display in the image viewer seemed to approximate both images, but couldn't progress any further. Thanks for the explanation $\endgroup$ – Duarte Farrajota Ramos Jul 1 '16 at 7:50
  • $\begingroup$ If i was to do this how would i convert the openEXR into a png? $\endgroup$ – QFSW Jul 1 '16 at 17:59
  • $\begingroup$ what is the purpose of this images? Why do you need them in png? $\endgroup$ – cegaton Jul 2 '16 at 0:30
  • $\begingroup$ I'm using them in a game as a HUD. The HUD info will be between different layers, so i need to render them as pngs with transparency $\endgroup$ – QFSW Jul 2 '16 at 8:39
  • 1
    $\begingroup$ Cegaton's replies already covered the problems with unassociated alpha from the compositing point of view, but I'd like to add that alpha channel isn't the most effective for compositing glass transparency. Keep in mind that a proper glass does both reflection and refraction, and while the reflection component could be composited with an alpha blend the refraction can't. So keep in mind that glass will never look ok from an alpha over comp. $\endgroup$ – Gez Oct 16 '16 at 14:30
4
$\begingroup$

If you need to produce a PNG file you have to know that the format uses "unassociated" alpha.

That means that the program that will do the compositing will "pre-multiply" foreground's RGB*alpha prior to adding it to the background plate.

This is important to know because it means that every pixel with alpha=0 will lose its RGB data (because multiplying anything by 0 gives 0).

Associated alpha, as Cegaton explained, allows you to have pixels that are both emissive and fully transparent, but that kind of information can't be expressed in a PNG file.

In order to transfer the the result of your render to a usable PNG output you'll have to cheat and pull an alpha from the RGB data, taking care of the light parts and the dark parts in two different steps.

Instructions:

1) First, do an alpha over on white, the result will show only the dark parts.

2) Then do another alpha over from the original render, this time on black. That will reveal only the light parts.

3) Now, invert the result of the first alpha over.

4) Using a mix node set to SCREEN, mix the result of the second alpha over with the inverted result of the first alpha over. That will be your alpha channel.

5) Take the output of your second alpha over (the composite on white) and using a mix node set to divide, divide it by the alpha created in the step 4.

6) Plug the pre-divided plate from step 5 into the "image" socket of the composite output, and plug the alpha channel produced in step 4 into the alpha socket.

Node Setup for unassociated PNG

That will give you a reasonable unassociated PNG output. It won't be perfect as the unassociated alpha format is very limited for advanced compositing, but it will do the trick.

Anyway, ALWAYS REMEMBER that associated alpha is the one true alpha, and allows compositing effects that are impossible with unassociated. This means that PNG isn't an adequate format for vfx compositing and a format that allows associated alpha should be chosen instead. If the program where you're going to composite these plates allows associated alpha always prefer it over unassociated.

$\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.