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_Header
17 #define _OpenGl_View_Header
19 #include <Standard_Transient.hxx>
20 #include <Standard_Type.hxx>
22 #include <TColStd_Array2OfReal.hxx>
23 #include <NCollection_List.hxx>
24 #include <math_BullardGenerator.hxx>
26 #include <Quantity_NameOfColor.hxx>
27 #include <Aspect_FillMethod.hxx>
28 #include <Aspect_GradientFillMethod.hxx>
30 #include <Graphic3d_CView.hxx>
31 #include <Graphic3d_GraduatedTrihedron.hxx>
32 #include <Graphic3d_SequenceOfHClipPlane.hxx>
33 #include <Graphic3d_ToneMappingMethod.hxx>
34 #include <Graphic3d_TypeOfShadingModel.hxx>
35 #include <Graphic3d_WorldViewProjState.hxx>
36 #include <Graphic3d_ZLayerSettings.hxx>
38 #include <OpenGl_AspectFace.hxx>
39 #include <OpenGl_BackgroundArray.hxx>
40 #include <OpenGl_BVHTreeSelector.hxx>
41 #include <OpenGl_Context.hxx>
42 #include <OpenGl_FrameBuffer.hxx>
43 #include <OpenGl_GraduatedTrihedron.hxx>
44 #include <OpenGl_LayerList.hxx>
45 #include <OpenGl_Light.hxx>
46 #include <OpenGl_LineAttributes.hxx>
47 #include <OpenGl_SceneGeometry.hxx>
48 #include <OpenGl_Structure.hxx>
49 #include <OpenGl_Window.hxx>
50 #include <OpenGl_Workspace.hxx>
51 #include <OpenGl_TileSampler.hxx>
58 class Graphic3d_StructureManager;
59 class OpenGl_GraphicDriver;
60 class OpenGl_StateCounter;
61 class OpenGl_RaytraceMaterial;
62 class OpenGl_TriangleSet;
63 class OpenGl_Workspace;
65 DEFINE_STANDARD_HANDLE(OpenGl_View,Graphic3d_CView)
67 //! Implementation of OpenGl view.
68 class OpenGl_View : public Graphic3d_CView
74 Standard_EXPORT OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
75 const Handle(OpenGl_GraphicDriver)& theDriver,
76 const Handle(OpenGl_Caps)& theCaps,
77 Standard_Boolean& theDeviceLostFlag,
78 OpenGl_StateCounter* theCounter);
80 //! Default destructor.
81 Standard_EXPORT virtual ~OpenGl_View();
83 Standard_EXPORT void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
85 //! Deletes and erases the view.
86 Standard_EXPORT virtual void Remove() Standard_OVERRIDE;
88 //! @param theDrawToFrontBuffer Advanced option to modify rendering mode:
89 //! 1. TRUE. Drawing immediate mode structures directly to the front buffer over the scene image.
90 //! Fast, so preferred for interactive work (used by default).
91 //! However these extra drawings will be missed in image dump since it is performed from back buffer.
92 //! Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen
93 //! in run-time (in case of slow hardware) and/or tearing may appear.
94 //! So this is strongly recommended to draw only simple (fast) structures.
95 //! 2. FALSE. Drawing immediate mode structures to the back buffer.
96 //! The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync
97 //! is turned on. But it works in any case and is especially useful for view dump because the dump image is read
98 //! from the back buffer.
99 //! @return previous mode.
100 Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) Standard_OVERRIDE;
102 //! Creates and maps rendering window to the view.
103 //! @param theWindow [in] the window.
104 //! @param theContext [in] the rendering context. If NULL the context will be created internally.
105 Standard_EXPORT virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
106 const Aspect_RenderingContext theContext) Standard_OVERRIDE;
108 //! Returns window associated with the view.
109 virtual Handle(Aspect_Window) Window() const Standard_OVERRIDE
110 { return myWindow->PlatformWindow(); }
112 //! Returns True if the window associated to the view is defined.
113 virtual Standard_Boolean IsDefined() const Standard_OVERRIDE
114 { return !myWindow.IsNull(); }
116 //! Handle changing size of the rendering window.
117 Standard_EXPORT virtual void Resized() Standard_OVERRIDE;
119 //! Redraw content of the view.
120 Standard_EXPORT virtual void Redraw() Standard_OVERRIDE;
122 //! Redraw immediate content of the view.
123 Standard_EXPORT virtual void RedrawImmediate() Standard_OVERRIDE;
125 //! Marks BVH tree for given priority list as dirty and marks primitive set for rebuild.
126 Standard_EXPORT virtual void Invalidate() Standard_OVERRIDE;
128 //! Return true if view content cache has been invalidated.
129 virtual Standard_Boolean IsInvalidated() Standard_OVERRIDE { return !myBackBufferRestored; }
131 //! Returns data of a graduated trihedron
132 const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() Standard_OVERRIDE
133 { return myGTrihedronData; }
135 //! Displays Graduated Trihedron.
136 Standard_EXPORT virtual void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) Standard_OVERRIDE;
138 //! Erases Graduated Trihedron.
139 Standard_EXPORT virtual void GraduatedTrihedronErase() Standard_OVERRIDE;
141 //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object.
142 //! @param theMin [in] the minimum point of scene.
143 //! @param theMax [in] the maximum point of scene.
144 Standard_EXPORT virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax) Standard_OVERRIDE;
146 //! Dump active rendering buffer into specified memory buffer.
147 //! In Ray-Tracing allow to get a raw HDR buffer using Graphic3d_BT_RGB_RayTraceHdrLeft buffer type,
148 //! only Left view will be dumped ignoring stereoscopic parameter.
149 Standard_EXPORT virtual Standard_Boolean BufferDump (Image_PixMap& theImage,
150 const Graphic3d_BufferType& theBufferType) Standard_OVERRIDE;
152 //! Export scene into the one of the Vector graphics formats (SVG, PS, PDF...).
153 //! In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits
154 //! on printing to laser printer). Notice however that results may differ a lot and
155 //! do not contain some elements.
156 Standard_EXPORT virtual Standard_Boolean Export (const Standard_CString theFileName,
157 const Graphic3d_ExportFormat theFormat,
158 const Graphic3d_SortType theSortType = Graphic3d_ST_BSP_Tree) Standard_OVERRIDE;
160 //! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
161 Standard_EXPORT virtual void InvalidateBVHData (const Standard_Integer theLayerId) Standard_OVERRIDE;
163 //! Insert a new top-level z layer with the given ID.
164 Standard_EXPORT virtual void AddZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
166 //! Remove a z layer with the given ID.
167 Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
169 //! Sets the settings for a single Z layer of specified view.
170 Standard_EXPORT virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
171 const Graphic3d_ZLayerSettings& theSettings) Standard_OVERRIDE;
173 //! Returns the maximum Z layer ID.
174 //! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
175 Standard_EXPORT virtual Standard_Integer ZLayerMax() const Standard_OVERRIDE;
177 //! Returns the bounding box of all structures displayed in the Z layer.
178 //! Never fails. If Z layer does not exist nothing happens.
179 Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const Standard_OVERRIDE;
181 //! Returns the bounding box of all structures displayed in the Z layer.
182 //! If Z layer does not exist the empty box is returned.
183 //! @param theLayerId layer identifier
184 //! @param theCamera camera definition
185 //! @param theWindowWidth viewport width (for applying transformation-persistence)
186 //! @param theWindowHeight viewport height (for applying transformation-persistence)
187 //! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
188 //! @return computed bounding box
189 Standard_EXPORT virtual Bnd_Box ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
190 const Handle(Graphic3d_Camera)& theCamera,
191 const Standard_Integer theWindowWidth,
192 const Standard_Integer theWindowHeight,
193 const Standard_Boolean theToIncludeAuxiliary) const Standard_OVERRIDE;
195 //! Returns pointer to an assigned framebuffer object.
196 Standard_EXPORT virtual Handle(Standard_Transient) FBO() const Standard_OVERRIDE;
198 //! Sets framebuffer object for offscreen rendering.
199 Standard_EXPORT virtual void SetFBO (const Handle(Standard_Transient)& theFbo) Standard_OVERRIDE;
201 //! Generate offscreen FBO in the graphic library.
202 //! If not supported on hardware returns NULL.
203 Standard_EXPORT virtual Handle(Standard_Transient) FBOCreate (const Standard_Integer theWidth,
204 const Standard_Integer theHeight) Standard_OVERRIDE;
206 //! Remove offscreen FBO from the graphic library
207 Standard_EXPORT virtual void FBORelease (Handle(Standard_Transient)& theFbo) Standard_OVERRIDE;
209 //! Read offscreen FBO configuration.
210 Standard_EXPORT virtual void FBOGetDimensions (const Handle(Standard_Transient)& theFbo,
211 Standard_Integer& theWidth,
212 Standard_Integer& theHeight,
213 Standard_Integer& theWidthMax,
214 Standard_Integer& theHeightMax) Standard_OVERRIDE;
216 //! Change offscreen FBO viewport.
217 Standard_EXPORT virtual void FBOChangeViewport (const Handle(Standard_Transient)& theFbo,
218 const Standard_Integer theWidth,
219 const Standard_Integer theHeight) Standard_OVERRIDE;
223 //! Returns background fill color.
224 Standard_EXPORT virtual Aspect_Background Background() const Standard_OVERRIDE;
226 //! Sets background fill color.
227 Standard_EXPORT virtual void SetBackground (const Aspect_Background& theBackground) Standard_OVERRIDE;
229 //! Returns gradient background fill colors.
230 Standard_EXPORT virtual Aspect_GradientBackground GradientBackground() const Standard_OVERRIDE;
232 //! Sets gradient background fill colors.
233 Standard_EXPORT virtual void SetGradientBackground (const Aspect_GradientBackground& theBackground) Standard_OVERRIDE;
235 //! Returns background image texture file path.
236 Standard_EXPORT virtual TCollection_AsciiString BackgroundImage() Standard_OVERRIDE { return myBackgroundImagePath; }
238 //! Sets background image texture file path.
239 Standard_EXPORT virtual void SetBackgroundImage (const TCollection_AsciiString& theFilePath) Standard_OVERRIDE;
241 //! Returns background image fill style.
242 Standard_EXPORT virtual Aspect_FillMethod BackgroundImageStyle() const Standard_OVERRIDE;
244 //! Sets background image fill style.
245 Standard_EXPORT virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) Standard_OVERRIDE;
247 //! Returns environment texture set for the view.
248 Standard_EXPORT virtual Handle(Graphic3d_TextureEnv) TextureEnv() const Standard_OVERRIDE { return myTextureEnvData; }
250 //! Sets environment texture for the view.
251 Standard_EXPORT virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) Standard_OVERRIDE;
253 //! Returns the state of frustum culling optimization.
254 virtual Standard_Boolean IsCullingEnabled() const Standard_OVERRIDE { return myCulling; }
256 //! Enables or disables frustum culling optimization.
257 virtual void SetCullingEnabled (const Standard_Boolean theIsEnabled) Standard_OVERRIDE { myCulling = theIsEnabled; }
259 //! Returns shading model of the view.
260 virtual Graphic3d_TypeOfShadingModel ShadingModel() const Standard_OVERRIDE { return myShadingModel; }
262 //! Sets shading model of the view.
263 virtual void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel) Standard_OVERRIDE { myShadingModel = theModel; }
265 //! Return backfacing model used for the view.
266 virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const Standard_OVERRIDE { return myBackfacing; }
268 //! Sets backfacing model for the view.
269 virtual void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) Standard_OVERRIDE { myBackfacing = theModel; }
271 //! Returns camera object of the view.
272 virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; }
274 //! Returns local camera origin currently set for rendering, might be modified during rendering.
275 const gp_XYZ& LocalOrigin() const { return myLocalOrigin; }
277 //! Setup local camera origin currently set for rendering.
278 Standard_EXPORT void SetLocalOrigin (const gp_XYZ& theOrigin);
280 //! Sets camera used by the view.
281 Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE;
283 //! Returns list of lights of the view.
284 virtual const Graphic3d_ListOfCLight& Lights() const Standard_OVERRIDE { return myLights; }
286 //! Sets list of lights for the view.
287 virtual void SetLights (const Graphic3d_ListOfCLight& theLights) Standard_OVERRIDE
289 myLights = theLights;
290 myCurrLightSourceState = myStateCounter->Increment();
293 //! Returns list of clip planes set for the view.
294 virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const Standard_OVERRIDE { return myClipPlanes; }
296 //! Sets list of clip planes for the view.
297 virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) Standard_OVERRIDE { myClipPlanes = thePlanes; }
299 //! Fill in the dictionary with diagnostic info.
300 //! Should be called within rendering thread.
302 //! This API should be used only for user output or for creating automated reports.
303 //! The format of returned information (e.g. key-value layout)
304 //! is NOT part of this API and can be changed at any time.
305 //! Thus application should not parse returned information to weed out specific parameters.
306 Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
307 Graphic3d_DiagnosticInfo theFlags) const Standard_OVERRIDE;
311 //! Returns background color.
312 const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; }
314 //! Change graduated trihedron.
315 OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
317 void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
318 const Handle(Graphic3d_TextureEnv)& theTexture);
320 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
322 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
324 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
326 //! Returns list of OpenGL Z-layers.
327 const OpenGl_LayerList& LayerList() const { return myZLayers; }
329 //! Returns list of openGL light sources.
330 const OpenGl_ListOfLight& LightList() const { return myLights; }
332 //! Returns OpenGL window implementation.
333 const Handle(OpenGl_Window) GlWindow() const { return myWindow; }
335 //! Returns OpenGL environment map.
336 const Handle(OpenGl_Texture)& GlTextureEnv() const { return myTextureEnv; }
338 //! Returns selector for BVH tree, providing a possibility to store information
339 //! about current view volume and to detect which objects are overlapping it.
340 OpenGl_BVHTreeSelector& BVHTreeSelector() { return myBVHSelector; }
342 //! Returns true if there are immediate structures to display
343 bool HasImmediateStructures() const
345 return myZLayers.NbImmediateStructures() != 0;
348 protected: //! @name Internal methods for managing GL resources
350 //! Initializes OpenGl resource for environment texture.
351 void initTextureEnv (const Handle(OpenGl_Context)& theContext);
353 protected: //! @name low-level redrawing sub-routines
355 //! Redraws view for the given monographic camera projection, or left/right eye.
356 Standard_EXPORT virtual void redraw (const Graphic3d_Camera::Projection theProjection,
357 OpenGl_FrameBuffer* theReadDrawFbo,
358 OpenGl_FrameBuffer* theOitAccumFbo);
360 //! Redraws view for the given monographic camera projection, or left/right eye.
362 //! Method will blit snapshot containing main scene (myMainSceneFbos or BackBuffer)
363 //! into presentation buffer (myMainSceneFbos -> offscreen FBO or
364 //! myMainSceneFbos -> BackBuffer or BackBuffer -> FrontBuffer),
365 //! and redraw immediate structures on top.
367 //! When scene caching is disabled (myTransientDrawToFront, no double buffer in window, etc.),
368 //! the first step (blitting) will be skipped.
370 //! @return false if immediate structures has been rendered directly into FrontBuffer
371 //! and Buffer Swap should not be called.
372 Standard_EXPORT virtual bool redrawImmediate (const Graphic3d_Camera::Projection theProjection,
373 OpenGl_FrameBuffer* theReadFbo,
374 OpenGl_FrameBuffer* theDrawFbo,
375 OpenGl_FrameBuffer* theOitAccumFbo,
376 const Standard_Boolean theIsPartialUpdate = Standard_False);
378 //! Blit image from/to specified buffers.
379 Standard_EXPORT bool blitBuffers (OpenGl_FrameBuffer* theReadFbo,
380 OpenGl_FrameBuffer* theDrawFbo,
381 const Standard_Boolean theToFlip = Standard_False);
383 //! Setup default FBO.
384 Standard_EXPORT void bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo = NULL);
386 protected: //! @name Rendering of GL graphics (with prepared drawing buffer).
388 //! Renders the graphical contents of the view into the preprepared window or framebuffer.
389 //! @param theProjection [in] the projection that should be used for rendering.
390 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
391 //! @param theOitAccumFbo [in] the framebuffer for accumulating color and coverage for OIT process.
392 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
393 Standard_EXPORT virtual void render (Graphic3d_Camera::Projection theProjection,
394 OpenGl_FrameBuffer* theReadDrawFbo,
395 OpenGl_FrameBuffer* theOitAccumFbo,
396 const Standard_Boolean theToDrawImmediate);
398 //! Renders the graphical scene.
399 //! @param theProjection [in] the projection that is used for rendering.
400 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
401 //! @param theOitAccumFbo [in] the framebuffer for accumulating color and coverage for OIT process.
402 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
403 Standard_EXPORT virtual void renderScene (Graphic3d_Camera::Projection theProjection,
404 OpenGl_FrameBuffer* theReadDrawFbo,
405 OpenGl_FrameBuffer* theOitAccumFbo,
406 const Standard_Boolean theToDrawImmediate);
408 //! Draw background (gradient / image)
409 Standard_EXPORT virtual void drawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
411 //! Render set of structures presented in the view.
412 //! @param theProjection [in] the projection that is used for rendering.
413 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
414 //! @param theOitAccumFbo [in] the framebuffer for accumulating color and coverage for OIT process.
415 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
416 Standard_EXPORT virtual void renderStructs (Graphic3d_Camera::Projection theProjection,
417 OpenGl_FrameBuffer* theReadDrawFbo,
418 OpenGl_FrameBuffer* theOitAccumFbo,
419 const Standard_Boolean theToDrawImmediate);
421 //! Renders trihedron.
422 void renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace);
426 //! Adds the structure to display lists of the view.
427 Standard_EXPORT virtual void displayStructure (const Handle(Graphic3d_CStructure)& theStructure,
428 const Standard_Integer thePriority) Standard_OVERRIDE;
430 //! Erases the structure from display lists of the view.
431 Standard_EXPORT virtual void eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) Standard_OVERRIDE;
433 //! Change Z layer of a structure already presented in view.
434 Standard_EXPORT virtual void changeZLayer (const Handle(Graphic3d_CStructure)& theCStructure,
435 const Graphic3d_ZLayerId theNewLayerId) Standard_OVERRIDE;
437 //! Changes the priority of a structure within its Z layer in the specified view.
438 Standard_EXPORT virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
439 const Standard_Integer theNewPriority) Standard_OVERRIDE;
441 //! Returns zoom-scale factor.
442 Standard_EXPORT virtual Standard_Real considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
443 const Handle(Graphic3d_Camera)& theCamera,
444 const Standard_Integer theWindowWidth,
445 const Standard_Integer theWindowHeight) const Standard_OVERRIDE;
449 //! Copy content of Back buffer to the Front buffer.
450 bool copyBackToFront();
452 //! Initialize blit quad.
453 OpenGl_VertexBuffer* initBlitQuad (const Standard_Boolean theToFlip);
455 //! Blend together views pair into stereo image.
456 void drawStereoPair (OpenGl_FrameBuffer* theDrawFbo);
458 //! Check and update OIT compatibility with current OpenGL context's state.
459 bool checkOitCompatibility (const Handle(OpenGl_Context)& theGlContext,
460 const Standard_Boolean theMSAA);
462 //! Chooses compatible internal color format for OIT frame buffer.
463 bool chooseOitColorConfiguration (const Handle(OpenGl_Context)& theGlContext,
464 const Standard_Integer theConfigIndex,
465 OpenGl_ColorFormats& theFormats);
469 OpenGl_GraphicDriver* myDriver;
470 Handle(OpenGl_Window) myWindow;
471 Handle(OpenGl_Workspace) myWorkspace;
472 Handle(OpenGl_Caps) myCaps;
473 Standard_Boolean& myDeviceLostFlag;
474 Standard_Boolean myWasRedrawnGL;
476 Standard_Boolean myCulling;
477 Graphic3d_TypeOfShadingModel myShadingModel;
478 Graphic3d_TypeOfBackfacingModel myBackfacing;
479 Quantity_ColorRGBA myBgColor;
480 Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
481 Handle(Graphic3d_Camera) myCamera;
482 gp_XYZ myLocalOrigin;
483 Handle(OpenGl_FrameBuffer) myFBO;
484 Standard_Boolean myToShowGradTrihedron;
485 TCollection_AsciiString myBackgroundImagePath;
486 Handle(Graphic3d_TextureEnv) myTextureEnvData;
487 Graphic3d_GraduatedTrihedron myGTrihedronData;
489 OpenGl_ListOfLight myNoShadingLight;
490 OpenGl_ListOfLight myLights;
491 OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers
493 Graphic3d_WorldViewProjState myWorldViewProjState; //!< camera modification state
494 OpenGl_StateCounter* myStateCounter;
495 Standard_Size myCurrLightSourceState;
497 typedef std::pair<Standard_Size, Standard_Size> StateInfo;
499 StateInfo myLastOrientationState;
500 StateInfo myLastViewMappingState;
501 StateInfo myLastLightSourceState;
503 //! Is needed for selection of overlapping objects and storage of the current view volume
504 OpenGl_BVHTreeSelector myBVHSelector;
506 OpenGl_GraduatedTrihedron myGraduatedTrihedron;
508 Handle(OpenGl_Texture) myTextureEnv;
510 //! Framebuffers for OpenGL output.
511 Handle(OpenGl_FrameBuffer) myOpenGlFBO;
512 Handle(OpenGl_FrameBuffer) myOpenGlFBO2;
514 protected: //! @name Rendering properties
516 //! Two framebuffers (left and right views) store cached main presentation
517 //! of the view (without presentation of immediate layers).
518 GLint myFboColorFormat; //!< sized format for color attachments
519 GLint myFboDepthFormat; //!< sized format for depth-stencil attachments
520 OpenGl_ColorFormats myFboOitColorConfig; //!< selected color format configuration for OIT color attachments
521 Handle(OpenGl_FrameBuffer) myMainSceneFbos[2];
522 Handle(OpenGl_FrameBuffer) myMainSceneFbosOit[2]; //!< Additional buffers for transparent draw of main layer.
523 Handle(OpenGl_FrameBuffer) myImmediateSceneFbos[2]; //!< Additional buffers for immediate layer in stereo mode.
524 Handle(OpenGl_FrameBuffer) myImmediateSceneFbosOit[2]; //!< Additional buffers for transparency draw of immediate layer.
525 OpenGl_VertexBuffer myFullScreenQuad; //!< Vertices for full-screen quad rendering.
526 OpenGl_VertexBuffer myFullScreenQuadFlip;
527 Standard_Boolean myToFlipOutput; //!< Flag to draw result image upside-down
528 unsigned int myFrameCounter; //!< redraw counter, for debugging
529 Standard_Boolean myHasFboBlit; //!< disable FBOs on failure
530 Standard_Boolean myToDisableOIT; //!< disable OIT on failure
531 Standard_Boolean myToDisableOITMSAA; //!< disable OIT with MSAA on failure
532 Standard_Boolean myToDisableMSAA; //!< disable MSAA after failure
533 Standard_Boolean myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer)
534 Standard_Boolean myBackBufferRestored;
535 Standard_Boolean myIsImmediateDrawn; //!< flag indicates that immediate mode buffer contains some data
537 protected: //! @name Background parameters
539 OpenGl_AspectFace* myTextureParams; //!< Stores texture and its parameters for textured background
540 OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
541 OpenGl_BackgroundArray* myBgTextureArray; //!< Primitive array for texture background
543 protected: //! @name data types related to ray-tracing
545 //! Result of OpenGL shaders initialization.
546 enum RaytraceInitStatus
553 //! Describes update mode (state).
554 enum RaytraceUpdateMode
556 OpenGl_GUM_CHECK, //!< check geometry state
557 OpenGl_GUM_PREPARE, //!< collect unchanged objects
558 OpenGl_GUM_REBUILD //!< rebuild changed and new objects
561 //! Defines frequently used shader variables.
562 enum ShaderVariableIndex
575 OpenGl_RT_uViewPrMat,
576 OpenGl_RT_uUnviewMat,
581 OpenGl_RT_uLightAmbnt,
582 OpenGl_RT_uLightCount,
585 OpenGl_RT_uBackColorTop,
586 OpenGl_RT_uBackColorBot,
588 // ray-tracing params
589 OpenGl_RT_uShadowsEnabled,
590 OpenGl_RT_uReflectEnabled,
591 OpenGl_RT_uSphereMapEnabled,
592 OpenGl_RT_uSphereMapForBack,
593 OpenGl_RT_uTexSamplersArray,
594 OpenGl_RT_uBlockedRngEnabled,
596 // size of render window
600 // sampled frame params
601 OpenGl_RT_uAccumSamples,
602 OpenGl_RT_uFrameRndSeed,
604 // adaptive FSAA params
609 // images used by ISS mode
610 OpenGl_RT_uRenderImage,
611 OpenGl_RT_uOffsetImage,
613 // maximum radiance value
614 OpenGl_RT_uMaxRadiance,
616 OpenGl_RT_NbVariables // special field
619 //! Defines OpenGL texture samplers.
620 enum ShaderSamplerNames
622 OpenGl_RT_EnvironmentMapTexture = 0,
624 OpenGl_RT_SceneNodeInfoTexture = 1,
625 OpenGl_RT_SceneMinPointTexture = 2,
626 OpenGl_RT_SceneMaxPointTexture = 3,
627 OpenGl_RT_SceneTransformTexture = 4,
629 OpenGl_RT_GeometryVertexTexture = 5,
630 OpenGl_RT_GeometryNormalTexture = 6,
631 OpenGl_RT_GeometryTexCrdTexture = 7,
632 OpenGl_RT_GeometryTriangTexture = 8,
634 OpenGl_RT_RaytraceMaterialTexture = 9,
635 OpenGl_RT_RaytraceLightSrcTexture = 10,
637 OpenGl_RT_FsaaInputTexture = 11,
638 OpenGl_RT_PrevAccumTexture = 12,
640 OpenGl_RT_RaytraceDepthTexture = 13
643 //! Defines OpenGL image samplers.
644 enum ShaderImageNames
646 OpenGl_RT_OutputImageLft = 0,
647 OpenGl_RT_OutputImageRgh = 1,
648 OpenGl_RT_VisualErrorImageLft = 2,
649 OpenGl_RT_VisualErrorImageRgh = 3,
650 OpenGl_RT_TileOffsetsImageLft = 4,
651 OpenGl_RT_TileOffsetsImageRgh = 5
654 //! Tool class for management of shader sources.
659 //! Default shader prefix - empty string.
660 static const TCollection_AsciiString EMPTY_PREFIX;
662 //! Creates new uninitialized shader source.
670 //! Returns error description in case of load fail.
671 const TCollection_AsciiString& ErrorDescription() const
676 //! Returns prefix to insert before the source.
677 const TCollection_AsciiString& Prefix() const
682 //! Sets prefix to insert before the source.
683 void SetPrefix (const TCollection_AsciiString& thePrefix)
685 myPrefix = thePrefix;
688 //! Returns shader source combined with prefix.
689 TCollection_AsciiString Source() const;
691 //! Loads shader source from specified files.
692 Standard_Boolean LoadFromFiles (const TCollection_AsciiString* theFileNames, const TCollection_AsciiString& thePrefix = EMPTY_PREFIX);
694 //! Loads shader source from specified strings.
695 Standard_Boolean LoadFromStrings (const TCollection_AsciiString* theStrings, const TCollection_AsciiString& thePrefix = EMPTY_PREFIX);
699 TCollection_AsciiString mySource; //!< Source string of the shader object
700 TCollection_AsciiString myPrefix; //!< Prefix to insert before the source
701 TCollection_AsciiString myError; //!< error state
705 //! Default ray-tracing depth.
706 static const Standard_Integer THE_DEFAULT_NB_BOUNCES = 3;
708 //! Default size of traversal stack.
709 static const Standard_Integer THE_DEFAULT_STACK_SIZE = 10;
711 //! Compile-time ray-tracing parameters.
712 struct RaytracingParams
714 //! Actual size of traversal stack in shader program.
715 Standard_Integer StackSize;
717 //! Actual ray-tracing depth (number of ray bounces).
718 Standard_Integer NbBounces;
720 //! Enables/disables light propagation through transparent media.
721 Standard_Boolean TransparentShadows;
723 //! Enables/disables global illumination (GI) effects.
724 Standard_Boolean GlobalIllumination;
726 //! Enables/disables the use of OpenGL bindless textures.
727 Standard_Boolean UseBindlessTextures;
729 //! Enables/disables two-sided BSDF models instead of one-sided.
730 Standard_Boolean TwoSidedBsdfModels;
732 //! Enables/disables adaptive screen sampling for path tracing.
733 Standard_Boolean AdaptiveScreenSampling;
735 //! Enables/disables environment map for background.
736 Standard_Boolean UseEnvMapForBackground;
738 //! Maximum radiance value used for clamping radiance estimation.
739 Standard_ShortReal RadianceClampingValue;
741 //! Number of tiles in X dimension (in adaptive sampling mode).
742 Standard_Integer NbTilesX;
744 //! Number of tiles in Y dimension (in adaptive sampling mode).
745 Standard_Integer NbTilesY;
747 //! Enables/disables depth-of-field effect (path tracing, perspective camera).
748 Standard_Boolean DepthOfField;
750 //! Tone mapping method for path tracing.
751 Graphic3d_ToneMappingMethod ToneMappingMethod;
753 //! Creates default compile-time ray-tracing parameters.
755 : StackSize (THE_DEFAULT_STACK_SIZE),
756 NbBounces (THE_DEFAULT_NB_BOUNCES),
757 TransparentShadows (Standard_False),
758 GlobalIllumination (Standard_False),
759 UseBindlessTextures (Standard_False),
760 TwoSidedBsdfModels (Standard_False),
761 AdaptiveScreenSampling (Standard_False),
762 UseEnvMapForBackground (Standard_False),
763 RadianceClampingValue (30.0),
766 DepthOfField (Standard_False),
767 ToneMappingMethod (Graphic3d_ToneMappingMethod_Disabled) { }
770 //! Describes state of OpenGL structure.
773 Standard_Size StructureState;
774 Standard_Size InstancedState;
776 //! Creates new structure state.
777 StructState (const Standard_Size theStructureState = 0,
778 const Standard_Size theInstancedState = 0)
779 : StructureState (theStructureState),
780 InstancedState (theInstancedState)
785 //! Creates new structure state.
786 StructState (const OpenGl_Structure* theStructure)
788 StructureState = theStructure->ModificationState();
790 InstancedState = theStructure->InstancedStructure() != NULL ?
791 theStructure->InstancedStructure()->ModificationState() : 0;
795 protected: //! @name methods related to ray-tracing
797 //! Updates 3D scene geometry for ray-tracing.
798 Standard_Boolean updateRaytraceGeometry (const RaytraceUpdateMode theMode,
799 const Standard_Integer theViewId,
800 const Handle(OpenGl_Context)& theGlContext);
802 //! Updates 3D scene light sources for ray-tracing.
803 Standard_Boolean updateRaytraceLightSources (const OpenGl_Mat4& theInvModelView, const Handle(OpenGl_Context)& theGlContext);
805 //! Checks to see if the OpenGL structure is modified.
806 Standard_Boolean toUpdateStructure (const OpenGl_Structure* theStructure);
808 //! Adds OpenGL structure to ray-traced scene geometry.
809 Standard_Boolean addRaytraceStructure (const OpenGl_Structure* theStructure,
810 const Handle(OpenGl_Context)& theGlContext);
812 //! Adds OpenGL groups to ray-traced scene geometry.
813 Standard_Boolean addRaytraceGroups (const OpenGl_Structure* theStructure,
814 const OpenGl_RaytraceMaterial& theStructMat,
815 const Handle(Geom_Transformation)& theTrsf,
816 const Handle(OpenGl_Context)& theGlContext);
818 //! Creates ray-tracing material properties.
819 OpenGl_RaytraceMaterial convertMaterial (const OpenGl_AspectFace* theAspect,
820 const Handle(OpenGl_Context)& theGlContext);
822 //! Adds OpenGL primitive array to ray-traced scene geometry.
823 Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
824 const Standard_Integer theMatID,
825 const OpenGl_Mat4* theTrans);
827 //! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
828 Standard_Boolean addRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
829 const Standard_Integer theMatID,
830 const Standard_Integer theCount,
831 const Standard_Integer theOffset,
832 const OpenGl_PrimitiveArray& theArray);
834 //! Adds OpenGL triangle array to ray-traced scene geometry.
835 Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
836 const Standard_Integer theMatID,
837 const Standard_Integer theCount,
838 const Standard_Integer theOffset,
839 const Handle(Graphic3d_IndexBuffer)& theIndices);
841 //! Adds OpenGL triangle fan array to ray-traced scene geometry.
842 Standard_Boolean addRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
843 const Standard_Integer theMatID,
844 const Standard_Integer theCount,
845 const Standard_Integer theOffset,
846 const Handle(Graphic3d_IndexBuffer)& theIndices);
848 //! Adds OpenGL triangle strip array to ray-traced scene geometry.
849 Standard_Boolean addRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
850 const Standard_Integer theMatID,
851 const Standard_Integer theCount,
852 const Standard_Integer theOffset,
853 const Handle(Graphic3d_IndexBuffer)& theIndices);
855 //! Adds OpenGL quadrangle array to ray-traced scene geometry.
856 Standard_Boolean addRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
857 const Standard_Integer theMatID,
858 const Standard_Integer theCount,
859 const Standard_Integer theOffset,
860 const Handle(Graphic3d_IndexBuffer)& theIndices);
862 //! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
863 Standard_Boolean addRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
864 const Standard_Integer theMatID,
865 const Standard_Integer theCount,
866 const Standard_Integer theOffset,
867 const Handle(Graphic3d_IndexBuffer)& theIndices);
869 //! Adds OpenGL polygon array to ray-traced scene geometry.
870 Standard_Boolean addRaytracePolygonArray (OpenGl_TriangleSet& theSet,
871 const Standard_Integer theMatID,
872 const Standard_Integer theCount,
873 const Standard_Integer theOffset,
874 const Handle(Graphic3d_IndexBuffer)& theIndices);
876 //! Uploads ray-trace data to the GPU.
877 Standard_Boolean uploadRaytraceData (const Handle(OpenGl_Context)& theGlContext);
879 //! Generates shader prefix based on current ray-tracing options.
880 TCollection_AsciiString generateShaderPrefix (const Handle(OpenGl_Context)& theGlContext) const;
882 //! Performs safe exit when shaders initialization fails.
883 Standard_Boolean safeFailBack (const TCollection_ExtendedString& theMessage,
884 const Handle(OpenGl_Context)& theGlContext);
886 //! Loads and compiles shader object from specified source.
887 Handle(OpenGl_ShaderObject) initShader (const GLenum theType,
888 const ShaderSource& theSource,
889 const Handle(OpenGl_Context)& theGlContext);
891 //! Creates shader program from the given vertex and fragment shaders.
892 Handle(OpenGl_ShaderProgram) initProgram (const Handle(OpenGl_Context)& theGlContext,
893 const Handle(OpenGl_ShaderObject)& theVertShader,
894 const Handle(OpenGl_ShaderObject)& theFragShader);
896 //! Initializes OpenGL/GLSL shader programs.
897 Standard_Boolean initRaytraceResources (const Handle(OpenGl_Context)& theGlContext);
899 //! Releases OpenGL/GLSL shader programs.
900 void releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext,
901 const Standard_Boolean theToRebuild = Standard_False);
903 //! Updates auxiliary OpenGL frame buffers.
904 Standard_Boolean updateRaytraceBuffers (const Standard_Integer theSizeX,
905 const Standard_Integer theSizeY,
906 const Handle(OpenGl_Context)& theGlContext);
908 //! Generates viewing rays for corners of screen quad.
909 //! (ray tracing; path tracing for orthographic camera)
910 void updateCamera (const OpenGl_Mat4& theOrientation,
911 const OpenGl_Mat4& theViewMapping,
912 OpenGl_Vec3* theOrigins,
913 OpenGl_Vec3* theDirects,
914 OpenGl_Mat4& theView,
915 OpenGl_Mat4& theUnView);
917 //! Generate viewing rays (path tracing, perspective camera).
918 void updatePerspCameraPT(const OpenGl_Mat4& theOrientation,
919 const OpenGl_Mat4& theViewMapping,
920 Graphic3d_Camera::Projection theProjection,
921 OpenGl_Mat4& theViewPr,
922 OpenGl_Mat4& theUnview,
923 const int theWinSizeX,
924 const int theWinSizeY);
926 //! Binds ray-trace textures to corresponding texture units.
927 void bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
929 //! Unbinds ray-trace textures from corresponding texture unit.
930 void unbindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
932 //! Sets uniform state for the given ray-tracing shader program.
933 Standard_Boolean setUniformState (const Standard_Integer theProgramId,
934 const Standard_Integer theSizeX,
935 const Standard_Integer theSizeY,
936 Graphic3d_Camera::Projection theProjection,
937 const Handle(OpenGl_Context)& theGlContext);
939 //! Runs ray-tracing shader programs.
940 Standard_Boolean runRaytraceShaders (const Standard_Integer theSizeX,
941 const Standard_Integer theSizeY,
942 Graphic3d_Camera::Projection theProjection,
943 OpenGl_FrameBuffer* theReadDrawFbo,
944 const Handle(OpenGl_Context)& theGlContext);
946 //! Runs classical (Whitted-style) ray-tracing kernel.
947 Standard_Boolean runRaytrace (const Standard_Integer theSizeX,
948 const Standard_Integer theSizeY,
949 Graphic3d_Camera::Projection theProjection,
950 OpenGl_FrameBuffer* theReadDrawFbo,
951 const Handle(OpenGl_Context)& theGlContext);
953 //! Runs path tracing (global illumination) kernel.
954 Standard_Boolean runPathtrace (const Standard_Integer theSizeX,
955 const Standard_Integer theSizeY,
956 Graphic3d_Camera::Projection theProjection,
957 OpenGl_FrameBuffer* theReadDrawFbo,
958 const Handle(OpenGl_Context)& theGlContext);
960 //! Redraws the window using OpenGL/GLSL ray-tracing or path tracing.
961 Standard_Boolean raytrace (const Standard_Integer theSizeX,
962 const Standard_Integer theSizeY,
963 Graphic3d_Camera::Projection theProjection,
964 OpenGl_FrameBuffer* theReadDrawFbo,
965 const Handle(OpenGl_Context)& theGlContext);
967 protected: //! @name fields related to ray-tracing
969 //! Result of RT/PT shaders initialization.
970 RaytraceInitStatus myRaytraceInitStatus;
972 //! Is ray-tracing geometry data valid?
973 Standard_Boolean myIsRaytraceDataValid;
975 //! True if warning about missing extension GL_ARB_bindless_texture has been displayed.
976 Standard_Boolean myIsRaytraceWarnTextures;
978 //! 3D scene geometry data for ray-tracing.
979 OpenGl_RaytraceGeometry myRaytraceGeometry;
981 //! Builder for triangle set.
982 opencascade::handle<BVH_Builder<Standard_ShortReal, 3> > myRaytraceBVHBuilder;
984 //! Compile-time ray-tracing parameters.
985 RaytracingParams myRaytraceParameters;
987 //! Radius of bounding sphere of the scene.
988 Standard_ShortReal myRaytraceSceneRadius;
989 //! Scene epsilon to prevent self-intersections.
990 Standard_ShortReal myRaytraceSceneEpsilon;
992 //! OpenGL/GLSL source of ray-tracing fragment shader.
993 ShaderSource myRaytraceShaderSource;
994 //! OpenGL/GLSL source of adaptive-AA fragment shader.
995 ShaderSource myPostFSAAShaderSource;
996 //! OpenGL/GLSL source of RT/PT display fragment shader.
997 ShaderSource myOutImageShaderSource;
999 //! OpenGL/GLSL ray-tracing fragment shader.
1000 Handle(OpenGl_ShaderObject) myRaytraceShader;
1001 //! OpenGL/GLSL adaptive-AA fragment shader.
1002 Handle(OpenGl_ShaderObject) myPostFSAAShader;
1003 //! OpenGL/GLSL ray-tracing display fragment shader.
1004 Handle(OpenGl_ShaderObject) myOutImageShader;
1006 //! OpenGL/GLSL ray-tracing shader program.
1007 Handle(OpenGl_ShaderProgram) myRaytraceProgram;
1008 //! OpenGL/GLSL adaptive-AA shader program.
1009 Handle(OpenGl_ShaderProgram) myPostFSAAProgram;
1010 //! OpenGL/GLSL program for displaying texture.
1011 Handle(OpenGl_ShaderProgram) myOutImageProgram;
1013 //! Texture buffer of data records of bottom-level BVH nodes.
1014 Handle(OpenGl_TextureBufferArb) mySceneNodeInfoTexture;
1015 //! Texture buffer of minimum points of bottom-level BVH nodes.
1016 Handle(OpenGl_TextureBufferArb) mySceneMinPointTexture;
1017 //! Texture buffer of maximum points of bottom-level BVH nodes.
1018 Handle(OpenGl_TextureBufferArb) mySceneMaxPointTexture;
1019 //! Texture buffer of transformations of high-level BVH nodes.
1020 Handle(OpenGl_TextureBufferArb) mySceneTransformTexture;
1022 //! Texture buffer of vertex coords.
1023 Handle(OpenGl_TextureBufferArb) myGeometryVertexTexture;
1024 //! Texture buffer of vertex normals.
1025 Handle(OpenGl_TextureBufferArb) myGeometryNormalTexture;
1026 //! Texture buffer of vertex UV coords.
1027 Handle(OpenGl_TextureBufferArb) myGeometryTexCrdTexture;
1028 //! Texture buffer of triangle indices.
1029 Handle(OpenGl_TextureBufferArb) myGeometryTriangTexture;
1031 //! Texture buffer of material properties.
1032 Handle(OpenGl_TextureBufferArb) myRaytraceMaterialTexture;
1033 //! Texture buffer of light source properties.
1034 Handle(OpenGl_TextureBufferArb) myRaytraceLightSrcTexture;
1036 //! 1st framebuffer (FBO) to perform adaptive FSAA.
1037 //! Used in compatibility mode (no adaptive sampling).
1038 Handle(OpenGl_FrameBuffer) myRaytraceFBO1[2];
1039 //! 2nd framebuffer (FBO) to perform adaptive FSAA.
1040 //! Used in compatibility mode (no adaptive sampling).
1041 Handle(OpenGl_FrameBuffer) myRaytraceFBO2[2];
1043 //! Output textures (2 textures are used in stereo mode).
1044 //! Used if adaptive screen sampling is activated.
1045 Handle(OpenGl_Texture) myRaytraceOutputTexture[2];
1047 //! Texture containing per-tile visual error estimation (2 textures are used in stereo mode).
1048 //! Used if adaptive screen sampling is activated.
1049 Handle(OpenGl_Texture) myRaytraceVisualErrorTexture[2];
1050 //! Texture containing offsets of sampled screen tiles (2 textures are used in stereo mode).
1051 //! Used if adaptive screen sampling is activated.
1052 Handle(OpenGl_Texture) myRaytraceTileOffsetsTexture[2];
1054 //! Vertex buffer (VBO) for drawing dummy quad.
1055 OpenGl_VertexBuffer myRaytraceScreenQuad;
1057 //! Cached locations of frequently used uniform variables.
1058 Standard_Integer myUniformLocations[2][OpenGl_RT_NbVariables];
1060 //! State of OpenGL structures reflected to ray-tracing.
1061 std::map<const OpenGl_Structure*, StructState> myStructureStates;
1063 //! PrimitiveArray to TriangleSet map for scene partial update.
1064 std::map<Standard_Size, OpenGl_TriangleSet*> myArrayToTrianglesMap;
1066 //! Set of IDs of non-raytracable elements (to detect updates).
1067 std::set<Standard_Integer> myNonRaytraceStructureIDs;
1069 //! Render filter to filter out all raytracable structures.
1070 Handle(OpenGl_RaytraceFilter) myRaytraceFilter;
1072 //! Marks if environment map should be updated.
1073 Standard_Boolean myToUpdateEnvironmentMap;
1075 //! State of OpenGL layer list.
1076 Standard_Size myRaytraceLayerListState;
1078 //! Number of accumulated frames (for progressive rendering).
1079 Standard_Integer myAccumFrames;
1081 //! Stored ray origins used for detection of camera movements.
1082 OpenGl_Vec3 myPreviousOrigins[3];
1084 //! Bullard RNG to produce random sequence.
1085 math_BullardGenerator myRNG;
1087 //! Tool object for sampling screen tiles in PT mode.
1088 OpenGl_TileSampler myTileSampler;
1090 //! Camera position used for projective mode
1091 OpenGl_Vec3 myEyeOrig;
1093 //! Camera view direction used for projective mode
1094 OpenGl_Vec3 myEyeView;
1096 //! Camera's screen vertical direction used for projective mode
1097 OpenGl_Vec3 myEyeVert;
1099 //! Camera's screen horizontal direction used for projective mode
1100 OpenGl_Vec3 myEyeSide;
1102 //! Camera's screen size used for projective mode
1103 OpenGl_Vec2 myEyeSize;
1105 //! Aperture radius of camera on previous frame used for depth-of-field (path tracing)
1106 float myPrevCameraApertureRadius;
1108 //! Focal distance of camera on previous frame used for depth-of-field (path tracing)
1109 float myPrevCameraFocalPlaneDist;
1113 DEFINE_STANDARD_ALLOC
1114 DEFINE_STANDARD_RTTIEXT(OpenGl_View,Graphic3d_CView) // Type definition
1116 friend class OpenGl_GraphicDriver;
1117 friend class OpenGl_Workspace;
1118 friend class OpenGl_LayerList;
1121 #endif // _OpenGl_View_Header