Jump to content
You must now use your email address to sign in [click for more info] ×

Straight alpha export for images, png etc.?


Recommended Posts

When I export images with transparency from Designer or Photo, the alpha is always pre-multiplied which is not desired for a lot of assets in game development.

The lack of this feature means I have to add an extra step to the creation of my 2D assets.

image.png.dcb1b448405b6cdd4fbc7ad4d9ce04c0.png

Left is the exported file, right is the desired result.
As you can see, all of the area with alpha is filled to pure black, which creates ugly edges on aliased images (as well as other issues with channel packing etc.)

Link to comment
Share on other sites

  

12 minutes ago, tudor said:

I don't see that here. Do you use any effects or blending modes on the strokes/edges?

image.png.e9fcc57a1e8c176359cef3850c6875c1.png


This Clip explains the difference between Premultiplied and Straight alpha (Pre-divide or un-premultiply).

 

Sketchbook (with Affinity Suite usage) | timurariman.com | artstation store

Windows 11 Pro - 23H2 | Ryzen 5800X3D | RTX 3090 - 24GB | 128GB |
Main SSD with 1TB | SSD 4TB | PCIe SSD 256GB (configured as Scratch disk) |

 

Link to comment
Share on other sites

12 hours ago, AutumnPioneer said:

When I export images with transparency from Designer or Photo, the alpha is always pre-multiplied which is not desired for a lot of assets in game development.

The lack of this feature means I have to add an extra step to the creation of my 2D assets.

image.png.dcb1b448405b6cdd4fbc7ad4d9ce04c0.png

Left is the exported file, right is the desired result.
As you can see, all of the area with alpha is filled to pure black, which creates ugly edges on aliased images (as well as other issues with channel packing etc.)

We would need to get an actual Affinity native format example file.

The effect you are observing can be caused by using specific combinations of clipping / masking / blend modes for groups / other features which can create anti-aliasing artifacts. But this always can be avoided and replaced by other means, to get the intended result without such artifacts. 

Affinity does not premultiply alpha for PNG export, as far as i know. This feature is only relevant for other data formats.

 

 

 

 

 

 

 

 

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

I have seen that in other software I have used and it had something to do with how the layers were setup and the FX on the layers. It was a combination of things that compounded and created the problem.   I have never seen it in my own work in version 1 or 2 apps to date.   

Look at the effects, stroke etc.. on the individual elements and the layers and groupings.

Look at your layers and how they are setup.. Normal, Passthrough etc..  and how the layers themselves are nested grouped together.  the FX on each one. nested layers can have effects that can cause this too.  Accidentally applying or forgetting you applied something nested 3 deep in a group or A group.

Look at the export options and see what they are set too.  Resample, Bleed, Palettized.  File format and option.

Those are the main areas to look at that I can suggest.  I have seen this in other apps like I said but personally not in Affinity myself.

 

Link to comment
Share on other sites

13 minutes ago, tudor said:

I get it now, this is an issue that is only relevant for those working with graphics for the video and gaming industry. The rest of us are probably not affected by it.

You are only effected if you want pure transparency in exported files from Affinity apps.

If it is NOT anything the OP did in their source file AND Affinity IS premultiplying transparency then it will impact you at some point, especially in 4k+ monitors or print.

Link to comment
Share on other sites

18 hours ago, AutumnPioneer said:

When I export images with transparency from Designer or Photo, the alpha is always pre-multiplied which is not desired for a lot of assets in game development.

The lack of this feature means I have to add an extra step to the creation of my 2D assets.

image.png.dcb1b448405b6cdd4fbc7ad4d9ce04c0.png

Left is the exported file, right is the desired result.
As you can see, all of the area with alpha is filled to pure black, which creates ugly edges on aliased images (as well as other issues with channel packing etc.)

Can you try to place a white colored fill object behind the actual object before export?
if you export without, the partial transparent edge pixels will use black as fill color.

it is probably unrelated to pre-multiplied or not. 

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

6 hours ago, tudor said:

I don't see that here. Do you use any effects or blending modes on the strokes/edges?

image.png.e9fcc57a1e8c176359cef3850c6875c1.png

To be clear, the image I posted in the 1st post is a view of the image inside Substance Designer, not the export preview. But you can check if the alpha area is filled black in pretty much any image editor. Even Affinity Photo by just hiding the alpha channel:

