Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:49

0001 // Created on: 2014-05-14
0002 // Created by: Denis BOGOLEPOV
0003 // Copyright (c) 2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _Graphic3d_RenderingParams_HeaderFile
0017 #define _Graphic3d_RenderingParams_HeaderFile
0018 
0019 #include <Font_Hinting.hxx>
0020 #include <Font_NameOfFont.hxx>
0021 #include <Graphic3d_AspectText3d.hxx>
0022 #include <Graphic3d_TransformPers.hxx>
0023 #include <Graphic3d_RenderTransparentMethod.hxx>
0024 #include <Graphic3d_RenderingMode.hxx>
0025 #include <Graphic3d_StereoMode.hxx>
0026 #include <Graphic3d_ToneMappingMethod.hxx>
0027 #include <Graphic3d_TypeOfShadingModel.hxx>
0028 #include <Graphic3d_Vec4.hxx>
0029 
0030 //! Helper class to store rendering parameters.
0031 class Graphic3d_RenderingParams
0032 {
0033 public:
0034   //! Default pixels density.
0035   static const unsigned int THE_DEFAULT_RESOLUTION = 72u;
0036 
0037   //! Default ray-tracing depth.
0038   static const Standard_Integer THE_DEFAULT_DEPTH = 3;
0039 
0040   //! Anaglyph filter presets.
0041   enum Anaglyph
0042   {
0043     Anaglyph_RedCyan_Simple,       //!< simple    filter for Red-Cyan      glasses (R+GB)
0044     Anaglyph_RedCyan_Optimized,    //!< optimized filter for Red-Cyan      glasses (R+GB)
0045     Anaglyph_YellowBlue_Simple,    //!< simple    filter for Yellow-Blue   glasses (RG+B)
0046     Anaglyph_YellowBlue_Optimized, //!< optimized filter for Yellow-Blue   glasses (RG+B)
0047     Anaglyph_GreenMagenta_Simple,  //!< simple    filter for Green-Magenta glasses (G+RB)
0048     Anaglyph_UserDefined           //!< use externally specified matrices
0049   };
0050 
0051   //! Statistics display flags.
0052   //! If not specified otherwise, the counter value is computed for a single rendered frame.
0053   enum PerfCounters
0054   {
0055     PerfCounters_NONE        = 0x000, //!< no stats
0056     PerfCounters_FrameRate   = 0x001, //!< Frame Rate,        frames per second (number of frames within elapsed time)
0057     PerfCounters_CPU         = 0x002, //!< CPU utilization as frames per second (number of frames within CPU utilization time (rendering thread))
0058     PerfCounters_Layers      = 0x004, //!< count layers (groups of structures)
0059     PerfCounters_Structures  = 0x008, //!< count low-level Structures (normal unhighlighted Presentable Object is usually represented by 1 Structure)
0060     //
0061     PerfCounters_Groups      = 0x010, //!< count primitive Groups (1 Structure holds 1 or more primitive Group)
0062     PerfCounters_GroupArrays = 0x020, //!< count Arrays within Primitive Groups (optimal primitive Group holds 1 Array)
0063     //
0064     PerfCounters_Triangles   = 0x040, //!< count Triangles
0065     PerfCounters_Points      = 0x080, //!< count Points
0066     PerfCounters_Lines       = 0x100, //!< count Line segments
0067     //
0068     PerfCounters_EstimMem    = 0x200, //!< estimated GPU memory usage
0069     //
0070     PerfCounters_FrameTime   = 0x400, //!< frame CPU utilization time (rendering thread); @sa Graphic3d_FrameStatsTimer
0071     PerfCounters_FrameTimeMax= 0x800, //!< maximum frame times
0072     //
0073     PerfCounters_SkipImmediate = 0x1000, //!< do not include immediate viewer updates (e.g. lazy updates without redrawing entire view content)
0074     //! show basic statistics
0075     PerfCounters_Basic = PerfCounters_FrameRate | PerfCounters_CPU | PerfCounters_Layers | PerfCounters_Structures,
0076     //! extended (verbose) statistics
0077     PerfCounters_Extended = PerfCounters_Basic
0078                           | PerfCounters_Groups | PerfCounters_GroupArrays
0079                           | PerfCounters_Triangles | PerfCounters_Points | PerfCounters_Lines
0080                           | PerfCounters_EstimMem,
0081     //! all counters
0082     PerfCounters_All = PerfCounters_Extended
0083                      | PerfCounters_FrameTime
0084                      | PerfCounters_FrameTimeMax,
0085   };
0086 
0087   //! State of frustum culling optimization.
0088   enum FrustumCulling
0089   {
0090     FrustumCulling_Off,     //!< culling is disabled
0091     FrustumCulling_On,      //!< culling is active, and the list of culled entities is automatically updated before redraw
0092     FrustumCulling_NoUpdate //!< culling is active, but the list of culled entities is not updated
0093   };
0094 
0095 public:
0096 
0097   //! Creates default rendering parameters.
0098   Graphic3d_RenderingParams()
0099   : Method                      (Graphic3d_RM_RASTERIZATION),
0100     ShadingModel                (Graphic3d_TypeOfShadingModel_Phong),
0101     TransparencyMethod          (Graphic3d_RTM_BLEND_UNORDERED),
0102     Resolution                  (THE_DEFAULT_RESOLUTION),
0103     FontHinting                 (Font_Hinting_Off),
0104     LineFeather                 (1.0f),
0105     // PBR parameters
0106     PbrEnvPow2Size              (9),
0107     PbrEnvSpecMapNbLevels       (6),
0108     PbrEnvBakingDiffNbSamples   (1024),
0109     PbrEnvBakingSpecNbSamples   (256),
0110     PbrEnvBakingProbability     (0.99f),
0111     //
0112     OitDepthFactor              (0.0f),
0113     NbOitDepthPeelingLayers     (4),
0114     NbMsaaSamples               (0),
0115     RenderResolutionScale       (1.0f),
0116     ShadowMapResolution         (1024),
0117     ShadowMapBias               (0.005f),
0118     ToEnableDepthPrepass        (Standard_False),
0119     ToEnableAlphaToCoverage     (Standard_True),
0120     // ray tracing parameters
0121     IsGlobalIlluminationEnabled (Standard_False),
0122     SamplesPerPixel(0),
0123     RaytracingDepth             (THE_DEFAULT_DEPTH),
0124     IsShadowEnabled             (Standard_True),
0125     IsReflectionEnabled         (Standard_False),
0126     IsAntialiasingEnabled       (Standard_False),
0127     IsTransparentShadowEnabled  (Standard_False),
0128     UseEnvironmentMapBackground (Standard_False),
0129     ToIgnoreNormalMapInRayTracing (Standard_False),
0130     CoherentPathTracingMode     (Standard_False),
0131     AdaptiveScreenSampling      (Standard_False),
0132     AdaptiveScreenSamplingAtomic(Standard_False),
0133     ShowSamplingTiles           (Standard_False),
0134     TwoSidedBsdfModels          (Standard_False),
0135     RadianceClampingValue       (30.0),
0136     RebuildRayTracingShaders    (Standard_False),
0137     RayTracingTileSize          (32),
0138     NbRayTracingTiles           (16 * 16),
0139     CameraApertureRadius        (0.0f),
0140     CameraFocalPlaneDist        (1.0f),
0141     FrustumCullingState         (FrustumCulling_On),
0142     ToneMappingMethod           (Graphic3d_ToneMappingMethod_Disabled),
0143     Exposure                    (0.f),
0144     WhitePoint                  (1.f),
0145     // stereoscopic parameters
0146     StereoMode (Graphic3d_StereoMode_QuadBuffer),
0147     HmdFov2d (30.0f),
0148     AnaglyphFilter (Anaglyph_RedCyan_Optimized),
0149     ToReverseStereo (Standard_False),
0150     ToSmoothInterlacing (Standard_True),
0151     ToMirrorComposer (Standard_True),
0152     //
0153     StatsPosition (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_UPPER,  Graphic3d_Vec2i (20, 20))),
0154     ChartPosition (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_RIGHT_UPPER, Graphic3d_Vec2i (20, 20))),
0155     ChartSize (-1, -1),
0156     StatsTextAspect (new Graphic3d_AspectText3d()),
0157     StatsUpdateInterval (1.0),
0158     StatsTextHeight (16),
0159     StatsNbFrames (1),
0160     StatsMaxChartTime (0.1f),
0161     CollectedStats (PerfCounters_Basic),
0162     ToShowStats (Standard_False)
0163   {
0164     const Graphic3d_Vec4 aZero (0.0f, 0.0f, 0.0f, 0.0f);
0165     AnaglyphLeft .SetRow (0, Graphic3d_Vec4 (1.0f,  0.0f,  0.0f, 0.0f));
0166     AnaglyphLeft .SetRow (1, aZero);
0167     AnaglyphLeft .SetRow (2, aZero);
0168     AnaglyphLeft .SetRow (3, aZero);
0169     AnaglyphRight.SetRow (0, aZero);
0170     AnaglyphRight.SetRow (1, Graphic3d_Vec4 (0.0f,  1.0f,  0.0f, 0.0f));
0171     AnaglyphRight.SetRow (2, Graphic3d_Vec4 (0.0f,  0.0f,  1.0f, 0.0f));
0172     AnaglyphRight.SetRow (3, aZero);
0173 
0174     StatsTextAspect->SetColor (Quantity_NOC_WHITE);
0175     StatsTextAspect->SetColorSubTitle (Quantity_NOC_BLACK);
0176     StatsTextAspect->SetFont (Font_NOF_ASCII_MONO);
0177     StatsTextAspect->SetDisplayType (Aspect_TODT_SHADOW);
0178     StatsTextAspect->SetTextZoomable (Standard_False);
0179     StatsTextAspect->SetTextFontAspect (Font_FA_Regular);
0180   }
0181 
0182   //! Returns resolution ratio.
0183   Standard_ShortReal ResolutionRatio() const
0184   {
0185     return Resolution / static_cast<Standard_ShortReal> (THE_DEFAULT_RESOLUTION);
0186   }
0187 
0188   //! Dumps the content of me into the stream
0189   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0190 
0191 public: //! @name general parameters
0192 
0193   Graphic3d_RenderingMode           Method;                      //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
0194   Graphic3d_TypeOfShadingModel      ShadingModel;                //!< specified default shading model, Graphic3d_TypeOfShadingModel_Phong by default
0195   Graphic3d_RenderTransparentMethod TransparencyMethod;          //!< specifies rendering method for transparent graphics
0196   unsigned int                      Resolution;                  //!< Pixels density (PPI), defines scaling factor for parameters like text size
0197                                                                  //!  (when defined in screen-space units rather than in 3D) to be properly displayed
0198                                                                  //!  on device (screen / printer). 72 is default value.
0199                                                                  //!  Note that using difference resolution in different Views in same Viewer
0200                                                                  //!  will lead to performance regression (for example, text will be recreated every time).
0201   Font_Hinting                      FontHinting;                 //!< enables/disables text hinting within textured fonts, Font_Hinting_Off by default;
0202                                                                  //!  hinting improves readability of thin text on low-resolution screen,
0203                                                                  //!  but adds distortions to original font depending on font family and font library version
0204   Standard_ShortReal                LineFeather;                 //!< line feather width in pixels (> 0.0), 1.0 by default;
0205                                                                  //!  high values produce blurred results, small values produce sharp (aliased) edges
0206 
0207 public: //! @name rendering resolution parameters
0208 
0209   Standard_Integer                  PbrEnvPow2Size;              //!< size of IBL maps side can be calculated as 2^PbrEnvPow2Size (> 0), 9 by default
0210   Standard_Integer                  PbrEnvSpecMapNbLevels;       //!< number of levels used in specular IBL map (> 1), 6 by default
0211   Standard_Integer                  PbrEnvBakingDiffNbSamples;   //!< number of samples used in Monte-Carlo integration during diffuse IBL map's
0212                                                                  //!  spherical harmonics coefficients generation (> 0), 1024 by default
0213   Standard_Integer                  PbrEnvBakingSpecNbSamples;   //!< number of samples used in Monte-Carlo integration during specular IBL map's generation (> 0), 256 by default
0214   Standard_ShortReal                PbrEnvBakingProbability;     //!< controls strength of samples reducing strategy during specular IBL map's generation
0215                                                                  //!  (see 'SpecIBLMapSamplesFactor' function for detail explanation) [0.0, 1.0], 0.99 by default
0216 
0217   Standard_ShortReal                OitDepthFactor;              //!< scalar factor [0-1] controlling influence of depth of a fragment to its final coverage (Graphic3d_RTM_BLEND_OIT), 0.0 by default
0218   Standard_Integer                  NbOitDepthPeelingLayers;     //!< number of depth peeling (Graphic3d_RTM_DEPTH_PEELING_OIT) layers, 4 by default
0219   Standard_Integer                  NbMsaaSamples;               //!< number of MSAA samples (should be within 0..GL_MAX_SAMPLES, power-of-two number), 0 by default
0220   Standard_ShortReal                RenderResolutionScale;       //!< rendering resolution scale factor, 1 by default;
0221                                                                  //!  incompatible with MSAA (e.g. NbMsaaSamples should be set to 0)
0222   Standard_Integer                  ShadowMapResolution;         //!< shadow texture map resolution, 1024 by default
0223   Standard_ShortReal                ShadowMapBias;               //!< shadowmap bias, 0.005 by default;
0224   Standard_Boolean                  ToEnableDepthPrepass;        //!< enables/disables depth pre-pass, False by default
0225   Standard_Boolean                  ToEnableAlphaToCoverage;     //!< enables/disables alpha to coverage, True by default
0226 
0227 public: //! @name Ray-Tracing/Path-Tracing parameters
0228 
0229   Standard_Boolean                  IsGlobalIlluminationEnabled; //!< enables/disables global illumination effects (path tracing)
0230   Standard_Integer                  SamplesPerPixel;             //!< number of samples per pixel (SPP)
0231   Standard_Integer                  RaytracingDepth;             //!< maximum ray-tracing depth, 3 by default
0232   Standard_Boolean                  IsShadowEnabled;             //!< enables/disables shadows rendering, True by default
0233   Standard_Boolean                  IsReflectionEnabled;         //!< enables/disables specular reflections, False by default
0234   Standard_Boolean                  IsAntialiasingEnabled;       //!< enables/disables adaptive anti-aliasing, False by default
0235   Standard_Boolean                  IsTransparentShadowEnabled;  //!< enables/disables light propagation through transparent media, False by default
0236   Standard_Boolean                  UseEnvironmentMapBackground; //!< enables/disables environment map background
0237   Standard_Boolean                  ToIgnoreNormalMapInRayTracing; //!< enables/disables normal map ignoring during path tracing; FALSE by default
0238   Standard_Boolean                  CoherentPathTracingMode;     //!< enables/disables 'coherent' tracing mode (single RNG seed within 16x16 image blocks)
0239   Standard_Boolean                  AdaptiveScreenSampling;      //!< enables/disables adaptive screen sampling mode for path tracing, FALSE by default
0240   Standard_Boolean                  AdaptiveScreenSamplingAtomic;//!< enables/disables usage of atomic float operations within adaptive screen sampling, FALSE by default
0241   Standard_Boolean                  ShowSamplingTiles;           //!< enables/disables debug mode for adaptive screen sampling, FALSE by default
0242   Standard_Boolean                  TwoSidedBsdfModels;          //!< forces path tracing to use two-sided versions of original one-sided scattering models
0243   Standard_ShortReal                RadianceClampingValue;       //!< maximum radiance value used for clamping radiance estimation.
0244   Standard_Boolean                  RebuildRayTracingShaders;    //!< forces rebuilding ray tracing shaders at the next frame
0245   Standard_Integer                  RayTracingTileSize;          //!< screen tile size, 32 by default (adaptive sampling mode of path tracing);
0246   Standard_Integer                  NbRayTracingTiles;           //!< maximum number of screen tiles per frame, 256 by default (adaptive sampling mode of path tracing);
0247                                                                  //!  this parameter limits the number of tiles to be rendered per redraw, increasing Viewer interactivity,
0248                                                                  //!  but also increasing the time for achieving a good quality; -1 means no limit
0249   Standard_ShortReal                CameraApertureRadius;        //!< aperture radius of perspective camera used for depth-of-field, 0.0 by default (no DOF) (path tracing only)
0250   Standard_ShortReal                CameraFocalPlaneDist;        //!< focal  distance of perspective camera used for depth-of field, 1.0 by default (path tracing only)
0251   FrustumCulling                    FrustumCullingState;         //!< state of frustum culling optimization; FrustumCulling_On by default
0252 
0253   Graphic3d_ToneMappingMethod       ToneMappingMethod;           //!< specifies tone mapping method for path tracing, Graphic3d_ToneMappingMethod_Disabled by default
0254   Standard_ShortReal                Exposure;                    //!< exposure value used for tone mapping (path tracing), 0.0 by default
0255   Standard_ShortReal                WhitePoint;                  //!< white point value used in filmic tone mapping (path tracing), 1.0 by default
0256 
0257 public: //! @name VR / stereoscopic parameters
0258 
0259   Graphic3d_StereoMode              StereoMode;                  //!< stereoscopic output mode, Graphic3d_StereoMode_QuadBuffer by default
0260   Standard_ShortReal                HmdFov2d;                    //!< sharp field of view range in degrees for displaying on-screen 2D elements, 30.0 by default;
0261   Anaglyph                          AnaglyphFilter;              //!< filter for anaglyph output, Anaglyph_RedCyan_Optimized by default
0262   Graphic3d_Mat4                    AnaglyphLeft;                //!< left  anaglyph filter (in normalized colorspace), Color = AnaglyphRight * theColorRight + AnaglyphLeft * theColorLeft;
0263   Graphic3d_Mat4                    AnaglyphRight;               //!< right anaglyph filter (in normalized colorspace), Color = AnaglyphRight * theColorRight + AnaglyphLeft * theColorLeft;
0264   Standard_Boolean                  ToReverseStereo;             //!< flag to reverse stereo pair, FALSE by default
0265   Standard_Boolean                  ToSmoothInterlacing;         //!< flag to smooth output on interlaced displays (improves text readability / reduces line aliasing), TRUE by default
0266   Standard_Boolean                  ToMirrorComposer;            //!< if output device is an external composer - mirror rendering results in window in addition to sending frame to composer, TRUE by default
0267 
0268 public: //! @name on-screen display parameters
0269 
0270   Handle(Graphic3d_TransformPers)   StatsPosition;               //!< location of stats, upper-left position by default
0271   Handle(Graphic3d_TransformPers)   ChartPosition;               //!< location of stats chart, upper-right position by default
0272   Graphic3d_Vec2i                   ChartSize;                   //!< chart size in pixels, (-1, -1) by default which means that chart will occupy a portion of viewport
0273   Handle(Graphic3d_AspectText3d)    StatsTextAspect;             //!< stats text aspect
0274   Standard_ShortReal                StatsUpdateInterval;         //!< time interval between stats updates in seconds, 1.0 second by default;
0275                                                                  //!  too often updates might impact performance and will smear text within widgets
0276                                                                  //!  (especially framerate, which is better averaging);
0277                                                                  //!  0.0 interval will force updating on each frame
0278   Standard_Integer                  StatsTextHeight;             //!< stats text size; 16 by default
0279   Standard_Integer                  StatsNbFrames;               //!< number of data frames to collect history; 1 by default
0280   Standard_ShortReal                StatsMaxChartTime;           //!< upper time limit within frame chart in seconds; 0.1 seconds by default (100 ms or 10 FPS)
0281   PerfCounters                      CollectedStats;              //!< performance counters to collect, PerfCounters_Basic by default;
0282                                                                  //!  too verbose options might impact rendering performance,
0283                                                                  //!  because some counters might lack caching optimization (and will require expensive iteration through all data structures)
0284   Standard_Boolean                  ToShowStats;                 //!< display performance statistics, FALSE by default;
0285                                                                  //!  note that counters specified within CollectedStats will be updated nevertheless
0286                                                                  //!  of visibility of widget managed by ToShowStats flag (e.g. stats can be retrieved by application for displaying using other methods)
0287 
0288 };
0289 
0290 #endif // _Graphic3d_RenderingParams_HeaderFile