VR-Forces 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) 2023 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
6 #pragma once
7 
11 
14 
16 
17 #include <vrvMath/DtVector2.h>
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  class DtNvidiaHbaoGlObject;
40 
43 
45  template <>
46  inline const char* creatorTypeName<DtHbaoDrawable>(void) { return "DtHbaoDrawableCreator"; }
47 
51  {
52  public:
53 
54  int viewWidth = 0;
55  int viewHeight = 0;
56 
57  float radius = 2.0f; // The AO radius in meters
58  float bias = 0.1f; // To hide low-tessellation artifacts // 0.0~0.5
59  float exponent = 2.0f; // The final AO output is pow(AO, powerExponent) // 1.0~4.0
60  bool blurEnable = true; // To blur the AO with an edge-preserving blur
61  int blurRadius = GFSDK_SSAO_BLUR_RADIUS_4; // BLUR_RADIUS_2 or BLUR_RADIUS_4
62  float blurSharpness = 4.0f; // The higher, the more the blur preserves edges // 0.0~16.0
63 
64  bool sharpnessProfileEnable = false; // To make the blur sharper in the foreground
65  float sharpnessProfileScale = 4.0f; // Sharpness scale factor for ViewDepths <= ForegroundViewDepth
66  float sharpnessProfileForegroundViewDepth = 0.0; // Maximum view depth of the foreground depth range
67  float sharpnessProfileBackgroundViewDepth = 1.0; // Minimum view depth of the background depth range
68 
69  float smallScaleAo = 1.0f; // Scale factor for the small-scale AO, the greater the darker // 0.0~2.0
70  float largeScaleAo = 1.0f; // Scale factor for the large-scale AO, the greater the darker // 0.0~2.0
71 
72  bool foregroundAoEnable = false; // To limit the occlusion scale in the foreground
73  float foregroundAoDepth = 0.0f;// View-space depth at which the AO footprint should get clamped
74  bool backgroundAoEnable = false; // To add larger-scale occlusion in the distance
75  float backgroundAoDepth = 0.0f; // View-space depth at which the AO footprint should stop falling off with depth
76 
77  //Depth storage needs to be 32-bit so that zoomed in views work.
78  int depthStorage = GFSDK_SSAO_FP32_VIEW_DEPTHS; // Quality / performance tradeoff
79  int depthClampMode = GFSDK_SSAO_CLAMP_TO_EDGE; // To hide possible false-occlusion artifacts near screen borders
80  bool depthThresholdEnable = false; // To return white AO for ViewDepths > MaxViewDepth
81  float depthThresholdMaxViewDepth = 0.0f; // Custom view-depth threshold
82  float depthThresholdSharpness = 100.0f; // The higher, the sharper are the AO-to-white transitions
83 
84  };
85 
91  {
92  public:
94  virtual ~DtHbaoDrawable();
95 
97  DtHbaoDrawable() = delete;
98 
100  DtHbaoDrawable(const DtHbaoDrawable&) = delete;
101 
103  DtHbaoDrawable& operator=(const DtHbaoDrawable&) = delete;
104 
105  protected:
107  DtHbaoDrawable(DtDe &de);
108 
111 
112  public:
114  virtual void drawImplementation(osg::RenderInfo& renderInfo) const override;
115 
117  virtual void reloadShaders();
118 
123  //virtual void releaseGLObjects(osg::State* state = 0) const;
124 
126  virtual void setDepthTexture(osg::Texture* texture);
127 
129  virtual void setBaseTexture(osg::Texture* texture);
130 
132  virtual void setOcclusionTexture(osg::Texture* inputTex);
133 
135  virtual void setViewSize(int width, int height);
136 
137  protected:
138 
140  virtual void createProgramIfNecessary(void) const;
141 
143  virtual void cleanupGpuMemory(void);
144 
146  virtual void releaseHbaoRenderTexture();
147 
152  void updateHbaoSettings() const;
153 
155  void createTextureViewsIfNecessary(osg::State* state) const;
156 
157  protected:
158 
162 
165  mutable std::vector<GLuint> myDepthTexViews;
167 
170 
174 
177  mutable bool myMutableTapsDirty;
178 
179  mutable osg::observer_ptr<const osg::GraphicsContext> myInitGraphicsContext;
181 
182  mutable DtNvidiaHbaoGlObject* myNvidiaHbaoResources = nullptr;
183 
185 
187 
189  };
190 }
float sharpnessProfileBackgroundViewDepth
Definition: DtHbaoDrawable.h:67
DtSignalConnectionManager myMutableConnections
Definition: DtHbaoDrawable.h:186
float depthThresholdSharpness
Definition: DtHbaoDrawable.h:82
float exponent
Definition: DtHbaoDrawable.h:59
bool sharpnessProfileEnable
Definition: DtHbaoDrawable.h:64
osg::observer_ptr< const osg::GraphicsContext > myInitGraphicsContext
Definition: DtHbaoDrawable.h:179
A helper classes for creating a RTT target, optionally including depth buffer.
Definition: DtGlRenderToTexture.h:46
HbaoParameters myMutableParameters
Definition: DtHbaoDrawable.h:184
float depthThresholdMaxViewDepth
Definition: DtHbaoDrawable.h:81
2 dimensional vector
bool myMutableShadersDirtyFlag
Definition: DtHbaoDrawable.h:188
float largeScaleAo
Definition: DtHbaoDrawable.h:70
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:18
osg::ref_ptr< osg::Texture > myBaseTexture
Definition: DtHbaoDrawable.h:159
int blurRadius
Definition: DtHbaoDrawable.h:61
A convenience class to represent an OpenGL Shader Program.
Definition: DtGlProgram.h:66
bool myShadingRateIsSupported
Definition: DtHbaoDrawable.h:166
float smallScaleAo
Definition: DtHbaoDrawable.h:69
int depthStorage
Definition: DtHbaoDrawable.h:78
bool depthThresholdEnable
Definition: DtHbaoDrawable.h:80
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:160
bool myMutableTapsDirty
are the taps needed to be re-sent to the GPU
Definition: DtHbaoDrawable.h:177
class used to render HBAO during the post processor camera draw. Uses the NVIDIA GFSDK HBAO library t...
Definition: DtHbaoDrawable.h:90
Definition: DtPostProcessorDrawable.h:33
struct for holding all the hbao paramters used by this drawable. Some are modified by the qt gui in t...
Definition: DtHbaoDrawable.h:50
bool backgroundAoEnable
Definition: DtHbaoDrawable.h:74
DtVirtualBaseClassCreator< DtHbaoDrawable > DtHbaoDrawableCreator
Definition: DtHbaoDrawable.h:41
friend DtHbaoDrawableCreator
friended, to access constructor above
Definition: DtHbaoDrawable.h:110
osg::ref_ptr< osg::Texture > myOcclusionTex
Definition: DtHbaoDrawable.h:161
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
float foregroundAoDepth
Definition: DtHbaoDrawable.h:73
int viewWidth
Definition: DtHbaoDrawable.h:54
#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:65
Contains DLL export macros.
float radius
Definition: DtHbaoDrawable.h:57
int myMutableVrvOcclusionTexLoc
Definition: DtHbaoDrawable.h:173
GLuint myDepthTextureId
texture views used for multiview
Definition: DtHbaoDrawable.h:164
bool foregroundAoEnable
Definition: DtHbaoDrawable.h:72
Base class to provide boost signal/slot management.
int viewHeight
Definition: DtHbaoDrawable.h:55
const char * creatorTypeName< DtHbaoDrawable >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtHbaoDrawable.h:46
float bias
Definition: DtHbaoDrawable.h:58
DtGlRenderTexture * myMutableHbaoTexture
Definition: DtHbaoDrawable.h:180
std::vector< GLuint > myDepthTexViews
Definition: DtHbaoDrawable.h:165
int depthClampMode
Definition: DtHbaoDrawable.h:79
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:72
DtGlProgram * myMutableHbaoProgram
the program
Definition: DtHbaoDrawable.h:169
float sharpnessProfileForegroundViewDepth
Definition: DtHbaoDrawable.h:66
float blurSharpness
Definition: DtHbaoDrawable.h:62
bool blurEnable
Definition: DtHbaoDrawable.h:60
int myMutableVrvSsaoTexLoc
locations of various shader parameters
Definition: DtHbaoDrawable.h:172
float backgroundAoDepth
Definition: DtHbaoDrawable.h:75

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)