0030640: Visualization, Graphic3d_Camera - add option creating Projection matrix...
[occt.git] / src / Graphic3d / Graphic3d_RenderingParams.hxx
CommitLineData
bc8c79bb 1// Created on: 2014-05-14
2// Created by: Denis BOGOLEPOV
3// Copyright (c) 2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _Graphic3d_RenderingParams_HeaderFile
17#define _Graphic3d_RenderingParams_HeaderFile
18
15669413 19#include <Graphic3d_AspectText3d.hxx>
20#include <Graphic3d_TransformPers.hxx>
a1073ae2 21#include <Graphic3d_RenderTransparentMethod.hxx>
bc8c79bb 22#include <Graphic3d_RenderingMode.hxx>
f978241f 23#include <Graphic3d_StereoMode.hxx>
eb85ed36 24#include <Graphic3d_ToneMappingMethod.hxx>
f978241f 25#include <Graphic3d_Vec4.hxx>
bc8c79bb 26
27//! Helper class to store rendering parameters.
28class Graphic3d_RenderingParams
29{
30public:
4b1c8733 31 //! Default pixels density.
32 static const unsigned int THE_DEFAULT_RESOLUTION = 72u;
bc8c79bb 33
34 //! Default ray-tracing depth.
35 static const Standard_Integer THE_DEFAULT_DEPTH = 3;
36
f978241f 37 //! Anaglyph filter presets.
38 enum Anaglyph
39 {
40 Anaglyph_RedCyan_Simple, //!< simple filter for Red-Cyan glasses (R+GB)
41 Anaglyph_RedCyan_Optimized, //!< optimized filter for Red-Cyan glasses (R+GB)
42 Anaglyph_YellowBlue_Simple, //!< simple filter for Yellow-Blue glasses (RG+B)
43 Anaglyph_YellowBlue_Optimized, //!< optimized filter for Yellow-Blue glasses (RG+B)
44 Anaglyph_GreenMagenta_Simple, //!< simple filter for Green-Magenta glasses (G+RB)
45 Anaglyph_UserDefined //!< use externally specified matrices
46 };
47
15669413 48 //! Statistics display flags.
5e30547b 49 //! If not specified otherwise, the counter value is computed for a single rendered frame.
15669413 50 enum PerfCounters
51 {
52 PerfCounters_NONE = 0x000, //!< no stats
5e30547b 53 PerfCounters_FrameRate = 0x001, //!< Frame Rate, frames per second (number of frames within elapsed time)
54 PerfCounters_CPU = 0x002, //!< CPU utilization as frames per second (number of frames within CPU utilization time (rendering thread))
15669413 55 PerfCounters_Layers = 0x004, //!< count layers (groups of structures)
56 PerfCounters_Structures = 0x008, //!< count low-level Structures (normal unhighlighted Presentable Object is usually represented by 1 Structure)
57 //
58 PerfCounters_Groups = 0x010, //!< count primitive Groups (1 Structure holds 1 or more primitive Group)
59 PerfCounters_GroupArrays = 0x020, //!< count Arrays within Primitive Groups (optimal primitive Group holds 1 Array)
60 //
61 PerfCounters_Triangles = 0x040, //!< count Triangles
62 PerfCounters_Points = 0x080, //!< count Points
b9f43ad1 63 PerfCounters_Lines = 0x100, //!< count Line segments
15669413 64 //
b9f43ad1 65 PerfCounters_EstimMem = 0x200, //!< estimated GPU memory usage
5e30547b 66 //
b9f43ad1 67 PerfCounters_FrameTime = 0x400, //!< frame CPU utilization time (rendering thread); @sa Graphic3d_FrameStatsTimer
68 PerfCounters_FrameTimeMax= 0x800, //!< maximum frame times
5e30547b 69 //
b9f43ad1 70 PerfCounters_SkipImmediate = 0x1000, //!< do not include immediate viewer updates (e.g. lazy updates without redrawing entire view content)
15669413 71 //! show basic statistics
72 PerfCounters_Basic = PerfCounters_FrameRate | PerfCounters_CPU | PerfCounters_Layers | PerfCounters_Structures,
73 //! extended (verbose) statistics
74 PerfCounters_Extended = PerfCounters_Basic
75 | PerfCounters_Groups | PerfCounters_GroupArrays
b9f43ad1 76 | PerfCounters_Triangles | PerfCounters_Points | PerfCounters_Lines
15669413 77 | PerfCounters_EstimMem,
5e30547b 78 //! all counters
79 PerfCounters_All = PerfCounters_Extended
80 | PerfCounters_FrameTime
81 | PerfCounters_FrameTimeMax,
15669413 82 };
83
0e3025bc 84 //! State of frustum culling optimization.
85 enum FrustumCulling
86 {
87 FrustumCulling_Off, //!< culling is disabled
88 FrustumCulling_On, //!< culling is active, and the list of culled entities is automatically updated before redraw
89 FrustumCulling_NoUpdate //!< culling is active, but the list of culled entities is not updated
90 };
91
bc8c79bb 92public:
93
94 //! Creates default rendering parameters.
95 Graphic3d_RenderingParams()
189f85a3 96 : Method (Graphic3d_RM_RASTERIZATION),
a1073ae2 97 TransparencyMethod (Graphic3d_RTM_BLEND_UNORDERED),
2a332745 98 LineFeather (1.0f),
67312b79 99 // PBR parameters
100 PbrEnvPow2Size (9),
101 PbrEnvSpecMapNbLevels (6),
102 PbrEnvBakingDiffNbSamples (1024),
103 PbrEnvBakingSpecNbSamples (256),
104 PbrEnvBakingProbability (0.99f),
105 //
a1073ae2 106 OitDepthFactor (0.0f),
78c4e836 107 NbOitDepthPeelingLayers (4),
3c4b62a4 108 NbMsaaSamples (0),
56689b27 109 RenderResolutionScale (1.0f),
d84e8669 110 ShadowMapResolution (1024),
111 ShadowMapBias (0.005f),
f88457e6 112 ToEnableDepthPrepass (Standard_False),
2a332745 113 ToEnableAlphaToCoverage (Standard_True),
3c4b62a4 114 // ray tracing parameters
f978241f 115 IsGlobalIlluminationEnabled (Standard_False),
d533dafb 116 SamplesPerPixel(0),
f978241f 117 RaytracingDepth (THE_DEFAULT_DEPTH),
189f85a3 118 IsShadowEnabled (Standard_True),
119 IsReflectionEnabled (Standard_False),
120 IsAntialiasingEnabled (Standard_False),
121 IsTransparentShadowEnabled (Standard_False),
f978241f 122 UseEnvironmentMapBackground (Standard_False),
78607702 123 ToIgnoreNormalMapInRayTracing (Standard_False),
8c820969 124 CoherentPathTracingMode (Standard_False),
3a9b5dc8 125 AdaptiveScreenSampling (Standard_False),
e084dbbc 126 AdaptiveScreenSamplingAtomic(Standard_False),
3a9b5dc8 127 ShowSamplingTiles (Standard_False),
b4327ba8 128 TwoSidedBsdfModels (Standard_False),
b09447ed 129 RadianceClampingValue (30.0),
d877e610 130 RebuildRayTracingShaders (Standard_False),
66d1cdc6 131 RayTracingTileSize (32),
4eaaf9d8 132 NbRayTracingTiles (16 * 16),
b27ab03d 133 CameraApertureRadius (0.0f),
134 CameraFocalPlaneDist (1.0f),
0e3025bc 135 FrustumCullingState (FrustumCulling_On),
eb85ed36 136 ToneMappingMethod (Graphic3d_ToneMappingMethod_Disabled),
137 Exposure (0.f),
138 WhitePoint (1.f),
3c4b62a4 139 // stereoscopic parameters
f978241f 140 StereoMode (Graphic3d_StereoMode_QuadBuffer),
b40cdc2b 141 HmdFov2d (30.0f),
f978241f 142 AnaglyphFilter (Anaglyph_RedCyan_Optimized),
4b1c8733 143 ToReverseStereo (Standard_False),
b40cdc2b 144 ToMirrorComposer (Standard_True),
15669413 145 //
5e30547b 146 StatsPosition (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_UPPER, Graphic3d_Vec2i (20, 20))),
147 ChartPosition (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_RIGHT_UPPER, Graphic3d_Vec2i (20, 20))),
148 ChartSize (-1, -1),
15669413 149 StatsTextAspect (new Graphic3d_AspectText3d()),
150 StatsUpdateInterval (1.0),
151 StatsTextHeight (16),
5e30547b 152 StatsNbFrames (1),
153 StatsMaxChartTime (0.1f),
15669413 154 CollectedStats (PerfCounters_Basic),
155 ToShowStats (Standard_False),
156 //
4b1c8733 157 Resolution (THE_DEFAULT_RESOLUTION)
bc8c79bb 158 {
f978241f 159 const Graphic3d_Vec4 aZero (0.0f, 0.0f, 0.0f, 0.0f);
160 AnaglyphLeft .SetRow (0, Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f));
161 AnaglyphLeft .SetRow (1, aZero);
162 AnaglyphLeft .SetRow (2, aZero);
163 AnaglyphLeft .SetRow (3, aZero);
164 AnaglyphRight.SetRow (0, aZero);
165 AnaglyphRight.SetRow (1, Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
166 AnaglyphRight.SetRow (2, Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f));
167 AnaglyphRight.SetRow (3, aZero);
15669413 168
169 StatsTextAspect->SetColor (Quantity_NOC_WHITE);
170 StatsTextAspect->SetColorSubTitle (Quantity_NOC_BLACK);
171 StatsTextAspect->SetFont (Font_NOF_ASCII_MONO);
172 StatsTextAspect->SetDisplayType (Aspect_TODT_SHADOW);
173 StatsTextAspect->SetTextZoomable (Standard_False);
174 StatsTextAspect->SetTextFontAspect (Font_FA_Regular);
bc8c79bb 175 }
176
75c262a9 177 //! Returns resolution ratio.
178 Standard_ShortReal ResolutionRatio() const
179 {
180 return Resolution / static_cast<Standard_ShortReal> (THE_DEFAULT_RESOLUTION);
181 }
a5162275 182
183 //! Dumps the content of me into the stream
184 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
75c262a9 185
bc8c79bb 186public:
187
a1073ae2 188 Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
189 Graphic3d_RenderTransparentMethod TransparencyMethod; //!< specifies rendering method for transparent graphics
2a332745 190 Standard_ShortReal LineFeather; //!< line feater width in pixels (> 0.0), 1.0 by default;
191 //! high values produce blurred results, small values produce sharp (aliased) edges
67312b79 192
193 Standard_Integer PbrEnvPow2Size; //!< size of IBL maps side can be calculated as 2^PbrEnvPow2Size (> 0), 9 by default
194 Standard_Integer PbrEnvSpecMapNbLevels; //!< number of levels used in specular IBL map (> 1), 6 by default
195 Standard_Integer PbrEnvBakingDiffNbSamples; //!< number of samples used in Monte-Carlo integration during diffuse IBL map's
196 //! spherical harmonics coefficients generation (> 0), 1024 by default
197 Standard_Integer PbrEnvBakingSpecNbSamples; //!< number of samples used in Monte-Carlo integration during specular IBL map's generation (> 0), 256 by default
198 Standard_ShortReal PbrEnvBakingProbability; //!< controls strength of samples reducing strategy during specular IBL map's generation
199 //! (see 'SpecIBLMapSamplesFactor' function for detail explanation) [0.0, 1.0], 0.99 by default
200
78c4e836 201 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
202 Standard_Integer NbOitDepthPeelingLayers; //!< number of depth peeling (Graphic3d_RTM_DEPTH_PEELING_OIT) layers, 4 by default
a1073ae2 203 Standard_Integer NbMsaaSamples; //!< number of MSAA samples (should be within 0..GL_MAX_SAMPLES, power-of-two number), 0 by default
204 Standard_ShortReal RenderResolutionScale; //!< rendering resolution scale factor, 1 by default;
205 //! incompatible with MSAA (e.g. NbMsaaSamples should be set to 0)
d84e8669 206 Standard_Integer ShadowMapResolution; //!< shadow texture map resolution, 1024 by default
207 Standard_ShortReal ShadowMapBias; //!< shadowmap bias, 0.005 by default;
f88457e6 208 Standard_Boolean ToEnableDepthPrepass; //!< enables/disables depth pre-pass, False by default
2a332745 209 Standard_Boolean ToEnableAlphaToCoverage; //!< enables/disables alpha to coverage, True by default
a1073ae2 210
211 Standard_Boolean IsGlobalIlluminationEnabled; //!< enables/disables global illumination effects (path tracing)
212 Standard_Integer SamplesPerPixel; //!< number of samples per pixel (SPP)
213 Standard_Integer RaytracingDepth; //!< maximum ray-tracing depth, 3 by default
214 Standard_Boolean IsShadowEnabled; //!< enables/disables shadows rendering, True by default
215 Standard_Boolean IsReflectionEnabled; //!< enables/disables specular reflections, False by default
216 Standard_Boolean IsAntialiasingEnabled; //!< enables/disables adaptive anti-aliasing, False by default
217 Standard_Boolean IsTransparentShadowEnabled; //!< enables/disables light propagation through transparent media, False by default
218 Standard_Boolean UseEnvironmentMapBackground; //!< enables/disables environment map background
78607702 219 Standard_Boolean ToIgnoreNormalMapInRayTracing; //!< enables/disables normal map ignoring during path tracing; FALSE by default
a1073ae2 220 Standard_Boolean CoherentPathTracingMode; //!< enables/disables 'coherent' tracing mode (single RNG seed within 16x16 image blocks)
221 Standard_Boolean AdaptiveScreenSampling; //!< enables/disables adaptive screen sampling mode for path tracing, FALSE by default
e084dbbc 222 Standard_Boolean AdaptiveScreenSamplingAtomic;//!< enables/disables usage of atomic float operations within adaptive screen sampling, FALSE by default
a1073ae2 223 Standard_Boolean ShowSamplingTiles; //!< enables/disables debug mode for adaptive screen sampling, FALSE by default
224 Standard_Boolean TwoSidedBsdfModels; //!< forces path tracing to use two-sided versions of original one-sided scattering models
225 Standard_ShortReal RadianceClampingValue; //!< maximum radiance value used for clamping radiance estimation.
226 Standard_Boolean RebuildRayTracingShaders; //!< forces rebuilding ray tracing shaders at the next frame
66d1cdc6 227 Standard_Integer RayTracingTileSize; //!< screen tile size, 32 by default (adaptive sampling mode of path tracing);
228 Standard_Integer NbRayTracingTiles; //!< maximum number of screen tiles per frame, 256 by default (adaptive sampling mode of path tracing);
229 //! this parameter limits the number of tiles to be rendered per redraw, increasing Viewer interactivity,
230 //! but also increasing the time for achieving a good quality; -1 means no limit
b27ab03d 231 Standard_ShortReal CameraApertureRadius; //!< aperture radius of perspective camera used for depth-of-field, 0.0 by default (no DOF) (path tracing only)
232 Standard_ShortReal CameraFocalPlaneDist; //!< focal distance of perspective camera used for depth-of field, 1.0 by default (path tracing only)
0e3025bc 233 FrustumCulling FrustumCullingState; //!< state of frustum culling optimization; FrustumCulling_On by default
a1073ae2 234
eb85ed36 235 Graphic3d_ToneMappingMethod ToneMappingMethod; //!< specifies tone mapping method for path tracing, Graphic3d_ToneMappingMethod_Disabled by default
236 Standard_ShortReal Exposure; //!< exposure value used for tone mapping (path tracing), 0.0 by default
237 Standard_ShortReal WhitePoint; //!< white point value used in filmic tone mapping (path tracing), 1.0 by default
238
a1073ae2 239 Graphic3d_StereoMode StereoMode; //!< stereoscopic output mode, Graphic3d_StereoMode_QuadBuffer by default
b40cdc2b 240 Standard_ShortReal HmdFov2d; //!< sharp field of view range in degrees for displaying on-screen 2D elements, 30.0 by default;
a1073ae2 241 Anaglyph AnaglyphFilter; //!< filter for anaglyph output, Anaglyph_RedCyan_Optimized by default
242 Graphic3d_Mat4 AnaglyphLeft; //!< left anaglyph filter (in normalized colorspace), Color = AnaglyphRight * theColorRight + AnaglyphLeft * theColorLeft;
243 Graphic3d_Mat4 AnaglyphRight; //!< right anaglyph filter (in normalized colorspace), Color = AnaglyphRight * theColorRight + AnaglyphLeft * theColorLeft;
244 Standard_Boolean ToReverseStereo; //!< flag to reverse stereo pair, FALSE by default
b40cdc2b 245 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
a1073ae2 246
15669413 247 Handle(Graphic3d_TransformPers) StatsPosition; //!< location of stats, upper-left position by default
5e30547b 248 Handle(Graphic3d_TransformPers) ChartPosition; //!< location of stats chart, upper-right position by default
249 Graphic3d_Vec2i ChartSize; //!< chart size in pixels, (-1, -1) by default which means that chart will occupy a portion of viewport
15669413 250 Handle(Graphic3d_AspectText3d) StatsTextAspect; //!< stats text aspect
251 Standard_ShortReal StatsUpdateInterval; //!< time interval between stats updates in seconds, 1.0 second by default;
252 //! too often updates might impact performance and will smear text within widgets
253 //! (especially framerate, which is better averaging);
254 //! 0.0 interval will force updating on each frame
255 Standard_Integer StatsTextHeight; //!< stats text size; 16 by default
5e30547b 256 Standard_Integer StatsNbFrames; //!< number of data frames to collect history; 1 by default
257 Standard_ShortReal StatsMaxChartTime; //!< upper time limit within frame chart in seconds; 0.1 seconds by default (100 ms or 10 FPS)
15669413 258 PerfCounters CollectedStats; //!< performance counters to collect, PerfCounters_Basic by default;
259 //! too verbose options might impact rendering performance,
260 //! because some counters might lack caching optimization (and will require expensive iteration through all data structures)
261 Standard_Boolean ToShowStats; //!< display performance statistics, FALSE by default;
262 //! note that counters specified within CollectedStats will be updated nevertheless
263 //! of visibility of widget managed by ToShowStats flag (e.g. stats can be retrieved by application for displaying using other methods)
264
a1073ae2 265 unsigned int Resolution; //!< Pixels density (PPI), defines scaling factor for parameters like text size
266 //! (when defined in screen-space units rather than in 3D) to be properly displayed
267 //! on device (screen / printer). 72 is default value.
268 //! Note that using difference resolution in different Views in same Viewer
269 //! will lead to performance regression (for example, text will be recreated every time).
bc8c79bb 270};
271
272#endif // _Graphic3d_RenderingParams_HeaderFile