From: dbp Date: Wed, 1 Apr 2015 13:19:20 +0000 (+0300) Subject: 0025964: Visualization, TKOpenGl - compile RayTracing shader without texturing when... X-Git-Tag: V6_9_0_beta1~28 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=f483f2ed11a031c026c3e46f97180248d4bf93da;p=occt-copy.git 0025964: Visualization, TKOpenGl - compile RayTracing shader without texturing when no textures in use --- diff --git a/src/OpenGl/OpenGl_SceneGeometry.hxx b/src/OpenGl/OpenGl_SceneGeometry.hxx index dc52558d5c..60740aef84 100755 --- a/src/OpenGl/OpenGl_SceneGeometry.hxx +++ b/src/OpenGl/OpenGl_SceneGeometry.hxx @@ -304,7 +304,7 @@ public: //! @name methods related to texture management } //! Checks if scene contains textured objects. - Standard_Integer HasTextures() const + Standard_Boolean HasTextures() const { return !myTextures.IsEmpty(); } diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 03dc77af3a..d49f0587b1 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -429,14 +429,18 @@ protected: //! @name data types related to ray-tracing //! Actual ray-tracing depth (number of ray bounces). Standard_Integer NbBounces; - //! Sets light propagation through transparent media. + //! Enables/disables light propagation through transparent media. Standard_Boolean TransparentShadows; + //! Enables/disables the use of OpenGL bindless textures. + Standard_Boolean UseBindlessTextures; + //! Creates default compile-time ray-tracing parameters. RaytracingParams() : StackSize (THE_DEFAULT_STACK_SIZE), NbBounces (THE_DEFAULT_NB_BOUNCES), - TransparentShadows (Standard_False) + TransparentShadows (Standard_False), + UseBindlessTextures (Standard_False) { // } diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index 7cde775d43..757f0b297d 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -1011,9 +1011,9 @@ TCollection_AsciiString OpenGl_View::generateShaderPrefix (const Handle(OpenGl_C aPrefixString += TCollection_AsciiString ("\n#define TRANSPARENT_SHADOWS"); } - // If OpenGL driver supports bindless textures, - // activate texturing in ray-tracing mode - if (theGlContext->arbTexBindless != NULL) + // If OpenGL driver supports bindless textures and texturing + // is actually used, activate texturing in ray-tracing mode + if (myRaytraceParameters.UseBindlessTextures && theGlContext->arbTexBindless != NULL) { aPrefixString += TCollection_AsciiString ("\n#define USE_TEXTURES") + TCollection_AsciiString ("\n#define MAX_TEX_NUMBER ") + TCollection_AsciiString (OpenGl_RaytraceGeometry::MAX_TEX_NUMBER); @@ -1153,6 +1153,12 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Graphic3d_CView& theC aToRebuildShaders = Standard_True; } + if (myRaytraceGeometry.HasTextures() != myRaytraceParameters.UseBindlessTextures) + { + myRaytraceParameters.UseBindlessTextures = myRaytraceGeometry.HasTextures(); + aToRebuildShaders = Standard_True; + } + if (theCView.RenderParams.IsTransparentShadowEnabled != myRaytraceParameters.TransparentShadows) { myRaytraceParameters.TransparentShadows = theCView.RenderParams.IsTransparentShadowEnabled;