OCCT live Draw Harness examples

Visualization / Anti-aliasing

Sample demonstrating Anti-aliasing options that can be configured within Graphic3d_RenderingParams structure returned by V3d_View::ChangeRenderingParams(). Anti-aliasing algorithms are intended to solve the problem of jagged and pixelated edges. Interactive options:



Graphic3d_RenderingParams::NbMsaaSamples allows enabling multi-sampling anti-aliasing (MSAA) with specified number of samples within graphics hardware limits. Limit could be queried using Graphic3d_GraphicDriver::InquireLimit() with Graphic3d_TypeOfLimit_MaxMsaa parameter or using vglinfo command in Draw Harness. Note that returned limit could be equal to 0, which means no MSAA support. ::RenderResolutionScale should be set to default 1.0 value to use MSAA mode. In general, MSAA is a compromise between quality and performance. 2 samples configuration doesn’t cost to much but usually provides poor visual result (worse than without MSAA in some cases). 4 samples provides average result, and 8 samples gives best results (some systems might support a higher number of samples).

Graphic3d_RenderingParams::RenderResolutionScale manages resolution used for rendering, which is equal to 1.0 (100%) by default. Setting this property to values above 1.0 activates super-sampling anti-aliasing (SSAA) mode (e.g. 2.0 for 200% scale). It is also possible setting property to values below 1.0, which could be used to improve performance on slow graphics hardware (e.g. 0.5 for 50%). ::NbMsaaSamples should be set to default 0 value to use ::RenderResolutionScale.



pload MODELING VISUALIZATION
vinit View1
vbackground -gradient GRAY70 BLACK -gradientMode ELLIPTICAL

# check MSAA limits on specific graphics hardware
set aNbSamples 0
regexp {Max MSAA samples: ([0-9]+)\s} [uplevel 0 vglinfo] res aNbSamples
puts $aNbSamples

# display sample wireframe
box b2 100 100 100
vdisplay b2 -dispMode 0
vfit

# display sample shading
box b1 25 25 25 50 50 50
vdisplay b1 -dispMode 1

# display sample text
vdrawtext t " Label 1.0" -pos 100 50 50 -color GREEN -height 20

# display sample marker
vpoint   p 100 50 50
vaspects p -markerType XCIRCLE -markerSize 3 -color BLUE

# render frame at 200% scale
vrenderparams -rendScale 2.00 -msaa 0

 

Copyright © Kirill Gavrilov Tartynskih, 2021