MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0031988Community[OCCT] OCCT:Visualizationpublic2020-12-09 11:022020-12-23 08:30
ReporterVico Liang 
Assigned Tokgv 
PrioritynormalSeverityminor 
StatusfeedbackResolutionduplicate 
PlatformOSOS Version
Product Version 
Target Version[OCCT] 7.6.0*Fixed in Version 
Summary0031988: Visualization - use Quantity_ColorRGBA as background rather than Quantity_Color to support alpha channel
DescriptionThe current implement uses Quantity_Color as input in class V3d_View
void V3d_View::SetBackgroundColor (const Quantity_Color& theColor)

But the storage field is in class Graphic3d_CView:
  Quantity_ColorRGBA myBgColor;

OpenGL actually uses the alpha value, occt set the alpha value to 0 as below:
glClearColor (aBgColor.r(), aBgColor.g(), aBgColor.b(), 0.0f);

It means the color is full transparent, it will cause blending. The blending result is very hard to predictable especially using with external GUI such as QT.

It would be nice to have an option to set the alpha channel by user.

Method SetBgGradientColors have the same issue.
void V3d_View::SetBgGradientColors (const Quantity_Color& theColor1,
                                    const Quantity_Color& theColor2,
                                    const Aspect_GradientFillMethod theFillStyle,
                                    const Standard_Boolean theToUpdate)
TagsNo tags attached.
Test case number
Attached Files

- Relationships
related to 0031597verifiedbugmaster Open CASCADE Visualization, TKOpenGl - allow disabling Alpha component writes within OpenGl_Context::ColorMask() 
related to 0031964newkgv Community Visualization, TKOpenGl - add option to disable background color filling for external render buffer 

-  Notes
(0097529)
kgv (developer)
2020-12-12 13:17
edited on: 2020-12-12 13:18

The idea of providing an alpha component option within viewer background color has appeared in the past.
However, in practice such API would produce only confusion, as apart from background, alpha values are also written by rendering semi-transparent objects.

The option proposed by a patch for 0031597 is expected to handle both issues and ensure 3D Viewer content is rendered opaque even if color buffer contains alpha component.

(0097833)
kgv (developer)
2020-12-21 15:19

Dear bugmaster,

please close the issue as duplicate of 0031597.

Dear Vico,

consider reopening the issue in case if 0031597 doesn't fulfill your needs.
(0097842)
Vico Liang (developer)
2020-12-21 18:10
edited on: 2020-12-21 18:12

Dear Kirill,

Issue 0031597 provides option to enable or diable alpha component, it can't change the alpha value even if the alpha channel is enabled. So these two issues are different. I insist to open this issue. This will allow user to control the alpha value not only enable or disalbe the option.

(0097847)
kgv (developer)
2020-12-21 19:47

> it can't change the alpha value even if the alpha channel is enabled
I see no meaning of setting a non-opaque alpha to the background color - what is expected result for it?
(0097855)
Vico Liang (developer)
2020-12-22 10:28

>>I see no meaning of setting a non-opaque alpha to the background color
The blending algorithm will use the alpha value if setting so. OpenGL will generate different result.
(0097858)
kgv (developer)
2020-12-22 10:49

Dear Vico,

> The blending algorithm will use the alpha value if setting so.
> OpenGL will generate different result.
There are the following use cases:
1. Alpha color writes are disabled.
   Background is filled in as fully opaque in case of RGBA buffer.
   Opaque and Translucent objects fill in pixels with opaque color - alpha values are used for blending but not written into result frame buffer.

RESULT: image is opaque, transparent of semitransparent objects is pre-multiplied with background.

2. Alpha color writes are enabled.
   Background is filled in as fully transparent.
   Opaque object fills corresponding pixels with opaque color.
   Translucent object fills pixels with semitransparent color (last drawn object overrides alpha values).

RESULT: image will contain two semitransparent regions: original background and translucent objects. Note that the alpha component for latter ones will be incorrect - as color is already blended with background, applying transparency second time will make result more transparent.

Allowing to set arbitrary transparency to background color will reveal two more scenarios:
3. Alpha color writes are disabled.
   Background is filled in as semitransparent color.
   Opaque and translucent objects will not write alpha values into frame buffer.

RESULT: the whole image will have a uniform semitransparent alpha that was defined for background.

4. Alpha color writes are enabled.
   Background is filled in as semitransparent color.
   Opaque object fills corresponding pixels with opaque color (override background).
   Translucent object fills pixels with semitransparent color (last drawn object overrides alpha values).

RESULT: image will contain two semitransparent regions: original background (now semitransparent, not fully transparent) and translucent objects.
(0097859)
kgv (developer)
2020-12-22 10:54

The 3rd case looks dubious to me, as if application wants to blend 3D Viewer content with some other background uniformly - there should be more straightforward ways to do it in specific engine, where 3D Viewer is integrated into.

The 4th case looks not very practical as 2nd case - it would just allow to avoid fully transparent background color.

Which use case do you actually see in your scenario?

Note that there might be a 5th use case with expected behavior: background is (semi)transparent, opaque and transparent objects fill in alpha as opaque (e.g. overrides background alpha, but transparent objects write color as opaque). But this is technically not implementable in current design.
(0097868)
Vico Liang (developer)
2020-12-22 18:43

Dear Kirill,

Wow, you really surprised me. I just think that there are different blending functions in OpenGL intenral. I don't consider the details as your described. From your described senarios, it's worthwhile to have this alpha channel controlable from user input, right? I'd like to see the surprised rendering result when this feature is available.

- Issue History
Date Modified Username Field Change
2020-12-09 11:02 Vico Liang New Issue
2020-12-09 11:02 Vico Liang Assigned To => kgv
2020-12-09 11:11 kgv Relationship added related to 0031597
2020-12-09 11:12 kgv Summary use Quantity_ColorRGBA as background rather than Quantity_Color to support alpha channel => Visualization - use Quantity_ColorRGBA as background rather than Quantity_Color to support alpha channel
2020-12-12 13:17 kgv Note Added: 0097529
2020-12-12 13:18 kgv Note Edited: 0097529 View Revisions
2020-12-12 13:18 kgv Note Edited: 0097529 View Revisions
2020-12-21 15:18 kgv Relationship added related to 0031964
2020-12-21 15:19 kgv Note Added: 0097833
2020-12-21 15:19 kgv Assigned To kgv => bugmaster
2020-12-21 15:19 kgv Status new => feedback
2020-12-21 15:19 kgv Resolution open => duplicate
2020-12-21 18:10 Vico Liang Note Added: 0097842
2020-12-21 18:11 Vico Liang Assigned To bugmaster => kgv
2020-12-21 18:12 Vico Liang Note Edited: 0097842 View Revisions
2020-12-21 19:47 kgv Note Added: 0097847
2020-12-21 19:48 kgv Assigned To kgv => Vico Liang
2020-12-22 10:28 Vico Liang Note Added: 0097855
2020-12-22 10:49 kgv Note Added: 0097858
2020-12-22 10:54 kgv Note Added: 0097859
2020-12-22 18:43 Vico Liang Note Added: 0097868
2020-12-23 08:30 Vico Liang Assigned To Vico Liang => kgv


Copyright © 2000 - 2021 MantisBT Team
Powered by Mantis Bugtracker