File indexing completed on 2025-01-18 10:04:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef OpenGl_ShaderStates_HeaderFile
0017 #define OpenGl_ShaderStates_HeaderFile
0018
0019 #include <Graphic3d_RenderTransparentMethod.hxx>
0020 #include <Graphic3d_LightSet.hxx>
0021 #include <OpenGl_Element.hxx>
0022 #include <OpenGl_Vec.hxx>
0023
0024 class OpenGl_ShadowMapArray;
0025
0026
0027 class OpenGl_StateInterface
0028 {
0029 public:
0030
0031
0032 Standard_EXPORT OpenGl_StateInterface();
0033
0034
0035 Standard_Size Index() const { return myIndex; }
0036
0037
0038 void Update() { ++myIndex; }
0039
0040 protected:
0041
0042 Standard_Size myIndex;
0043
0044 };
0045
0046
0047 class OpenGl_ProjectionState : public OpenGl_StateInterface
0048 {
0049 public:
0050
0051
0052 Standard_EXPORT OpenGl_ProjectionState();
0053
0054
0055 Standard_EXPORT void Set (const OpenGl_Mat4& theProjectionMatrix);
0056
0057
0058 const OpenGl_Mat4& ProjectionMatrix() const { return myProjectionMatrix; }
0059
0060
0061 Standard_EXPORT const OpenGl_Mat4& ProjectionMatrixInverse() const;
0062
0063 private:
0064
0065 OpenGl_Mat4 myProjectionMatrix;
0066 mutable OpenGl_Mat4 myProjectionMatrixInverse;
0067 mutable bool myInverseNeedUpdate;
0068
0069 };
0070
0071
0072 class OpenGl_ModelWorldState : public OpenGl_StateInterface
0073 {
0074 public:
0075
0076
0077 Standard_EXPORT OpenGl_ModelWorldState();
0078
0079
0080 Standard_EXPORT void Set (const OpenGl_Mat4& theModelWorldMatrix);
0081
0082
0083 const OpenGl_Mat4& ModelWorldMatrix() const { return myModelWorldMatrix; }
0084
0085
0086 Standard_EXPORT const OpenGl_Mat4& ModelWorldMatrixInverse() const;
0087
0088 private:
0089
0090 OpenGl_Mat4 myModelWorldMatrix;
0091 mutable OpenGl_Mat4 myModelWorldMatrixInverse;
0092 mutable bool myInverseNeedUpdate;
0093
0094 };
0095
0096
0097 class OpenGl_WorldViewState : public OpenGl_StateInterface
0098 {
0099 public:
0100
0101
0102 Standard_EXPORT OpenGl_WorldViewState();
0103
0104
0105 Standard_EXPORT void Set (const OpenGl_Mat4& theWorldViewMatrix);
0106
0107
0108 const OpenGl_Mat4& WorldViewMatrix() const { return myWorldViewMatrix; }
0109
0110
0111 Standard_EXPORT const OpenGl_Mat4& WorldViewMatrixInverse() const;
0112
0113 private:
0114
0115 OpenGl_Mat4 myWorldViewMatrix;
0116 mutable OpenGl_Mat4 myWorldViewMatrixInverse;
0117 mutable bool myInverseNeedUpdate;
0118
0119 };
0120
0121
0122 class OpenGl_LightSourceState : public OpenGl_StateInterface
0123 {
0124 public:
0125
0126
0127 OpenGl_LightSourceState() : mySpecIBLMapLevels (0), myToCastShadows (Standard_True) {}
0128
0129
0130 void Set (const Handle(Graphic3d_LightSet)& theLightSources) { myLightSources = theLightSources; }
0131
0132
0133 const Handle(Graphic3d_LightSet)& LightSources() const { return myLightSources; }
0134
0135
0136
0137 Standard_Integer SpecIBLMapLevels() const { return mySpecIBLMapLevels; }
0138
0139
0140 void SetSpecIBLMapLevels(Standard_Integer theSpecIBLMapLevels) { mySpecIBLMapLevels = theSpecIBLMapLevels; }
0141
0142
0143 bool HasShadowMaps() const { return myToCastShadows && !myShadowMaps.IsNull(); }
0144
0145
0146 const Handle(OpenGl_ShadowMapArray)& ShadowMaps() const { return myShadowMaps; }
0147
0148
0149 void SetShadowMaps (const Handle(OpenGl_ShadowMapArray)& theMap) { myShadowMaps = theMap; }
0150
0151
0152 bool ToCastShadows() const { return myToCastShadows; }
0153
0154
0155 void SetCastShadows (bool theToCast) { myToCastShadows = theToCast; }
0156
0157 private:
0158
0159 Handle(Graphic3d_LightSet) myLightSources;
0160 Standard_Integer mySpecIBLMapLevels;
0161 Handle(OpenGl_ShadowMapArray) myShadowMaps;
0162 Standard_Boolean myToCastShadows;
0163
0164 };
0165
0166
0167 class OpenGl_ClippingState
0168 {
0169 public:
0170
0171
0172 Standard_EXPORT OpenGl_ClippingState();
0173
0174
0175 Standard_Size Index() const { return myIndex; }
0176
0177
0178 Standard_EXPORT void Update();
0179
0180
0181 Standard_EXPORT void Revert();
0182
0183 protected:
0184
0185 Standard_Size myIndex;
0186 Standard_Size myNextIndex;
0187 NCollection_List<Standard_Size> myStateStack;
0188
0189 };
0190
0191
0192 class OpenGl_OitState : public OpenGl_StateInterface
0193 {
0194 public:
0195
0196
0197 OpenGl_OitState() : myOitMode (Graphic3d_RTM_BLEND_UNORDERED), myDepthFactor (0.5f) {}
0198
0199
0200
0201
0202
0203
0204 void Set (Graphic3d_RenderTransparentMethod theMode,
0205 const float theDepthFactor)
0206 {
0207 myOitMode = theMode;
0208 myDepthFactor = static_cast<float> (Max (0.f, Min (1.f, theDepthFactor)));
0209 }
0210
0211
0212
0213 Graphic3d_RenderTransparentMethod ActiveMode() const { return myOitMode; }
0214
0215
0216
0217 float DepthFactor() const { return myDepthFactor; }
0218
0219 private:
0220
0221 Graphic3d_RenderTransparentMethod myOitMode;
0222 float myDepthFactor;
0223 };
0224
0225 #endif