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