VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtHbaoDrawable.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Copyright (c) 2022 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
6 #pragma once
7 
11 
14 
16 
18 
20 
21 #include <osg/observer_ptr>
22 #include <osg/GraphicsContext>
23 #include <osg/Texture>
24 
25 //NVIDIA's HBAO library https://developer.nvidia.com/shadowworks
26 #include <GFSDK/GFSDK_SSAO.h>
27 
28 namespace osg
29 {
30  class Texture2D;
31  class State;
32 }
33 
34 namespace makVrv
35 {
36  class DtDe;
37  class DtGlProgram;
38  class DtGlRenderTexture;
39 
42 
44  template <>
45  inline const char* creatorTypeName<DtHbaoDrawable>(void) { return "DtHbaoDrawableCreator"; }
46 
50  {
51  public:
52 
53  int viewWidth = 0;
54  int viewHeight = 0;
55 
56  float radius = 2.0f; // The AO radius in meters
57  float bias = 0.1f; // To hide low-tessellation artifacts // 0.0~0.5
58  float exponent = 2.0f; // The final AO output is pow(AO, powerExponent) // 1.0~4.0
59  bool blurEnable = true; // To blur the AO with an edge-preserving blur
60  int blurRadius = GFSDK_SSAO_BLUR_RADIUS_4; // BLUR_RADIUS_2 or BLUR_RADIUS_4
61  float blurSharpness = 4.0f; // The higher, the more the blur preserves edges // 0.0~16.0
62 
63  bool sharpnessProfileEnable = false; // To make the blur sharper in the foreground
64  float sharpnessProfileScale = 4.0f; // Sharpness scale factor for ViewDepths <= ForegroundViewDepth
65  float sharpnessProfileForegroundViewDepth = 0.0; // Maximum view depth of the foreground depth range
66  float sharpnessProfileBackgroundViewDepth = 1.0; // Minimum view depth of the background depth range
67 
68  float smallScaleAo = 1.0f; // Scale factor for the small-scale AO, the greater the darker // 0.0~2.0
69  float largeScaleAo = 1.0f; // Scale factor for the large-scale AO, the greater the darker // 0.0~2.0
70 
71  bool foregroundAoEnable = false; // To limit the occlusion scale in the foreground
72  float foregroundAoDepth = 0.0f;// View-space depth at which the AO footprint should get clamped
73  bool backgroundAoEnable = false; // To add larger-scale occlusion in the distance
74  float backgroundAoDepth = 0.0f; // View-space depth at which the AO footprint should stop falling off with depth
75 
76  //Depth storage needs to be 32-bit so that zoomed in views work.
77  int depthStorage = GFSDK_SSAO_FP32_VIEW_DEPTHS; // Quality / performance tradeoff
78  int depthClampMode = GFSDK_SSAO_CLAMP_TO_EDGE; // To hide possible false-occlusion artifacts near screen borders
79  bool depthThresholdEnable = false; // To return white AO for ViewDepths > MaxViewDepth
80  float depthThresholdMaxViewDepth = 0.0f; // Custom view-depth threshold
81  float depthThresholdSharpness = 100.0f; // The higher, the sharper are the AO-to-white transitions
82 
83  };
84 
90  {
91  public:
93  virtual ~DtHbaoDrawable();
94 
96  DtHbaoDrawable() = delete;
97 
99  DtHbaoDrawable(const DtHbaoDrawable&) = delete;
100 
102  DtHbaoDrawable& operator=(const DtHbaoDrawable&) = delete;
103 
104  protected:
106  DtHbaoDrawable(DtDe &de);
107 
110 
111  public:
113  virtual void drawImplementation(osg::RenderInfo& renderInfo) const override;
114 
116  virtual void reloadShaders();
117 
122  //virtual void releaseGLObjects(osg::State* state = 0) const;
123 
125  virtual void setDepthTexture(osg::Texture* texture);
126 
128  virtual void setBaseTexture(osg::Texture* texture);
129 
131  virtual void setOcclusionTexture(osg::Texture* inputTex);
132 
134  virtual void setViewSize(int width, int height);
135 
136  protected:
137 
139  virtual void createProgramIfNecessary(void) const;
140 
142  virtual void cleanupGpuMemory(void);
143 
145  virtual void releaseHbaoRenderTexture();
146 
151  void updateHbaoSettings() const;
152 
154  void createTextureViewsIfNecessary(osg::State* state) const;
155 
156  protected:
157 
161 
164  mutable std::vector<GLuint> myDepthTexViews;
166 
169 
173 
176  mutable bool myMutableTapsDirty;
177 
178  mutable osg::observer_ptr<const osg::GraphicsContext> myInitGraphicsContext;
180 
181  mutable GFSDK_SSAO_Context_GL* myMutableSsaoContextGl;
182  mutable GFSDK_SSAO_GLFunctions myMutableGlFunctions;
183 
185 
187 
189  };
190 
191 
192 }
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
float sharpnessProfileBackgroundViewDepth
Definition: DtHbaoDrawable.h:66
DtSignalConnectionManager myMutableConnections
Definition: DtHbaoDrawable.h:186
float depthThresholdSharpness
Definition: DtHbaoDrawable.h:81
GFSDK_SSAO_GLFunctions myMutableGlFunctions
Definition: DtHbaoDrawable.h:182
float exponent
Definition: DtHbaoDrawable.h:58
bool sharpnessProfileEnable
Definition: DtHbaoDrawable.h:63
osg::observer_ptr< const osg::GraphicsContext > myInitGraphicsContext
Definition: DtHbaoDrawable.h:178
A helper classes for creating a RTT target, optionally including depth buffer.
Definition: DtGlRenderToTexture.h:47
HbaoParameters myMutableParameters
Definition: DtHbaoDrawable.h:184
float depthThresholdMaxViewDepth
Definition: DtHbaoDrawable.h:80
2 dimensional vector
bool myMutableShadersDirtyFlag
Definition: DtHbaoDrawable.h:188
float largeScaleAo
Definition: DtHbaoDrawable.h:69
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
osg::ref_ptr< osg::Texture > myBaseTexture
Definition: DtHbaoDrawable.h:158
int blurRadius
Definition: DtHbaoDrawable.h:60
A convenience class to represent an OpenGL Shader Program.
Definition: DtGlProgram.h:65
bool myShadingRateIsSupported
Definition: DtHbaoDrawable.h:165
float smallScaleAo
Definition: DtHbaoDrawable.h:68
int depthStorage
Definition: DtHbaoDrawable.h:77
bool depthThresholdEnable
Definition: DtHbaoDrawable.h:79
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
osg::ref_ptr< osg::Texture > myDepthTexture
Definition: DtHbaoDrawable.h:159
bool myMutableTapsDirty
are the taps needed to be re-sent to the GPU
Definition: DtHbaoDrawable.h:176
class used to render HBAO during the post processor camera draw. Uses the NVIDIA GFSDK HBAO library t...
Definition: DtHbaoDrawable.h:89
Definition: DtPostProcessorDrawable.h:24
struct for holding all the hbao paramters used by this drawable. Some are modified by the qt gui in t...
Definition: DtHbaoDrawable.h:49
bool backgroundAoEnable
Definition: DtHbaoDrawable.h:73
DtVirtualBaseClassCreator< DtHbaoDrawable > DtHbaoDrawableCreator
Definition: DtHbaoDrawable.h:40
friend DtHbaoDrawableCreator
friended, to access constructor above
Definition: DtHbaoDrawable.h:109
osg::ref_ptr< osg::Texture > myOcclusionTex
Definition: DtHbaoDrawable.h:160
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
float foregroundAoDepth
Definition: DtHbaoDrawable.h:72
int viewWidth
Definition: DtHbaoDrawable.h:53
#define DT_DLL_VRVPOSTPROCESSOR
Definition: vrvPostProcessor.h:19
This file contains the declaration of the class DtPostProcessorDrawable which is used for rendering p...
float sharpnessProfileScale
Definition: DtHbaoDrawable.h:64
Contains DLL export macros.
float radius
Definition: DtHbaoDrawable.h:56
int myMutableVrvOcclusionTexLoc
Definition: DtHbaoDrawable.h:172
GLuint myDepthTextureId
texture views used for multiview
Definition: DtHbaoDrawable.h:163
bool foregroundAoEnable
Definition: DtHbaoDrawable.h:71
Base class to provide boost signal/slot management.
int viewHeight
Definition: DtHbaoDrawable.h:54
const char * creatorTypeName< DtHbaoDrawable >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtHbaoDrawable.h:45
float bias
Definition: DtHbaoDrawable.h:57
DtGlRenderTexture * myMutableHbaoTexture
Definition: DtHbaoDrawable.h:179
std::vector< GLuint > myDepthTexViews
Definition: DtHbaoDrawable.h:164
int depthClampMode
Definition: DtHbaoDrawable.h:78
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
DtGlProgram * myMutableHbaoProgram
the program
Definition: DtHbaoDrawable.h:168
float sharpnessProfileForegroundViewDepth
Definition: DtHbaoDrawable.h:65
float blurSharpness
Definition: DtHbaoDrawable.h:61
bool blurEnable
Definition: DtHbaoDrawable.h:59
int myMutableVrvSsaoTexLoc
locations of various shader parameters
Definition: DtHbaoDrawable.h:171
float backgroundAoDepth
Definition: DtHbaoDrawable.h:74
GFSDK_SSAO_Context_GL * myMutableSsaoContextGl
Definition: DtHbaoDrawable.h:181

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)