Problem with custom AIS object visualization

TLohi

CAD practitioner
Hi,

I am implementing custom AIS_InteractiveObject but when displaying transparent version of object parts behave strange way. When changing point of view part of object that should be behind came forward. For comparision images have also non transparent version.

Axises are constructed using Prs3d_Arrow::DrawShaded function
and transparency is achieved by:
Handle(Prs3d_ShadingAspect) anAspectCen = new Prs3d_ShadingAspect();
anAspectCen->SetTransparency(0.2);


Any ideas how to fix this?

1663766434976.png1663766452437.png
 

natalia

Moderator
Staff member
Hi, @TLohi

I checked your case on AIS_Trihedron displayed in shaded mode. It is reproduced (red arrow is geometrically above others in this camera position but shown below):
trihedron_transparent.png

The similar problem is discussed here lots of time ago: https://dev.opencascade.org/content/problem-drawing-transparency-objects.

As I remember there are many improvements performed in OCCT regarding transparency since that time. So, I'll play with some flags in rendering and after let you know about the result.

By the way, which version of OCCT you use?
 

Attachments

  • trihedron_transparent.png
    trihedron_transparent.png
    16.3 KB · Views: 0

natalia

Moderator
Staff member
Hi @TLohi

The solution for this request is using ‘Graphic3d_RTM_BLEND_OIT’ parameter of ‘TransparencyMethod’ for ‘Graphic3d_RenderingParams’ of view (instead of default ‘Graphic3d_RTM_BLEND_UNORDERED’).

It might be set using the next piece of code. Just add it when the view is created/initialized:

C++:
Handle(V3d_View) view/* = <get here view from the V3d_Viewer>*/;

Graphic3d_RenderingParams& renderParams = aView->ChangeRenderingParams();
renderParams.TransparencyMethod = Graphic3d_RTM_BLEND_OIT;

Using this method, the shaded trihedron presentation looks (on the right):

trihedron_transparency_oit.png:

This feature implemented in OCCT in bounds of the https://tracker.dev.opencascade.org/view.php?id=27925 issue. The issue description contains links to basic concepts of OpenGl. Implementation provides test cases releated. If you want to play with it in DRAW, please note, that these test cases are now (checked on OCCT 7.6.0) placed in ‘tests/opengl/data/transparency’.

By the way, the ‘vrenderparams’ command of DRAW has parameters to change the transparency method for the active view. The next parameter of this DRAW command calls the proposed C++ code above:
Code:
vrenderparams -oit weight 0.0
 
Top