1 // Created on: 2011-09-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef OpenGl_View_HeaderFile
17 #define OpenGl_View_HeaderFile
19 #include <Graphic3d_CView.hxx>
20 #include <Graphic3d_CullingTool.hxx>
21 #include <Graphic3d_GraduatedTrihedron.hxx>
22 #include <Graphic3d_SequenceOfHClipPlane.hxx>
23 #include <Graphic3d_ToneMappingMethod.hxx>
24 #include <Graphic3d_WorldViewProjState.hxx>
25 #include <Graphic3d_ZLayerSettings.hxx>
26 #include <math_BullardGenerator.hxx>
28 #include <OpenGl_Aspects.hxx>
29 #include <OpenGl_FrameBuffer.hxx>
30 #include <OpenGl_FrameStatsPrs.hxx>
31 #include <OpenGl_GraduatedTrihedron.hxx>
32 #include <OpenGl_LayerList.hxx>
33 #include <OpenGl_SceneGeometry.hxx>
34 #include <OpenGl_Structure.hxx>
35 #include <OpenGl_TileSampler.hxx>
40 class OpenGl_BackgroundArray;
41 class OpenGl_DepthPeeling;
42 class OpenGl_PBREnvironment;
43 struct OpenGl_RaytraceMaterial;
44 class OpenGl_ShadowMap;
45 class OpenGl_ShadowMapArray;
46 class OpenGl_ShaderObject;
47 class OpenGl_TextureBuffer;
48 class OpenGl_Workspace;
50 DEFINE_STANDARD_HANDLE(OpenGl_View,Graphic3d_CView)
52 //! Implementation of OpenGl view.
53 class OpenGl_View : public Graphic3d_CView
59 Standard_EXPORT OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
60 const Handle(OpenGl_GraphicDriver)& theDriver,
61 const Handle(OpenGl_Caps)& theCaps,
62 OpenGl_StateCounter* theCounter);
64 //! Default destructor.
65 Standard_EXPORT virtual ~OpenGl_View();
67 //! Release OpenGL resources.
68 Standard_EXPORT virtual void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
70 //! Deletes and erases the view.
71 Standard_EXPORT virtual void Remove() Standard_OVERRIDE;
73 //! @param theDrawToFrontBuffer Advanced option to modify rendering mode:
74 //! 1. TRUE. Drawing immediate mode structures directly to the front buffer over the scene image.
75 //! Fast, so preferred for interactive work (used by default).
76 //! However these extra drawings will be missed in image dump since it is performed from back buffer.
77 //! Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen
78 //! in run-time (in case of slow hardware) and/or tearing may appear.
79 //! So this is strongly recommended to draw only simple (fast) structures.
80 //! 2. FALSE. Drawing immediate mode structures to the back buffer.
81 //! The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync
82 //! is turned on. But it works in any case and is especially useful for view dump because the dump image is read
83 //! from the back buffer.
84 //! @return previous mode.
85 Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) Standard_OVERRIDE;
87 //! Creates and maps rendering window to the view.
88 //! @param theWindow [in] the window.
89 //! @param theContext [in] the rendering context. If NULL the context will be created internally.
90 Standard_EXPORT virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
91 const Aspect_RenderingContext theContext) Standard_OVERRIDE;
93 //! Returns window associated with the view.
94 Standard_EXPORT virtual Handle(Aspect_Window) Window() const Standard_OVERRIDE;
96 //! Returns True if the window associated to the view is defined.
97 virtual Standard_Boolean IsDefined() const Standard_OVERRIDE
98 { return !myWindow.IsNull(); }
100 //! Handle changing size of the rendering window.
101 Standard_EXPORT virtual void Resized() Standard_OVERRIDE;
103 //! Redraw content of the view.
104 Standard_EXPORT virtual void Redraw() Standard_OVERRIDE;
106 //! Redraw immediate content of the view.
107 Standard_EXPORT virtual void RedrawImmediate() Standard_OVERRIDE;
109 //! Marks BVH tree for given priority list as dirty and marks primitive set for rebuild.
110 Standard_EXPORT virtual void Invalidate() Standard_OVERRIDE;
112 //! Return true if view content cache has been invalidated.
113 virtual Standard_Boolean IsInvalidated() Standard_OVERRIDE { return !myBackBufferRestored; }
115 //! Dump active rendering buffer into specified memory buffer.
116 //! In Ray-Tracing allow to get a raw HDR buffer using Graphic3d_BT_RGB_RayTraceHdrLeft buffer type,
117 //! only Left view will be dumped ignoring stereoscopic parameter.
118 Standard_EXPORT virtual Standard_Boolean BufferDump (Image_PixMap& theImage,
119 const Graphic3d_BufferType& theBufferType) Standard_OVERRIDE;
121 //! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
122 Standard_EXPORT virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
124 //! Add a layer to the view.
125 //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
126 //! @param theSettings [in] new layer settings
127 //! @param theLayerAfter [in] id of layer to append new layer before
128 Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
129 const Graphic3d_ZLayerSettings& theSettings,
130 const Graphic3d_ZLayerId theLayerAfter) Standard_OVERRIDE;
132 //! Add a layer to the view.
133 //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
134 //! @param theSettings [in] new layer settings
135 //! @param theLayerBefore [in] id of layer to append new layer after
136 Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
137 const Graphic3d_ZLayerSettings& theSettings,
138 const Graphic3d_ZLayerId theLayerBefore) Standard_OVERRIDE;
140 //! Remove a z layer with the given ID.
141 Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
143 //! Sets the settings for a single Z layer of specified view.
144 Standard_EXPORT virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
145 const Graphic3d_ZLayerSettings& theSettings) Standard_OVERRIDE;
147 //! Returns the maximum Z layer ID.
148 //! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
149 Standard_EXPORT virtual Standard_Integer ZLayerMax() const Standard_OVERRIDE;
151 //! Returns the list of layers.
152 Standard_EXPORT virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const Standard_OVERRIDE;
154 //! Returns layer with given ID or NULL if undefined.
155 Standard_EXPORT virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const Standard_OVERRIDE;
157 //! Returns the bounding box of all structures displayed in the view.
158 //! If theToIncludeAuxiliary is TRUE, then the boundary box also includes minimum and maximum limits
159 //! of graphical elements forming parts of infinite and other auxiliary structures.
160 //! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
161 //! @return computed bounding box
162 Standard_EXPORT virtual Bnd_Box MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const Standard_OVERRIDE;
164 //! Returns pointer to an assigned framebuffer object.
165 Standard_EXPORT virtual Handle(Standard_Transient) FBO() const Standard_OVERRIDE;
167 //! Sets framebuffer object for offscreen rendering.
168 Standard_EXPORT virtual void SetFBO (const Handle(Standard_Transient)& theFbo) Standard_OVERRIDE;
170 //! Generate offscreen FBO in the graphic library.
171 //! If not supported on hardware returns NULL.
172 Standard_EXPORT virtual Handle(Standard_Transient) FBOCreate (const Standard_Integer theWidth,
173 const Standard_Integer theHeight) Standard_OVERRIDE;
175 //! Remove offscreen FBO from the graphic library
176 Standard_EXPORT virtual void FBORelease (Handle(Standard_Transient)& theFbo) Standard_OVERRIDE;
178 //! Read offscreen FBO configuration.
179 Standard_EXPORT virtual void FBOGetDimensions (const Handle(Standard_Transient)& theFbo,
180 Standard_Integer& theWidth,
181 Standard_Integer& theHeight,
182 Standard_Integer& theWidthMax,
183 Standard_Integer& theHeightMax) Standard_OVERRIDE;
185 //! Change offscreen FBO viewport.
186 Standard_EXPORT virtual void FBOChangeViewport (const Handle(Standard_Transient)& theFbo,
187 const Standard_Integer theWidth,
188 const Standard_Integer theHeight) Standard_OVERRIDE;
190 //! Returns additional buffers for depth peeling OIT.
191 const Handle(OpenGl_DepthPeeling)& DepthPeelingFbos() const { return myDepthPeelingFbos; }
195 //! Returns gradient background fill colors.
196 Standard_EXPORT virtual Aspect_GradientBackground GradientBackground() const Standard_OVERRIDE;
198 //! Sets gradient background fill colors.
199 Standard_EXPORT virtual void SetGradientBackground (const Aspect_GradientBackground& theBackground) Standard_OVERRIDE;
201 //! Sets image texture or environment cubemap as background.
202 //! @param theTextureMap [in] source to set a background;
203 //! should be either Graphic3d_Texture2D or Graphic3d_CubeMap
204 //! @param theToUpdatePBREnv [in] defines whether IBL maps will be generated or not
205 //! (see GeneratePBREnvironment())
206 Standard_EXPORT virtual void SetBackgroundImage (const Handle(Graphic3d_TextureMap)& theTextureMap,
207 Standard_Boolean theToUpdatePBREnv = Standard_True) Standard_OVERRIDE;
209 //! Sets environment texture for the view.
210 Standard_EXPORT virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) Standard_OVERRIDE;
212 //! Returns background image fill style.
213 Standard_EXPORT virtual Aspect_FillMethod BackgroundImageStyle() const Standard_OVERRIDE;
215 //! Sets background image fill style.
216 Standard_EXPORT virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) Standard_OVERRIDE;
218 //! Enables or disables IBL (Image Based Lighting) from background cubemap.
219 //! Has no effect if PBR is not used.
220 //! @param[in] theToEnableIBL enable or disable IBL from background cubemap
221 //! @param[in] theToUpdate redraw the view
222 Standard_EXPORT virtual void SetImageBasedLighting (Standard_Boolean theToEnableIBL) Standard_OVERRIDE;
224 //! Returns number of mipmap levels used in specular IBL map.
225 //! 0 if PBR environment is not created.
226 Standard_EXPORT unsigned int SpecIBLMapLevels() const;
228 //! Returns local camera origin currently set for rendering, might be modified during rendering.
229 const gp_XYZ& LocalOrigin() const { return myLocalOrigin; }
231 //! Setup local camera origin currently set for rendering.
232 Standard_EXPORT void SetLocalOrigin (const gp_XYZ& theOrigin);
234 //! Returns list of lights of the view.
235 virtual const Handle(Graphic3d_LightSet)& Lights() const Standard_OVERRIDE { return myLights; }
237 //! Sets list of lights for the view.
238 virtual void SetLights (const Handle(Graphic3d_LightSet)& theLights) Standard_OVERRIDE
240 myLights = theLights;
241 myCurrLightSourceState = myStateCounter->Increment();
244 //! Returns list of clip planes set for the view.
245 virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const Standard_OVERRIDE { return myClipPlanes; }
247 //! Sets list of clip planes for the view.
248 virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) Standard_OVERRIDE { myClipPlanes = thePlanes; }
250 //! Fill in the dictionary with diagnostic info.
251 //! Should be called within rendering thread.
253 //! This API should be used only for user output or for creating automated reports.
254 //! The format of returned information (e.g. key-value layout)
255 //! is NOT part of this API and can be changed at any time.
256 //! Thus application should not parse returned information to weed out specific parameters.
257 Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
258 Graphic3d_DiagnosticInfo theFlags) const Standard_OVERRIDE;
260 //! Returns string with statistic performance info.
261 Standard_EXPORT virtual TCollection_AsciiString StatisticInformation() const Standard_OVERRIDE;
263 //! Fills in the dictionary with statistic performance info.
264 Standard_EXPORT virtual void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const Standard_OVERRIDE;
268 //! Returns background color.
269 const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; }
271 //! Change graduated trihedron.
272 OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
274 void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
275 const Handle(Graphic3d_TextureEnv)& theTexture);
277 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
279 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
281 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
283 //! Returns list of OpenGL Z-layers.
284 const OpenGl_LayerList& LayerList() const { return myZLayers; }
286 //! Returns OpenGL window implementation.
287 const Handle(OpenGl_Window)& GlWindow() const { return myWindow; }
289 //! Returns OpenGL environment map.
290 const Handle(OpenGl_TextureSet)& GlTextureEnv() const { return myTextureEnv; }
292 //! Returns selector for BVH tree, providing a possibility to store information
293 //! about current view volume and to detect which objects are overlapping it.
294 const Graphic3d_CullingTool& BVHTreeSelector() const { return myBVHSelector; }
296 //! Returns true if there are immediate structures to display
297 bool HasImmediateStructures() const
299 return myZLayers.NbImmediateStructures() != 0;
302 public: //! @name obsolete Graduated Trihedron functionality
304 //! Displays Graduated Trihedron.
305 Standard_EXPORT virtual void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) Standard_OVERRIDE;
307 //! Erases Graduated Trihedron.
308 Standard_EXPORT virtual void GraduatedTrihedronErase() Standard_OVERRIDE;
310 //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object.
311 //! @param theMin [in] the minimum point of scene.
312 //! @param theMax [in] the maximum point of scene.
313 Standard_EXPORT virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax) Standard_OVERRIDE;
315 protected: //! @name Internal methods for managing GL resources
317 //! Initializes OpenGl resource for environment texture.
318 void initTextureEnv (const Handle(OpenGl_Context)& theContext);
320 protected: //! @name low-level redrawing sub-routines
322 //! Prepare frame buffers for rendering.
323 Standard_EXPORT virtual bool prepareFrameBuffers (Graphic3d_Camera::Projection& theProj);
325 //! Redraws view for the given monographic camera projection, or left/right eye.
326 Standard_EXPORT virtual void redraw (const Graphic3d_Camera::Projection theProjection,
327 OpenGl_FrameBuffer* theReadDrawFbo,
328 OpenGl_FrameBuffer* theOitAccumFbo);
330 //! Redraws view for the given monographic camera projection, or left/right eye.
332 //! Method will blit snapshot containing main scene (myMainSceneFbos or BackBuffer)
333 //! into presentation buffer (myMainSceneFbos -> offscreen FBO or
334 //! myMainSceneFbos -> BackBuffer or BackBuffer -> FrontBuffer),
335 //! and redraw immediate structures on top.
337 //! When scene caching is disabled (myTransientDrawToFront, no double buffer in window, etc.),
338 //! the first step (blitting) will be skipped.
340 //! @return false if immediate structures has been rendered directly into FrontBuffer
341 //! and Buffer Swap should not be called.
342 Standard_EXPORT virtual bool redrawImmediate (const Graphic3d_Camera::Projection theProjection,
343 OpenGl_FrameBuffer* theReadFbo,
344 OpenGl_FrameBuffer* theDrawFbo,
345 OpenGl_FrameBuffer* theOitAccumFbo,
346 const Standard_Boolean theIsPartialUpdate = Standard_False);
348 //! Blit image from/to specified buffers.
349 Standard_EXPORT bool blitBuffers (OpenGl_FrameBuffer* theReadFbo,
350 OpenGl_FrameBuffer* theDrawFbo,
351 const Standard_Boolean theToFlip = Standard_False);
353 //! Setup default FBO.
354 Standard_EXPORT void bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo = NULL);
356 protected: //! @name Rendering of GL graphics (with prepared drawing buffer).
358 //! Renders the graphical contents of the view into the preprepared shadowmap framebuffer.
359 //! @param theShadowMap [in] the framebuffer for rendering shadowmap.
360 Standard_EXPORT virtual void renderShadowMap (const Handle(OpenGl_ShadowMap)& theShadowMap);
362 //! Renders the graphical contents of the view into the preprepared window or framebuffer.
363 //! @param theProjection [in] the projection that should be used for rendering.
364 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
365 //! @param theOitAccumFbo [in] the framebuffer for accumulating color and coverage for OIT process.
366 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
367 Standard_EXPORT virtual void render (Graphic3d_Camera::Projection theProjection,
368 OpenGl_FrameBuffer* theReadDrawFbo,
369 OpenGl_FrameBuffer* theOitAccumFbo,
370 const Standard_Boolean theToDrawImmediate);
372 //! Renders the graphical scene.
373 //! @param theProjection [in] the projection that is used for rendering.
374 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
375 //! @param theOitAccumFbo [in] the framebuffer for accumulating color and coverage for OIT process.
376 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
377 Standard_EXPORT virtual void renderScene (Graphic3d_Camera::Projection theProjection,
378 OpenGl_FrameBuffer* theReadDrawFbo,
379 OpenGl_FrameBuffer* theOitAccumFbo,
380 const Standard_Boolean theToDrawImmediate);
382 //! Draw background (gradient / image)
383 Standard_EXPORT virtual void drawBackground (const Handle(OpenGl_Workspace)& theWorkspace,
384 Graphic3d_Camera::Projection theProjection);
386 //! Render set of structures presented in the view.
387 //! @param theProjection [in] the projection that is used for rendering.
388 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
389 //! @param theOitAccumFbo [in] the framebuffer for accumulating color and coverage for OIT process.
390 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
391 Standard_EXPORT virtual void renderStructs (Graphic3d_Camera::Projection theProjection,
392 OpenGl_FrameBuffer* theReadDrawFbo,
393 OpenGl_FrameBuffer* theOitAccumFbo,
394 const Standard_Boolean theToDrawImmediate);
396 //! Renders trihedron.
397 void renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace);
399 //! Renders frame statistics.
400 void renderFrameStats();
404 //! Adds the structure to display lists of the view.
405 Standard_EXPORT virtual void displayStructure (const Handle(Graphic3d_CStructure)& theStructure,
406 const Standard_Integer thePriority) Standard_OVERRIDE;
408 //! Erases the structure from display lists of the view.
409 Standard_EXPORT virtual void eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) Standard_OVERRIDE;
411 //! Change Z layer of a structure already presented in view.
412 Standard_EXPORT virtual void changeZLayer (const Handle(Graphic3d_CStructure)& theCStructure,
413 const Graphic3d_ZLayerId theNewLayerId) Standard_OVERRIDE;
415 //! Changes the priority of a structure within its Z layer in the specified view.
416 Standard_EXPORT virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
417 const Standard_Integer theNewPriority) Standard_OVERRIDE;
421 //! Release sRGB resources (frame-buffers, textures, etc.).
422 void releaseSrgbResources (const Handle(OpenGl_Context)& theCtx);
424 //! Copy content of Back buffer to the Front buffer.
425 bool copyBackToFront();
427 //! Initialize blit quad.
428 OpenGl_VertexBuffer* initBlitQuad (const Standard_Boolean theToFlip);
430 //! Blend together views pair into stereo image.
431 void drawStereoPair (OpenGl_FrameBuffer* theDrawFbo);
433 //! Check and update OIT compatibility with current OpenGL context's state.
434 bool checkOitCompatibility (const Handle(OpenGl_Context)& theGlContext,
435 const Standard_Boolean theMSAA);
439 OpenGl_GraphicDriver* myDriver;
440 Handle(OpenGl_Window) myWindow;
441 Handle(OpenGl_Workspace) myWorkspace;
442 Handle(OpenGl_Caps) myCaps;
443 Standard_Boolean myWasRedrawnGL;
445 Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
446 gp_XYZ myLocalOrigin;
447 Handle(OpenGl_FrameBuffer) myFBO;
448 Standard_Boolean myToShowGradTrihedron;
449 Graphic3d_GraduatedTrihedron myGTrihedronData;
451 Handle(Graphic3d_LightSet) myNoShadingLight;
452 Handle(Graphic3d_LightSet) myLights;
453 OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers
455 Graphic3d_WorldViewProjState myWorldViewProjState; //!< camera modification state
456 OpenGl_StateCounter* myStateCounter;
457 Standard_Size myCurrLightSourceState;
458 Standard_Size myLightsRevision;
460 typedef std::pair<Standard_Size, Standard_Size> StateInfo;
462 StateInfo myLastOrientationState;
463 StateInfo myLastViewMappingState;
464 StateInfo myLastLightSourceState;
466 //! Is needed for selection of overlapping objects and storage of the current view volume
467 Graphic3d_CullingTool myBVHSelector;
469 OpenGl_GraduatedTrihedron myGraduatedTrihedron;
470 OpenGl_FrameStatsPrs myFrameStatsPrs;
472 //! Framebuffers for OpenGL output.
473 Handle(OpenGl_FrameBuffer) myOpenGlFBO;
474 Handle(OpenGl_FrameBuffer) myOpenGlFBO2;
476 protected: //! @name Rendering properties
478 //! Two framebuffers (left and right views) store cached main presentation
479 //! of the view (without presentation of immediate layers).
480 Standard_Integer mySRgbState; //!< track sRGB state
481 GLint myFboColorFormat; //!< sized format for color attachments
482 GLint myFboDepthFormat; //!< sized format for depth-stencil attachments
483 OpenGl_ColorFormats myFboOitColorConfig; //!< selected color format configuration for OIT color attachments
484 Handle(OpenGl_FrameBuffer) myMainSceneFbos[2];
485 Handle(OpenGl_FrameBuffer) myMainSceneFbosOit[2]; //!< Additional buffers for transparent draw of main layer.
486 Handle(OpenGl_FrameBuffer) myImmediateSceneFbos[2]; //!< Additional buffers for immediate layer in stereo mode.
487 Handle(OpenGl_FrameBuffer) myImmediateSceneFbosOit[2]; //!< Additional buffers for transparency draw of immediate layer.
488 Handle(OpenGl_FrameBuffer) myXrSceneFbo; //!< additional FBO (without MSAA) for submitting to XR
489 Handle(OpenGl_DepthPeeling) myDepthPeelingFbos; //!< additional buffers for depth peeling
490 Handle(OpenGl_ShadowMapArray) myShadowMaps; //!< additional FBOs for shadow map rendering
491 OpenGl_VertexBuffer myFullScreenQuad; //!< Vertices for full-screen quad rendering.
492 OpenGl_VertexBuffer myFullScreenQuadFlip;
493 Standard_Boolean myToFlipOutput; //!< Flag to draw result image upside-down
494 unsigned int myFrameCounter; //!< redraw counter, for debugging
495 Standard_Boolean myHasFboBlit; //!< disable FBOs on failure
496 Standard_Boolean myToDisableOIT; //!< disable OIT on failure
497 Standard_Boolean myToDisableOITMSAA; //!< disable OIT with MSAA on failure
498 Standard_Boolean myToDisableMSAA; //!< disable MSAA after failure
499 Standard_Boolean myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer)
500 Standard_Boolean myBackBufferRestored;
501 Standard_Boolean myIsImmediateDrawn; //!< flag indicates that immediate mode buffer contains some data
503 protected: //! @name Background parameters
505 OpenGl_Aspects* myTextureParams; //!< Stores texture and its parameters for textured background
506 OpenGl_Aspects* myCubeMapParams; //!< Stores cubemap and its parameters for cubemap background
507 OpenGl_Aspects* myColoredQuadParams; //!< Stores parameters for gradient (corner mode) background
508 OpenGl_BackgroundArray* myBackgrounds[Graphic3d_TypeOfBackground_NB]; //!< Array of primitive arrays of different background types
509 Handle(OpenGl_TextureSet) myTextureEnv;
511 protected: //! @name methods related to PBR
513 //! Checks whether PBR is available.
514 Standard_EXPORT Standard_Boolean checkPBRAvailability() const;
516 //! Generates IBL maps used in PBR pipeline.
517 //! If background cubemap is not set clears all IBL maps.
518 Standard_EXPORT void updatePBREnvironment (const Handle(OpenGl_Context)& theCtx);
520 protected: //! @name fields and types related to PBR
522 //! State of PBR environment.
523 enum PBREnvironmentState
525 OpenGl_PBREnvState_NONEXISTENT,
526 OpenGl_PBREnvState_UNAVAILABLE, // indicates failed try to create PBR environment
527 OpenGl_PBREnvState_CREATED
530 Handle(OpenGl_PBREnvironment) myPBREnvironment; //!< manager of IBL maps used in PBR pipeline
531 PBREnvironmentState myPBREnvState; //!< state of PBR environment
532 Standard_Boolean myPBREnvRequest; //!< update PBR environment
534 protected: //! @name data types related to ray-tracing
536 //! Result of OpenGL shaders initialization.
537 enum RaytraceInitStatus
544 //! Describes update mode (state).
545 enum RaytraceUpdateMode
547 OpenGl_GUM_CHECK, //!< check geometry state
548 OpenGl_GUM_PREPARE, //!< collect unchanged objects
549 OpenGl_GUM_REBUILD //!< rebuild changed and new objects
552 //! Defines frequently used shader variables.
553 enum ShaderVariableIndex
566 OpenGl_RT_uViewPrMat,
567 OpenGl_RT_uUnviewMat,
572 OpenGl_RT_uLightAmbnt,
573 OpenGl_RT_uLightCount,
576 OpenGl_RT_uBackColorTop,
577 OpenGl_RT_uBackColorBot,
579 // ray-tracing params
580 OpenGl_RT_uShadowsEnabled,
581 OpenGl_RT_uReflectEnabled,
582 OpenGl_RT_uEnvMapEnabled,
583 OpenGl_RT_uEnvMapForBack,
584 OpenGl_RT_uTexSamplersArray,
585 OpenGl_RT_uBlockedRngEnabled,
587 // size of render window
591 // sampled frame params
592 OpenGl_RT_uAccumSamples,
593 OpenGl_RT_uFrameRndSeed,
595 // adaptive FSAA params
596 OpenGl_RT_uFsaaOffset,
599 // images used by ISS mode
600 OpenGl_RT_uRenderImage,
601 OpenGl_RT_uTilesImage,
602 OpenGl_RT_uOffsetImage,
604 OpenGl_RT_uVarianceScaleFactor,
606 // maximum radiance value
607 OpenGl_RT_uMaxRadiance,
609 OpenGl_RT_NbVariables // special field
612 //! Defines OpenGL image samplers.
613 enum ShaderImageNames
615 OpenGl_RT_OutputImage = 0,
616 OpenGl_RT_VisualErrorImage = 1,
617 OpenGl_RT_TileOffsetsImage = 2,
618 OpenGl_RT_TileSamplesImage = 3
621 //! Tool class for management of shader sources.
626 //! Default shader prefix - empty string.
627 static const TCollection_AsciiString EMPTY_PREFIX;
629 //! Creates new uninitialized shader source.
637 //! Returns error description in case of load fail.
638 const TCollection_AsciiString& ErrorDescription() const
643 //! Returns prefix to insert before the source.
644 const TCollection_AsciiString& Prefix() const
649 //! Sets prefix to insert before the source.
650 void SetPrefix (const TCollection_AsciiString& thePrefix)
652 myPrefix = thePrefix;
655 //! Returns shader source combined with prefix.
656 TCollection_AsciiString Source (const Handle(OpenGl_Context)& theCtx,
657 const GLenum theType) const;
659 //! Loads shader source from specified files.
660 Standard_Boolean LoadFromFiles (const TCollection_AsciiString* theFileNames, const TCollection_AsciiString& thePrefix = EMPTY_PREFIX);
662 //! Loads shader source from specified strings.
663 Standard_Boolean LoadFromStrings (const TCollection_AsciiString* theStrings, const TCollection_AsciiString& thePrefix = EMPTY_PREFIX);
667 TCollection_AsciiString mySource; //!< Source string of the shader object
668 TCollection_AsciiString myPrefix; //!< Prefix to insert before the source
669 TCollection_AsciiString myError; //!< error state
673 //! Default ray-tracing depth.
674 static const Standard_Integer THE_DEFAULT_NB_BOUNCES = 3;
676 //! Default size of traversal stack.
677 static const Standard_Integer THE_DEFAULT_STACK_SIZE = 10;
679 //! Compile-time ray-tracing parameters.
680 struct RaytracingParams
682 //! Actual size of traversal stack in shader program.
683 Standard_Integer StackSize;
685 //! Actual ray-tracing depth (number of ray bounces).
686 Standard_Integer NbBounces;
688 //! Define depth computation
689 Standard_Boolean IsZeroToOneDepth;
691 //! Enables/disables light propagation through transparent media.
692 Standard_Boolean TransparentShadows;
694 //! Enables/disables global illumination (GI) effects.
695 Standard_Boolean GlobalIllumination;
697 //! Enables/disables the use of OpenGL bindless textures.
698 Standard_Boolean UseBindlessTextures;
700 //! Enables/disables two-sided BSDF models instead of one-sided.
701 Standard_Boolean TwoSidedBsdfModels;
703 //! Enables/disables adaptive screen sampling for path tracing.
704 Standard_Boolean AdaptiveScreenSampling;
706 //! Enables/disables 1-pass atomic mode for AdaptiveScreenSampling.
707 Standard_Boolean AdaptiveScreenSamplingAtomic;
709 //! Enables/disables environment map for background.
710 Standard_Boolean UseEnvMapForBackground;
712 //! Enables/disables normal map ignoring during path tracing.
713 Standard_Boolean ToIgnoreNormalMap;
715 //! Maximum radiance value used for clamping radiance estimation.
716 Standard_ShortReal RadianceClampingValue;
718 //! Enables/disables depth-of-field effect (path tracing, perspective camera).
719 Standard_Boolean DepthOfField;
721 //! Enables/disables cubemap background.
722 Standard_Boolean CubemapForBack;
724 //! Tone mapping method for path tracing.
725 Graphic3d_ToneMappingMethod ToneMappingMethod;
727 //! Creates default compile-time ray-tracing parameters.
729 : StackSize (THE_DEFAULT_STACK_SIZE),
730 NbBounces (THE_DEFAULT_NB_BOUNCES),
731 IsZeroToOneDepth (Standard_False),
732 TransparentShadows (Standard_False),
733 GlobalIllumination (Standard_False),
734 UseBindlessTextures (Standard_False),
735 TwoSidedBsdfModels (Standard_False),
736 AdaptiveScreenSampling (Standard_False),
737 AdaptiveScreenSamplingAtomic (Standard_False),
738 UseEnvMapForBackground (Standard_False),
739 ToIgnoreNormalMap (Standard_False),
740 RadianceClampingValue (30.0),
741 DepthOfField (Standard_False),
742 CubemapForBack (Standard_False),
743 ToneMappingMethod (Graphic3d_ToneMappingMethod_Disabled) { }
746 //! Describes state of OpenGL structure.
749 Standard_Size StructureState;
750 Standard_Size InstancedState;
752 //! Creates new structure state.
753 StructState (const Standard_Size theStructureState = 0,
754 const Standard_Size theInstancedState = 0)
755 : StructureState (theStructureState),
756 InstancedState (theInstancedState)
761 //! Creates new structure state.
762 StructState (const OpenGl_Structure* theStructure)
764 StructureState = theStructure->ModificationState();
766 InstancedState = theStructure->InstancedStructure() != NULL ?
767 theStructure->InstancedStructure()->ModificationState() : 0;
771 protected: //! @name methods related to ray-tracing
773 //! Updates 3D scene geometry for ray-tracing.
774 Standard_Boolean updateRaytraceGeometry (const RaytraceUpdateMode theMode,
775 const Standard_Integer theViewId,
776 const Handle(OpenGl_Context)& theGlContext);
778 //! Updates 3D scene light sources for ray-tracing.
779 Standard_Boolean updateRaytraceLightSources (const OpenGl_Mat4& theInvModelView, const Handle(OpenGl_Context)& theGlContext);
781 //! Checks to see if the OpenGL structure is modified.
782 Standard_Boolean toUpdateStructure (const OpenGl_Structure* theStructure);
784 //! Adds OpenGL structure to ray-traced scene geometry.
785 Standard_Boolean addRaytraceStructure (const OpenGl_Structure* theStructure,
786 const Handle(OpenGl_Context)& theGlContext);
788 //! Adds OpenGL groups to ray-traced scene geometry.
789 Standard_Boolean addRaytraceGroups (const OpenGl_Structure* theStructure,
790 const OpenGl_RaytraceMaterial& theStructMat,
791 const Handle(TopLoc_Datum3D)& theTrsf,
792 const Handle(OpenGl_Context)& theGlContext);
794 //! Creates ray-tracing material properties.
795 OpenGl_RaytraceMaterial convertMaterial (const OpenGl_Aspects* theAspect,
796 const Handle(OpenGl_Context)& theGlContext);
798 //! Adds OpenGL primitive array to ray-traced scene geometry.
799 Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
800 const Standard_Integer theMatID,
801 const OpenGl_Mat4* theTrans);
803 //! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
804 Standard_Boolean addRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
805 const Standard_Integer theMatID,
806 const Standard_Integer theCount,
807 const Standard_Integer theOffset,
808 const OpenGl_PrimitiveArray& theArray);
810 //! Adds OpenGL triangle array to ray-traced scene geometry.
811 Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
812 const Standard_Integer theMatID,
813 const Standard_Integer theCount,
814 const Standard_Integer theOffset,
815 const Handle(Graphic3d_IndexBuffer)& theIndices);
817 //! Adds OpenGL triangle fan array to ray-traced scene geometry.
818 Standard_Boolean addRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
819 const Standard_Integer theMatID,
820 const Standard_Integer theCount,
821 const Standard_Integer theOffset,
822 const Handle(Graphic3d_IndexBuffer)& theIndices);
824 //! Adds OpenGL triangle strip array to ray-traced scene geometry.
825 Standard_Boolean addRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
826 const Standard_Integer theMatID,
827 const Standard_Integer theCount,
828 const Standard_Integer theOffset,
829 const Handle(Graphic3d_IndexBuffer)& theIndices);
831 //! Adds OpenGL quadrangle array to ray-traced scene geometry.
832 Standard_Boolean addRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
833 const Standard_Integer theMatID,
834 const Standard_Integer theCount,
835 const Standard_Integer theOffset,
836 const Handle(Graphic3d_IndexBuffer)& theIndices);
838 //! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
839 Standard_Boolean addRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
840 const Standard_Integer theMatID,
841 const Standard_Integer theCount,
842 const Standard_Integer theOffset,
843 const Handle(Graphic3d_IndexBuffer)& theIndices);
845 //! Adds OpenGL polygon array to ray-traced scene geometry.
846 Standard_Boolean addRaytracePolygonArray (OpenGl_TriangleSet& theSet,
847 const Standard_Integer theMatID,
848 const Standard_Integer theCount,
849 const Standard_Integer theOffset,
850 const Handle(Graphic3d_IndexBuffer)& theIndices);
852 //! Uploads ray-trace data to the GPU.
853 Standard_Boolean uploadRaytraceData (const Handle(OpenGl_Context)& theGlContext);
855 //! Generates shader prefix based on current ray-tracing options.
856 TCollection_AsciiString generateShaderPrefix (const Handle(OpenGl_Context)& theGlContext) const;
858 //! Performs safe exit when shaders initialization fails.
859 Standard_Boolean safeFailBack (const TCollection_ExtendedString& theMessage,
860 const Handle(OpenGl_Context)& theGlContext);
862 //! Loads and compiles shader object from specified source.
863 Handle(OpenGl_ShaderObject) initShader (const GLenum theType,
864 const ShaderSource& theSource,
865 const Handle(OpenGl_Context)& theGlContext);
867 //! Creates shader program from the given vertex and fragment shaders.
868 Handle(OpenGl_ShaderProgram) initProgram (const Handle(OpenGl_Context)& theGlContext,
869 const Handle(OpenGl_ShaderObject)& theVertShader,
870 const Handle(OpenGl_ShaderObject)& theFragShader,
871 const TCollection_AsciiString& theName);
873 //! Initializes OpenGL/GLSL shader programs.
874 Standard_Boolean initRaytraceResources (const Standard_Integer theSizeX,
875 const Standard_Integer theSizeY,
876 const Handle(OpenGl_Context)& theGlContext);
878 //! Releases OpenGL/GLSL shader programs.
879 void releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext,
880 const Standard_Boolean theToRebuild = Standard_False);
882 //! Updates auxiliary OpenGL frame buffers.
883 Standard_Boolean updateRaytraceBuffers (const Standard_Integer theSizeX,
884 const Standard_Integer theSizeY,
885 const Handle(OpenGl_Context)& theGlContext);
887 //! Generates viewing rays for corners of screen quad.
888 //! (ray tracing; path tracing for orthographic camera)
889 void updateCamera (const OpenGl_Mat4& theOrientation,
890 const OpenGl_Mat4& theViewMapping,
891 OpenGl_Vec3* theOrigins,
892 OpenGl_Vec3* theDirects,
893 OpenGl_Mat4& theView,
894 OpenGl_Mat4& theUnView);
896 //! Generate viewing rays (path tracing, perspective camera).
897 void updatePerspCameraPT(const OpenGl_Mat4& theOrientation,
898 const OpenGl_Mat4& theViewMapping,
899 Graphic3d_Camera::Projection theProjection,
900 OpenGl_Mat4& theViewPr,
901 OpenGl_Mat4& theUnview,
902 const int theWinSizeX,
903 const int theWinSizeY);
905 //! Binds ray-trace textures to corresponding texture units.
906 void bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext,
909 //! Unbinds ray-trace textures from corresponding texture unit.
910 void unbindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
912 //! Sets uniform state for the given ray-tracing shader program.
913 Standard_Boolean setUniformState (const Standard_Integer theProgramId,
914 const Standard_Integer theSizeX,
915 const Standard_Integer theSizeY,
916 Graphic3d_Camera::Projection theProjection,
917 const Handle(OpenGl_Context)& theGlContext);
919 //! Runs ray-tracing shader programs.
920 Standard_Boolean runRaytraceShaders (const Standard_Integer theSizeX,
921 const Standard_Integer theSizeY,
922 Graphic3d_Camera::Projection theProjection,
923 OpenGl_FrameBuffer* theReadDrawFbo,
924 const Handle(OpenGl_Context)& theGlContext);
926 //! Runs classical (Whitted-style) ray-tracing kernel.
927 Standard_Boolean runRaytrace (const Standard_Integer theSizeX,
928 const Standard_Integer theSizeY,
929 Graphic3d_Camera::Projection theProjection,
930 OpenGl_FrameBuffer* theReadDrawFbo,
931 const Handle(OpenGl_Context)& theGlContext);
933 //! Runs path tracing (global illumination) kernel.
934 Standard_Boolean runPathtrace (const Standard_Integer theSizeX,
935 const Standard_Integer theSizeY,
936 Graphic3d_Camera::Projection theProjection,
937 const Handle(OpenGl_Context)& theGlContext);
939 //! Runs path tracing (global illumination) kernel.
940 Standard_Boolean runPathtraceOut (Graphic3d_Camera::Projection theProjection,
941 OpenGl_FrameBuffer* theReadDrawFbo,
942 const Handle(OpenGl_Context)& theGlContext);
944 //! Redraws the window using OpenGL/GLSL ray-tracing or path tracing.
945 Standard_Boolean raytrace (const Standard_Integer theSizeX,
946 const Standard_Integer theSizeY,
947 Graphic3d_Camera::Projection theProjection,
948 OpenGl_FrameBuffer* theReadDrawFbo,
949 const Handle(OpenGl_Context)& theGlContext);
951 protected: //! @name fields related to ray-tracing
953 //! Result of RT/PT shaders initialization.
954 RaytraceInitStatus myRaytraceInitStatus;
956 //! Is ray-tracing geometry data valid?
957 Standard_Boolean myIsRaytraceDataValid;
959 //! True if warning about missing extension GL_ARB_bindless_texture has been displayed.
960 Standard_Boolean myIsRaytraceWarnTextures;
962 //! 3D scene geometry data for ray-tracing.
963 OpenGl_RaytraceGeometry myRaytraceGeometry;
965 //! Builder for triangle set.
966 opencascade::handle<BVH_Builder<Standard_ShortReal, 3> > myRaytraceBVHBuilder;
968 //! Compile-time ray-tracing parameters.
969 RaytracingParams myRaytraceParameters;
971 //! Radius of bounding sphere of the scene.
972 Standard_ShortReal myRaytraceSceneRadius;
973 //! Scene epsilon to prevent self-intersections.
974 Standard_ShortReal myRaytraceSceneEpsilon;
976 //! OpenGL/GLSL source of ray-tracing fragment shader.
977 ShaderSource myRaytraceShaderSource;
978 //! OpenGL/GLSL source of adaptive-AA fragment shader.
979 ShaderSource myPostFSAAShaderSource;
980 //! OpenGL/GLSL source of RT/PT display fragment shader.
981 ShaderSource myOutImageShaderSource;
983 //! OpenGL/GLSL ray-tracing fragment shader.
984 Handle(OpenGl_ShaderObject) myRaytraceShader;
985 //! OpenGL/GLSL adaptive-AA fragment shader.
986 Handle(OpenGl_ShaderObject) myPostFSAAShader;
987 //! OpenGL/GLSL ray-tracing display fragment shader.
988 Handle(OpenGl_ShaderObject) myOutImageShader;
990 //! OpenGL/GLSL ray-tracing shader program.
991 Handle(OpenGl_ShaderProgram) myRaytraceProgram;
992 //! OpenGL/GLSL adaptive-AA shader program.
993 Handle(OpenGl_ShaderProgram) myPostFSAAProgram;
994 //! OpenGL/GLSL program for displaying texture.
995 Handle(OpenGl_ShaderProgram) myOutImageProgram;
997 //! Texture buffer of data records of bottom-level BVH nodes.
998 Handle(OpenGl_TextureBuffer) mySceneNodeInfoTexture;
999 //! Texture buffer of minimum points of bottom-level BVH nodes.
1000 Handle(OpenGl_TextureBuffer) mySceneMinPointTexture;
1001 //! Texture buffer of maximum points of bottom-level BVH nodes.
1002 Handle(OpenGl_TextureBuffer) mySceneMaxPointTexture;
1003 //! Texture buffer of transformations of high-level BVH nodes.
1004 Handle(OpenGl_TextureBuffer) mySceneTransformTexture;
1006 //! Texture buffer of vertex coords.
1007 Handle(OpenGl_TextureBuffer) myGeometryVertexTexture;
1008 //! Texture buffer of vertex normals.
1009 Handle(OpenGl_TextureBuffer) myGeometryNormalTexture;
1010 //! Texture buffer of vertex UV coords.
1011 Handle(OpenGl_TextureBuffer) myGeometryTexCrdTexture;
1012 //! Texture buffer of triangle indices.
1013 Handle(OpenGl_TextureBuffer) myGeometryTriangTexture;
1015 //! Texture buffer of material properties.
1016 Handle(OpenGl_TextureBuffer) myRaytraceMaterialTexture;
1017 //! Texture buffer of light source properties.
1018 Handle(OpenGl_TextureBuffer) myRaytraceLightSrcTexture;
1020 //! 1st framebuffer (FBO) to perform adaptive FSAA.
1021 //! Used in compatibility mode (no adaptive sampling).
1022 Handle(OpenGl_FrameBuffer) myRaytraceFBO1[2];
1023 //! 2nd framebuffer (FBO) to perform adaptive FSAA.
1024 //! Used in compatibility mode (no adaptive sampling).
1025 Handle(OpenGl_FrameBuffer) myRaytraceFBO2[2];
1027 //! Output textures (2 textures are used in stereo mode).
1028 //! Used if adaptive screen sampling is activated.
1029 Handle(OpenGl_Texture) myRaytraceOutputTexture[2];
1031 //! Texture containing per-tile visual error estimation (2 textures are used in stereo mode).
1032 //! Used if adaptive screen sampling is activated.
1033 Handle(OpenGl_Texture) myRaytraceVisualErrorTexture[2];
1034 //! Texture containing offsets of sampled screen tiles (2 textures are used in stereo mode).
1035 //! Used if adaptive screen sampling is activated.
1036 Handle(OpenGl_Texture) myRaytraceTileOffsetsTexture[2];
1037 //! Texture containing amount of extra per-tile samples (2 textures are used in stereo mode).
1038 //! Used if adaptive screen sampling is activated.
1039 Handle(OpenGl_Texture) myRaytraceTileSamplesTexture[2];
1041 //! Vertex buffer (VBO) for drawing dummy quad.
1042 OpenGl_VertexBuffer myRaytraceScreenQuad;
1044 //! Cached locations of frequently used uniform variables.
1045 Standard_Integer myUniformLocations[2][OpenGl_RT_NbVariables];
1047 //! State of OpenGL structures reflected to ray-tracing.
1048 std::map<const OpenGl_Structure*, StructState> myStructureStates;
1050 //! PrimitiveArray to TriangleSet map for scene partial update.
1051 std::map<Standard_Size, OpenGl_TriangleSet*> myArrayToTrianglesMap;
1053 //! Set of IDs of non-raytracable elements (to detect updates).
1054 std::set<Standard_Integer> myNonRaytraceStructureIDs;
1056 //! Marks if environment map should be updated.
1057 Standard_Boolean myToUpdateEnvironmentMap;
1059 //! State of OpenGL layer list.
1060 Standard_Size myRaytraceLayerListState;
1062 //! Number of accumulated frames (for progressive rendering).
1063 Standard_Integer myAccumFrames;
1065 //! Stored ray origins used for detection of camera movements.
1066 OpenGl_Vec3 myPreviousOrigins[3];
1068 //! Bullard RNG to produce random sequence.
1069 math_BullardGenerator myRNG;
1071 //! Tool object for sampling screen tiles in PT mode.
1072 OpenGl_TileSampler myTileSampler;
1074 //! Camera position used for projective mode
1075 OpenGl_Vec3 myEyeOrig;
1077 //! Camera view direction used for projective mode
1078 OpenGl_Vec3 myEyeView;
1080 //! Camera's screen vertical direction used for projective mode
1081 OpenGl_Vec3 myEyeVert;
1083 //! Camera's screen horizontal direction used for projective mode
1084 OpenGl_Vec3 myEyeSide;
1086 //! Camera's screen size used for projective mode
1087 OpenGl_Vec2 myEyeSize;
1089 //! Aperture radius of camera on previous frame used for depth-of-field (path tracing)
1090 float myPrevCameraApertureRadius;
1092 //! Focal distance of camera on previous frame used for depth-of-field (path tracing)
1093 float myPrevCameraFocalPlaneDist;
1097 DEFINE_STANDARD_ALLOC
1098 DEFINE_STANDARD_RTTIEXT(OpenGl_View,Graphic3d_CView) // Type definition
1100 friend class OpenGl_GraphicDriver;
1101 friend class OpenGl_Workspace;
1102 friend class OpenGl_LayerList;
1103 friend class OpenGl_FrameStats;
1106 #endif // _OpenGl_View_Header