Open GL Rendering : Alpha channel is always recorded in Premultiplied mode, even if you save your image in PNG #34276

Closed
opened 2013-02-16 14:01:05 +01:00 by Francois Grassard · 11 comments

%%%--- Operating System, Graphics card ---

Windows 7 Pro 64 bits - nVidia GTX 460

- Blender version with error, and version that worked ---

Tested on Blender 2.66 TestBuild 1

- Short description of error ---

I use Open GL Rendering a lot, even for broadcast projects.

Since the Alpha has been refactored, the Alpha channel is always recorded in "a kind of" Premultiplied mode when we use the OpenGL render, even if you save your image in PNG. Not in Straight mode. I say "a kind of" because if I interpret the rendered image in After Effects as a premultiplied footage, anti-aliased pixels are wrong too ...

So, when you save your Open GL render in PNG files, it's totally impossible to reuse it in any compositing software ... even Blender.

And ... just a little feature request about OpenGL rendering : It could be so cool to directly catch the OpenGL render in the Compositor by using a Render Layer node ... even if only RGBA channels (and maybe Z channel) are relevants here. For now, I have to render my images on my hard drive ... then reload them in the compositor. :o) Thanks a lot !

- Steps for others to reproduce the error (preferably based on attached .blend file) ---
  • Create a sphere
  • Set Alpha to Transparent
  • Render using "OpenGL Render Active Viewport"
  • Save as PNG
  • Inspect the RGB channels to see there are pre-mulitplied and not straight

Thanks a lot for your work !%%%

%%%--- Operating System, Graphics card --- Windows 7 Pro 64 bits - nVidia GTX 460 - Blender version with error, and version that worked --- Tested on Blender 2.66 TestBuild 1 - Short description of error --- I use Open GL Rendering a lot, even for broadcast projects. Since the Alpha has been refactored, the Alpha channel is always recorded in "a kind of" Premultiplied mode when we use the OpenGL render, even if you save your image in PNG. Not in Straight mode. I say "a kind of" because if I interpret the rendered image in After Effects as a premultiplied footage, anti-aliased pixels are wrong too ... So, when you save your Open GL render in PNG files, it's totally impossible to reuse it in any compositing software ... even Blender. And ... just a little feature request about OpenGL rendering : It could be so cool to directly catch the OpenGL render in the Compositor by using a Render Layer node ... even if only RGBA channels (and maybe Z channel) are relevants here. For now, I have to render my images on my hard drive ... then reload them in the compositor. :o) Thanks a lot ! - Steps for others to reproduce the error (preferably based on attached .blend file) --- - Create a sphere - Set Alpha to Transparent - Render using "OpenGL Render Active Viewport" - Save as PNG - Inspect the RGB channels to see there are pre-mulitplied and not straight Thanks a lot for your work !%%%

Changed status to: 'Open'

Changed status to: 'Open'

%%%I couldn't see an issue here. Semi-transparent cube rendered with OpenGL viewport renderer seems to be correct after saving it to png in gwenview and gimp. Also, it seems in exactly the same way as OpenGL Render Result image after opening this png in blender.

Please, reset to factory settings, try to reproduce issue and if it'll reproduce attach sample .blend file, steps to make alpha fail and describe what's exactly you consider behaving wrong there.%%%

%%%I couldn't see an issue here. Semi-transparent cube rendered with OpenGL viewport renderer seems to be correct after saving it to png in gwenview and gimp. Also, it seems in exactly the same way as OpenGL Render Result image after opening this png in blender. Please, reset to factory settings, try to reproduce issue and if it'll reproduce attach sample .blend file, steps to make alpha fail and describe what's exactly you consider behaving wrong there.%%%

%%%I can confirm the issue here and have committed a fix, it's more clear on edges than transparency materials. The sRGB to linear color space conversion wasn't taking alpha into account.%%%

%%%I can confirm the issue here and have committed a fix, it's more clear on edges than transparency materials. The sRGB to linear color space conversion wasn't taking alpha into account.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

%%%Sorry for my late reply ... i'm really busy those days ... :o)

Thank you Brecht ... I investigated the issue a little bit more and in fact, I discovered that the same problem was already there in Blender 2.65a.

Here is two screenshots I made about that :

The first one show the RGB channels only ... for an image coming from the BI (on the left side) and for the same scene, an image coming from the OpenGL Renderer (on the right side) :

http://www.coyhot.com/no_CoyHot/SideBySide_Compare.jpg

The second image show those two renders saved in PNG and opened in Photoshop. As you can see, the png saved from the OpenGL Renderer (on the right side) is showing some ugly black artefacts on the antialiased pixels ... who is not surprising when we saw the first screenshot :

http://www.coyhot.com/no_CoyHot/SideBySide_SavedAndImported.jpg

Here is the really simple scene I used (a sphere with a "shadeless" red shader) :

http://www.coyhot.com/no_CoyHot/SimpleSphere.blend

I tried to switch to cycles renderer to acces the "OpenGL Alpha" parameter (in "Film" tab) to switch it to "Transparent" ... but the issue remain the same.

I don't know if the commit from brecht already fixed it ... if not, I hope those informations will help you to solve the issue.

And once again ... if we can grab the OpenGl render in a compositing node ... it could be really interesting. As I previously said, I've rendered a lot of billboards and jingles for Broadcast TVs in France by using only OpenGl renderer and some Matcaps mapped in "Normal" mode (using GLSL renderer). It's a really good tricks to produce good looking animations in HD when you only have 1 hour or 2 to create a 15 seconds animation. :o)

Thanks again for your wonderfull work !%%%

