View Issue Details

IDProjectCategoryView StatusLast Update
0031988CommunityOCCT:Visualizationpublic2023-08-07 15:52
ReporterVico Liang Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionduplicate 
Target VersionUnscheduled 
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

Relationships

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

Activities

kgv

2020-12-12 13:17

developer   ~0097529

Last edited: 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.

kgv

2020-12-21 15:19

developer   ~0097833

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.

Vico Liang

2020-12-21 18:10

developer   ~0097842

Last edited: 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.

kgv

2020-12-21 19:47

developer   ~0097847

> 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?

Vico Liang

2020-12-22 10:28

developer   ~0097855

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

kgv

2020-12-22 10:49

developer   ~0097858

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.

kgv

2020-12-22 10:54

developer   ~0097859

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.

Vico Liang

2020-12-22 18:43

developer   ~0097868

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.

dpasukhi

2023-08-02 02:11

administrator   ~0113836

Dear @bugmaster
please close the issue

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
2020-12-12 13:18 kgv Note Edited: 0097529
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
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
2021-09-20 11:08 kgv Target Version 7.6.0 => 7.7.0
2022-08-17 11:55 kgv Target Version 7.7.0 => 7.8.0
2022-10-19 15:49 smoskvin Assigned To kgv => vpozdyayev
2023-08-02 02:11 dpasukhi Assigned To vpozdyayev => bugmaster
2023-08-02 02:11 dpasukhi Target Version 7.8.0 => Unscheduled
2023-08-02 02:11 dpasukhi Note Added: 0113836
2023-08-07 15:52 vglukhik Status feedback => closed