Every year and every 3ds Max Version I try again to understand why this is never fixed and how to find a better fix to this annoying issue. That thing is simple (or should be simple),  if you have an image with transparency info (alpha channel) you want it to show nice no matter the background. In the image above you see a dark halo in the borders that looks horrible. The same happens if the background is white in the render and later you composite it over a black background then you see white borders.

This also affect anti-aliasing, that depends on transparency. So even you don't use translucent materials your object could have issues on its borders when you composite the image in any 2D editing program or game engine.

 The following is the correct way,  how you want to behave a PNG with transparency :

Then when I google about it, is like only a few people have this concern and the forums discussion you find many different opinions, complex solutions and fights about if 3ds Max fault or Photoshop fault; or my fault for being so dump that I never found that secret super-hidden configuration that makes 3ds Max save .PNG right.
 A simple test says who is guilty. Open your 3ds Max .PNG on Gimp 2, or drag it to a new gmail message, try anywhere else and you will see that it will show wrong with the black or white background borders.

Why this happen?

When your image have and alpha channel then the color channel must be pure colors, NOT blended with the background color, have to be totally independent. But 3ds Max thinks in a different way, they always use pre-multiplied alpha and make things difficult for those that want to composite images outside of Max. (Tested with all versions until Max 2014, later versions I don't know yet, but I bet is still there)

Solution 1 - EXR or TGA

Use another file format, like OpenEXR or TGA. Yes, it solve the problem, but I want to use .PNG. it's small popular and sexy.

Solution 2 - Photoshop

Fix with photoshop "Remove White|Black Matte". It works perfectly well fixing the mixed RGB channel.
Go to Layer > Matting > Remove White|Black Matte 

Done! But I'm not happy yet. I need to fix a whole animation sequence of many PNG images.
Ok. Create a new Photoshop action that applies "Remove White|Black Matte".  Go to Files > Scripts > Image processor and apply your new action to a whole folder of *.PNG images!
Wait... No.
I'm using Photoshop CS4 (I'm vintage guy) and the Image Proccessor doen't have a save to .PNG option! grrrrr.... Google time.
Yay! Found a modified script of Image Proccessor that adds PNG-24 support.
(NOTE: At the moment of writing this post the old links for the scrips are broken. So I going to share my copy of the  script here. Copy and replace the old one here: C:\Program Files\Adobe\Adobe Photoshop CS4 (64 Bit)\Presets\Scripts )

Well, I was happy for a while, but now I needed more speed, because Photoshop is too slow doing this, and you have wait for it to process all images to use Photoshop again.

Solution 3 - ImageMagic convert to PNG

UPDATE: This one resulted to be more realiable when found cases that my final solution 4 failed.

ImageMagick! I was already using ImageMagick tools for a while and now wanted to find a solution to my dirty PNGs.
- Install the command line tools.
- On 3ds Max render output as TGA.
-  Disable "premultiplied alpha" in TGA setup dialog.
-  Set the background to black (0,0,0)
- Then convert to PNG using ImageMagic convert for single files

convert image1.tga image2.png

- or mogrify for multiple files preserving the file name

mogrify -format png *.tga

Solution 4 - My own matte removal

I have my own graphics Unit developed over many years since Delphi 7 that makes many small efficient useful things, playing with pixels directly.

So now with  Delphi XE3 that supports Load/Saving of PNG, I made this console tool, that fix my PNGs like 10 times faster than Photoshop just with this line in the windows cmd:
dpxtool fixalpha *.png black   
And it works. :D
You can download the *.EXE and Delphi source here: [Download dpxTool]
Copy it anywhere and add to your Windows PATH environment variable.
If your PNG background is white just ommit the color:
dpxtool fixalpha *.png
Use wildcards:
dpxtool fixalpha frame????.png

Tell me in the comments if  any of this solutions works for you or if you have better one! ;)

Original Images (Right click to download  PNG):

Image rendered with 3ds Max 2014. See how it shows the black borders on your browser:
This is the image result after fixing with dpxTool. Now it is blending nicely with the white background:

Share To:
Denys Almaral

Denys Almaral

Denys is a 3D artist with an old passion for game development

Post a Comment