%%%Sorry for my late reply ... i'm really busy those days ... :o) Thank you Brecht ... I investigated the issue a little bit more and in fact, I discovered that the same problem was already there in Blender 2.65a. Here is two screenshots I made about that : The first one show the RGB channels only ... for an image coming from the BI (on the left side) and for the same scene, an image coming from the OpenGL Renderer (on the right side) : http://www.coyhot.com/no_CoyHot/SideBySide_Compare.jpg The second image show those two renders saved in PNG and opened in Photoshop. As you can see, the png saved from the OpenGL Renderer (on the right side) is showing some ugly black artefacts on the antialiased pixels ... who is not surprising when we saw the first screenshot : http://www.coyhot.com/no_CoyHot/SideBySide_SavedAndImported.jpg Here is the really simple scene I used (a sphere with a "shadeless" red shader) : http://www.coyhot.com/no_CoyHot/SimpleSphere.blend I tried to switch to cycles renderer to acces the "OpenGL Alpha" parameter (in "Film" tab) to switch it to "Transparent" ... but the issue remain the same. I don't know if the commit from brecht already fixed it ... if not, I hope those informations will help you to solve the issue. And once again ... if we can grab the OpenGl render in a compositing node ... it could be really interesting. As I previously said, I've rendered a lot of billboards and jingles for Broadcast TVs in France by using only OpenGl renderer and some Matcaps mapped in "Normal" mode (using GLSL renderer). It's a really good tricks to produce good looking animations in HD when you only have 1 hour or 2 to create a 15 seconds animation. :o) Thanks again for your wonderfull work !%%%

%%%EDIT : I just tested the final 2.66 release and the issue has disapear ! Yeah !!!

Thank you so much guys ! :o)

So ... if you want to had an "OpenGl node" in the Compositing ... it will be my pleasure to test it everyday ... :o)

Thanks again !%%%

%%%EDIT : I just tested the final 2.66 release and the issue has disapear ! Yeah !!! Thank you so much guys ! :o) So ... if you want to had an "OpenGl node" in the Compositing ... it will be my pleasure to test it everyday ... :o) Thanks again !%%%

Added subscriber: @adapmal

Added subscriber: @adapmal

Hi! Did the issue get back on Blender 2.77? Always get premultiplied alpha on Open GL render... My workaround is to render twice: One with the alpha objects and other without them - then compose both... But that's a bit annoying, agreed?

Hi! Did the issue get back on Blender 2.77? Always get premultiplied alpha on Open GL render... My workaround is to render twice: One with the alpha objects and other without them - then compose both... But that's a bit annoying, agreed?

@adapmal, if you think you found a bug, open a new report with precise instructions to redo the problem and details about your operating system, graphics card, etc.

@adapmal, if you think you found a bug, open a new report with precise instructions to redo the problem and details about your operating system, graphics card, etc.

In #34276#383081, @brecht wrote:
@adapmal, if you think you found a bug, open a new report with precise instructions to redo the problem and details about your operating system, graphics card, etc.

Well, I really don't know if that's a bug. But I cannot get straight alpha from OpenGl Render. So, my details:

- Operating System, Graphics card --- 

MacOS 10.11.5 - AMD Radeon R9 M295X 4096 MB

- Blender version with error, and version that worked --- 

Blender 2.77 (2016-03-19)

- Short description of error --- 

In my 3d world I use a plane with a "png with alpha" texture, composed with 3d objects made in Blender. Alpha "Straight" is the one that works for me, and I can see it composing beautifully with my 3d objects, in my 3d Viewport (Texture shaders mode). When then i hit "Open Gl Render", to render a photo or animation it only renders in "Premultiplied mode". I can even choose witch premultiplied type I want, in |Info|Render>OpenGL Render Options>Alpha Mode (Sky/Transparent), but I cannot choose "Straight".

Thanks guys. You have changed my life.

> In #34276#383081, @brecht wrote: > @adapmal, if you think you found a bug, open a new report with precise instructions to redo the problem and details about your operating system, graphics card, etc. Well, I really don't know if that's a bug. But I cannot get straight alpha from OpenGl Render. So, my details: - Operating System, Graphics card --- MacOS 10.11.5 - AMD Radeon R9 M295X 4096 MB - Blender version with error, and version that worked --- Blender 2.77 (2016-03-19) - Short description of error --- In my 3d world I use a plane with a "png with alpha" texture, composed with 3d objects made in Blender. Alpha "Straight" is the one that works for me, and I can see it composing beautifully with my 3d objects, in my 3d Viewport (Texture shaders mode). When then i hit "Open Gl Render", to render a photo or animation it only renders in "Premultiplied mode". I can even choose witch premultiplied type I want, in |Info|Render>OpenGL Render Options>Alpha Mode (Sky/Transparent), but I cannot choose "Straight". Thanks guys. You have changed my life.

@adapmal, opening a new report is still the best thing to do even if you aren't certain it's a bug.

Rendering indeed always outputs premultiplied alpha by design, since Blender 2.66. Only on file save do we convert to the appropriate alpha convention for the specific file type. Compositing with premultiplied alpha is the standard workflow in animation / VFX, and I don't think it imposes any significant limitations.

The specific thing you're trying to do is most likely still possible in another way, or maybe there is a bug or limitation in Blender, but there's not enough information for me to tell.

@adapmal, opening a new report is still the best thing to do even if you aren't certain it's a bug. Rendering indeed always outputs premultiplied alpha by design, since Blender 2.66. Only on file save do we convert to the appropriate alpha convention for the specific file type. Compositing with premultiplied alpha is the standard workflow in animation / VFX, and I don't think it imposes any significant limitations. The specific thing you're trying to do is most likely still possible in another way, or maybe there is a bug or limitation in Blender, but there's not enough information for me to tell.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#34276
No description provided.