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