Frustum culling is now managed by Graphic3d_RenderingParams::FrustumCullingState flag
and can be switched into Graphic3d_RenderingParams::FrustumCulling_NoUpdate state
useful for debugging the algorithm.
Draw Harness command vrustumculling has been replaced by vrenderparams -frustumCulling.
SetBackgroundImage (theOther->BackgroundImage());
SetBackgroundImageStyle (theOther->BackgroundImageStyle());
SetTextureEnv (theOther->TextureEnv());
- SetCullingEnabled (theOther->IsCullingEnabled());
SetShadingModel (theOther->ShadingModel());
SetBackfacingModel (theOther->BackfacingModel());
SetCamera (new Graphic3d_Camera (theOther->Camera()));
//! Sets environment texture for the view.
virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) = 0;
- //! Returns the state of frustum culling optimization.
- virtual Standard_Boolean IsCullingEnabled() const = 0;
-
- //! Enables or disables frustum culling optimization.
- virtual void SetCullingEnabled (const Standard_Boolean theIsEnabled) = 0;
-
//! Return backfacing model used for the view.
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const = 0;
| PerfCounters_FrameTimeMax,
};
+ //! State of frustum culling optimization.
+ enum FrustumCulling
+ {
+ FrustumCulling_Off, //!< culling is disabled
+ FrustumCulling_On, //!< culling is active, and the list of culled entities is automatically updated before redraw
+ FrustumCulling_NoUpdate //!< culling is active, but the list of culled entities is not updated
+ };
+
public:
//! Creates default rendering parameters.
NbRayTracingTiles (16 * 16),
CameraApertureRadius (0.0f),
CameraFocalPlaneDist (1.0f),
+ FrustumCullingState (FrustumCulling_On),
ToneMappingMethod (Graphic3d_ToneMappingMethod_Disabled),
Exposure (0.f),
WhitePoint (1.f),
Standard_Integer NbRayTracingTiles; //!< total number of screen tiles used in adaptive sampling mode (PT only)
Standard_ShortReal CameraApertureRadius; //!< aperture radius of perspective camera used for depth-of-field, 0.0 by default (no DOF) (path tracing only)
Standard_ShortReal CameraFocalPlaneDist; //!< focal distance of perspective camera used for depth-of field, 1.0 by default (path tracing only)
+ FrustumCulling FrustumCullingState; //!< state of frustum culling optimization; FrustumCulling_On by default
Graphic3d_ToneMappingMethod ToneMappingMethod; //!< specifies tone mapping method for path tracing, Graphic3d_ToneMappingMethod_Disabled by default
Standard_ShortReal Exposure; //!< exposure value used for tone mapping (path tracing), 0.0 by default
// =======================================================================
void OpenGl_Layer::UpdateCulling (const Standard_Integer theViewId,
const OpenGl_BVHTreeSelector& theSelector,
- const Standard_Boolean theToTraverse)
+ const Graphic3d_RenderingParams::FrustumCulling theFrustumCullingState)
{
updateBVH();
myNbStructuresNotCulled = myNbStructures;
- for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (myBVHPrimitives.Structures()); aStructIter.More(); aStructIter.Next())
+ if (theFrustumCullingState != Graphic3d_RenderingParams::FrustumCulling_NoUpdate)
{
- const OpenGl_Structure* aStruct = aStructIter.Value();
- aStruct->SetCulled (theToTraverse);
- }
- for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (myBVHPrimitivesTrsfPers.Structures()); aStructIter.More(); aStructIter.Next())
- {
- const OpenGl_Structure* aStruct = aStructIter.Value();
- aStruct->SetCulled (theToTraverse);
+ Standard_Boolean toTraverse =
+ (theFrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On);
+ for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (myBVHPrimitives.Structures()); aStructIter.More(); aStructIter.Next())
+ {
+ const OpenGl_Structure* aStruct = aStructIter.Value();
+ aStruct->SetCulled (toTraverse);
+ }
+ for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (myBVHPrimitivesTrsfPers.Structures()); aStructIter.More(); aStructIter.Next())
+ {
+ const OpenGl_Structure* aStruct = aStructIter.Value();
+ aStruct->SetCulled (toTraverse);
+ }
}
- if (!theToTraverse)
+ if (theFrustumCullingState != Graphic3d_RenderingParams::FrustumCulling_On)
{
return;
}
//! Traverses through BVH tree to determine which structures are in view volume.
void UpdateCulling (const Standard_Integer theViewId,
const OpenGl_BVHTreeSelector& theSelector,
- const Standard_Boolean theToTraverse);
+ const Graphic3d_RenderingParams::FrustumCulling theFrustumCullingState);
//! Returns TRUE if layer is empty or has been discarded entirely by culling test.
bool IsCulled() const { return myNbStructuresNotCulled == 0; }
continue;
}
- aLayer.UpdateCulling (aViewId, aSelector, theWorkspace->IsCullingEnabled());
+ aLayer.UpdateCulling (aViewId, aSelector, theWorkspace->View()->RenderingParams().FrustumCullingState);
}
aTimer.Stop();
myDriver (theDriver.operator->()),
myCaps (theCaps),
myWasRedrawnGL (Standard_False),
- myCulling (Standard_True),
myBackfacing (Graphic3d_TOBM_AUTOMATIC),
myBgColor (Quantity_NOC_BLACK),
myCamera (new Graphic3d_Camera()),
//! Sets environment texture for the view.
Standard_EXPORT virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) Standard_OVERRIDE;
- //! Returns the state of frustum culling optimization.
- virtual Standard_Boolean IsCullingEnabled() const Standard_OVERRIDE { return myCulling; }
-
- //! Enables or disables frustum culling optimization.
- virtual void SetCullingEnabled (const Standard_Boolean theIsEnabled) Standard_OVERRIDE { myCulling = theIsEnabled; }
-
//! Return backfacing model used for the view.
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const Standard_OVERRIDE { return myBackfacing; }
Handle(OpenGl_Caps) myCaps;
Standard_Boolean myWasRedrawnGL;
- Standard_Boolean myCulling;
Graphic3d_TypeOfBackfacingModel myBackfacing;
Quantity_ColorRGBA myBgColor;
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
return !myView->GlWindow().IsNull() ? myView->GlWindow()->Height() : 0;
}
-// =======================================================================
-// function : IsCullingEnabled
-// purpose :
-// =======================================================================
-Standard_Boolean OpenGl_Workspace::IsCullingEnabled() const
-{
- return myView->IsCullingEnabled();
-}
-
// =======================================================================
// function : FBOCreate
// purpose :
theCamera->Transform (aPanTrsf);
}
-// =======================================================================
-// function : IsCullingEnabled
-// purpose :
-// =======================================================================
-Standard_Boolean V3d_View::IsCullingEnabled() const
-{
- return myView->IsCullingEnabled();
-}
-
-// =======================================================================
-// function : SetFrustumCulling
-// purpose :
-// =======================================================================
-void V3d_View::SetFrustumCulling (const Standard_Boolean theToClip)
-{
- myView->SetCullingEnabled (theToClip);
-}
-
// =======================================================================
// function : DiagnosticInformation
// purpose :
Standard_EXPORT Graphic3d_RenderingParams& ChangeRenderingParams();
//! @return flag value of objects culling mechanism
- Standard_EXPORT Standard_Boolean IsCullingEnabled() const;
+ Standard_Boolean IsCullingEnabled() const { return RenderingParams().FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On; }
- //! Turn on/off automatic culling of objects outside frustrum (ON by default)
- Standard_EXPORT void SetFrustumCulling (const Standard_Boolean theMode);
+ //! Turn on/off automatic culling of objects outside frustum (ON by default)
+ void SetFrustumCulling (Standard_Boolean theMode) { ChangeRenderingParams().FrustumCullingState = theMode ? Graphic3d_RenderingParams::FrustumCulling_On : Graphic3d_RenderingParams::FrustumCulling_Off; }
//! Fill in the dictionary with diagnostic info.
//! Should be called within rendering thread.
}
theDI << "depth pre-pass: " << (aParams.ToEnableDepthPrepass ? "on" : "off") << "\n";
theDI << "alpha to coverage: " << (aParams.ToEnableAlphaToCoverage ? "on" : "off") << "\n";
+ theDI << "frustum culling: " << (aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On ? "on" :
+ aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_Off ? "off" :
+ "noUpdate") << "\n";
theDI << "\n";
return 0;
}
}
aView->ChangeRenderingParams().StatsMaxChartTime = (Standard_ShortReal )Draw::Atof (theArgVec[anArgIter]);
}
+ else if (aFlag == "-frustumculling"
+ || aFlag == "-culling")
+ {
+ if (toPrint)
+ {
+ theDI << ((aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On) ? "on" :
+ (aParams.FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_Off) ? "off" :
+ "noUpdate") << " ";
+ continue;
+ }
+
+ Graphic3d_RenderingParams::FrustumCulling aState = Graphic3d_RenderingParams::FrustumCulling_On;
+ if (++anArgIter < theArgNb)
+ {
+ TCollection_AsciiString aStateStr(theArgVec[anArgIter]);
+ aStateStr.LowerCase();
+ bool toEnable = true;
+ if (ViewerTest::ParseOnOff (aStateStr.ToCString(), toEnable))
+ {
+ aState = toEnable ? Graphic3d_RenderingParams::FrustumCulling_On : Graphic3d_RenderingParams::FrustumCulling_Off;
+ }
+ else if (aStateStr == "noupdate"
+ || aStateStr == "freeze")
+ {
+ aState = Graphic3d_RenderingParams::FrustumCulling_NoUpdate;
+ }
+ else
+ {
+ --anArgIter;
+ }
+ }
+ aParams.FrustumCullingState = aState;
+ }
else
{
std::cout << "Error: wrong syntax, unknown flag '" << anArg << "'\n";
}
#endif
-//=======================================================================
-//function : VFrustumCulling
-//purpose : enables/disables view volume's culling.
-//=======================================================================
-static int VFrustumCulling (Draw_Interpretor& theDI,
- Standard_Integer theArgNb,
- const char** theArgVec)
-{
- Handle(V3d_View) aView = ViewerTest::CurrentView();
- if (aView.IsNull())
- {
- std::cout << theArgVec[0] << " Error: Use 'vinit' command before\n";
- return 1;
- }
-
- if (theArgNb < 2)
- {
- theDI << (aView->IsCullingEnabled() ? "on" : "off");
- return 0;
- }
- else if (theArgNb != 2)
- {
- std::cout << theArgVec[0] << " Syntax error: Specify the mode\n";
- return 1;
- }
-
- TCollection_AsciiString aModeStr (theArgVec[1]);
- aModeStr.LowerCase();
- Standard_Boolean toEnable = 0;
- if (aModeStr == "on")
- {
- toEnable = 1;
- }
- else if (aModeStr == "off")
- {
- toEnable = 0;
- }
- else
- {
- toEnable = Draw::Atoi (theArgVec[1]) != 0;
- }
-
- aView->SetFrustumCulling (toEnable);
- aView->Redraw();
- return 0;
-}
-
//=======================================================================
//function : VXRotate
//purpose :
"\n '-perfUpdateInterval nbSeconds' Performance counters update interval"
"\n '-perfChart nbFrames' Show frame timers chart limited by specified number of frames"
"\n '-perfChartMax seconds' Maximum time in seconds with the chart"
+ "\n '-frustumCulling on|off|noupdate' Enable/disable objects frustum clipping or"
+ "\n set state to check structures culled previously."
"\n Unlike vcaps, these parameters dramatically change visual properties."
"\n Command is intended to control presentation quality depending on"
"\n hardware capabilities and performance.",
__FILE__, VRenderParams, group);
- theCommands.Add("vfrustumculling",
- "vfrustumculling [toEnable]: enables/disables objects clipping",
- __FILE__,VFrustumCulling,group);
theCommands.Add ("vplace",
"vplace dx dy"
"\n\t\t: Places the point (in pixels) at the center of the window",
vinit name=small_wnd l=32 t=32 w=$SMALL_WIN_WIDTH h=$SMALL_WIN_HEIGHT
vactivate small_wnd
vrenderparams -perfUpdateInterval 0
-vfrustumculling 0
+vrenderparams -frustumculling off
vautozfit 0
vviewparams -scale 1.953125 -eye 0.57735026918962573 -0.57735026918962573 0.57735026918962573
vzrange 1 512
verase
puts "Start displaying spheres with clipping..."
-vfrustumculling 1
+vrenderparams -frustumculling on
vdisplayall
puts [vfps]
vrenderparams -perfCounters none
vinit name=small_wnd l=32 t=32 w=$SMALL_WIN_WIDTH h=$SMALL_WIN_HEIGHT
vactivate small_wnd
vrenderparams -perfUpdateInterval 0
-vfrustumculling 0
+vrenderparams -frustumculling off
vautozfit 0
vviewparams -scale 1.953125 -eye 0.57735026918962573 -0.57735026918962573 0.57735026918962573
vzrange 1 512
verase
-vfrustumculling 1
+vrenderparams -frustumculling on
puts "Start displaying boxes with clipping..."
for {set i 0} {$i < $BOXES_NUM} {incr i} {
vdisplay -noupdate $aBoxNames($i)
box b 1 2 3
vinit
vdisplay b
-vfrustumculling 1
+vrenderparams -frustumculling on
vfit
vdump $imagedir/${casename}_default_layer.png
vfit
-vfrustumculling 1
+vrenderparams -frustumculling on
vdump $aWithCulling
-vfrustumculling 0
+vrenderparams -frustumculling off
vdump $aNoCulling
set aDiffRes [diffimage $aWithCulling $aNoCulling 0.1 0 0 $aDiff]
# Test orthographic camera without frustum culling. #
####################################################################
vcamera -ortho
-vfrustumculling 0
+vrenderparams -frustumculling off
if { [test2d] != 1 } {
puts "Error: 2D projection test failed: view frustum culling is OFF"
# Test orthographic camera with frustum culling. #
####################################################################
vcamera -ortho
-vfrustumculling 1
+vrenderparams -frustumculling on
if { [test2d] != 1 } {
puts "Error: 2D projection test failed: view frustum culling is ON"
####################################################################
vcamera -ortho
vviewparams -scale 1e-8
-vfrustumculling 0
+vrenderparams -frustumculling off
if { [test3d 1e-7] != 1 } {
puts "Error: 3D projection test failed: camera is orthographic, view frustum culling is OFF"
####################################################################
vcamera -ortho
vviewparams -scale 1e-8
-vfrustumculling 1
+vrenderparams -frustumculling on
if { [test3d 1e-7] != 1 } {
puts "Error: 3D projection test failed: camera is orthographic, view frustum culling is ON"
# Test camera with less starting distance 1.0 to avoid jittering. #
####################################################################
vcamera -persp
-vfrustumculling 0
+vrenderparams -frustumculling off
if { [test3d 1.0] != 1 } {
puts "Error: 3D projection test failed: camera is perspective, view frustum culling is OFF"
# Test camera with less starting distance 1.0 to avoid jittering. #
####################################################################
vcamera -persp
-vfrustumculling 1
+vrenderparams -frustumculling on
if { [test3d 1.0] != 1 } {
puts "Error: 3D projection test failed: camera is perspective, view frustum culling is ON"
--- /dev/null
+puts "============="
+puts "0030434: Visualization, TKV3d - add 'NoUpdate' state of frustum culling optimization"
+puts "============="
+
+pload VISUALIZATION
+vclear
+vinit View1
+
+set THE_NB_POINTS 10
+puts "Creating [expr $THE_NB_POINTS * $THE_NB_POINTS * $THE_NB_POINTS] points..."
+for {set i 0} {$i < $THE_NB_POINTS} {incr i} {
+ for {set j 0} {$j < $THE_NB_POINTS} {incr j} {
+ for {set k 0} {$k < $THE_NB_POINTS} {incr k} {
+ vpoint p$i$j$k 3.*$i 3.*$j 3.*$k
+ }
+ }
+}
+
+vcamera -ortho
+vfront
+vfit
+vzoom 2
+vrenderparams -frustumculling on
+vrenderparams -frustumculling noupdate
+vfit
+if { [vreadpixel 92 92 rgb name] == "YELLOW" } { puts "Error: point should be clipped earlier" }
+vdump $::imagedir/${::casename}_ortho_culled.png
+vrenderparams -frustumculling off
+if { [vreadpixel 92 92 rgb name] != "YELLOW" } { puts "Error: point should NOT be clipped" }
+vdump $::imagedir/${::casename}_ortho_all.png
+
+vcamera -persp
+vaxo
+vfit
+vzoom 3
+vrenderparams -frustumculling on
+vrenderparams -frustumculling noupdate
+vfit
+if { [vreadpixel 114 92 rgb name] == "YELLOW" } { puts "Error: point should be clipped earlier" }
+vdump $::imagedir/${::casename}_persp_culled.png
+vrenderparams -frustumculling off
+if { [vreadpixel 114 92 rgb name] != "YELLOW" } { puts "Error: point should NOT be clipped" }
+vdump $::imagedir/${::casename}_persp_all.png