image.png.0df044e4a792e128d67e30679e10aa51.png

The edge outlines are done using a layer effect outline, but I have tested this with the regular stroke outlines too and the result is still the same. The ideal result is to have the diffusion of the RGB channels and the alpha NOT effecting the colours.

 

1 hour ago, NotMyFault said:

Can you try to place a white colored fill object behind the actual object before export?
if you export without, the partial transparent edge pixels will use black as fill color.

it is probably unrelated to pre-multiplied or not. 

This has the expected result of a pure white background and no issues.
I also tested setting that pure white background to 0% opacity but it still produced the same issue of the black colur.

Link to comment
Share on other sites

This and similar issues of thin lines in black/white or any other color are plaguing users since ages.

Affinity is doing kind of correct „as defined“ exports in some cases, but fractional pixels, unexpected anti-aliasing, clipping and masking issues are very annoying and sometimes difficult to analyze.

Affinity should change their position and provide more help for users to get rid of all these unwanted effects, e.g. by optional preflight checks & corrective measures.

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

1 hour ago, tudor said:

@AutumnPioneer which file format do you use when exporting graphics out of Affinity apps?

.PNG. But because of this message you left me, i just tried with TGA file and it works?! Thank you. edit: does not work exactly but see further comments below.

Obviously the file sizes are now like 10x larger but, i might be able to convert them in another program? Still annoying when i wanted to stick to a .png workflow

Edited by AutumnPioneer
Link to comment
Share on other sites

I did a test exporting graphics from Affinity Designer and importing them into Motion, where the alpha type makes a difference. PNGs were always straight alpha. For comparison, TIFFs with transparency are always pre-multiplied black, so they do have that black outline when I set them to straight alpha. But I'm wondering why your PNGs looked like they were pre-multiplied?

2129928456_Screenshot2022-11-18at18_27_00.png.5e8ddc017d699c6cf95a647bbe3de626.png

Link to comment
Share on other sites

11 minutes ago, tudor said:

But I'm wondering why your PNGs looked like they were pre-multiplied?

Even at the risk of repeating this for the 3rd time:

the effect is not caused by premultiplied alpha. To identify the actual cause, we need the file uploaded. There are many possible causes, mainly layer fx.

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

3 minutes ago, NotMyFault said:

Even at the risk of repeating this for the 3rd time:

the effect is not caused by premultiplied alpha. To identify the actual cause, we need the file uploaded. There are many possible causes, mainly layer fx.

Here's a file, its very easy to reproduce. Simply make something and export is as .png

BlackOpacity.afdesign

Link to comment
Share on other sites

1 hour ago, AutumnPioneer said:

.PNG. But because of this message you left me, i just tried with TGA file and it works?! Thank you. edit: does not work exactly but see further comments below.

Obviously the file sizes are now like 10x larger but, i might be able to convert them in another program? Still annoying when i wanted to stick to a .png workflow

UPDATE: I was deceived by my own setup because i was testing an image with a white outline. Exporting as .PNG, the background alpha colour is forced to black. But in .tga and .tiff, they are forced to white. So i had not noticed the issue until i tested it with an object with a green outline.

I have however noticed that there is more bleed for the colours alpha in the .tiff and .tga files. So why is .png exporting with a forced black background and not allowing the colours to stay for the aliasing.

Screenshot 2022-11-18 172605.png

Edited by AutumnPioneer
forgot to attach image
Link to comment
Share on other sites

1 hour ago, tudor said:

@AutumnPioneer I exported that question mark graphic as PNG from your afdesign file and Motion detected it as straight alpha. No black background or any black artifacts. 

Do you export as PNG-8 by any chance?

Yes i export as PNG-8 because i dont need the extra info and file size increase. I just tested and youre right about it being white and no artefacts in png 16 though. hmm...

Link to comment
Share on other sites

4 hours ago, AutumnPioneer said:

Here's a file, its very easy to reproduce. Simply make something and export is as .png

BlackOpacity.afdesign 76.33 kB · 5 downloads

Thanks for uploading. It exports without any trace of black. What export settings do you use? (Screenshot would do)
I use „Selected Area“ instead of „Document“, and used iPad.

173B8F5D-857D-4C30-BE05-A96CAC0A86E4.png

Untitled.png

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.