VAPOR3 3.9.4
VolumeOSPRay.h
Go to the documentation of this file.
1#pragma once
2
4#include <vapor/Texture.h>
5#include <vapor/OSPRay.h>
6
7namespace VAPoR {
8
17
18#ifdef BUILD_OSPRAY
19class RENDER_API VolumeOSPRay : public VolumeAlgorithm {
20public:
21 enum WindingOrder { CCW, CW, INVALID };
22
23 VolumeOSPRay(GLManager *gl, VolumeRenderer *renderer);
24 ~VolumeOSPRay();
25
26 static std::string GetName();
27 static Type GetType() { return Type::DVR; }
28 virtual bool RequiresChunkedRendering() { return false; }
29
30 virtual void SaveDepthBuffer(bool fast);
31 virtual int Render(bool fast);
32 virtual int LoadData(const Grid *grid);
33 virtual int LoadSecondaryData(const Grid *grid) { return 0; }
34 virtual void DeleteSecondaryData() {}
35 virtual ShaderProgram *GetShader() const;
36 virtual void SetUniforms(const ShaderProgram *shader) const;
37 virtual float GuestimateFastModeSpeedupFactor() const;
38 virtual void GetFinalBlendingMode(int *src, int *dst);
39
40protected:
41 virtual bool _isIso() const { return false; }
42
43private:
44 std::vector<size_t> _dataDimensions;
45 std::vector<float> _depthData;
46 std::vector<unsigned char> _backplateData;
47 Texture2D _ospRenderTexture;
48 Texture2D _ospWriteDepthTexture;
49 struct {
50 glm::vec3 min, max;
51 } _clipBox = {glm::vec3(0), glm::vec3(1)};
52 float _ospSampleRateScalar;
53
54 struct {
55 bool usePT;
56 } _cache;
57
58 OSPRenderer _ospRenderer = nullptr;
59 OSPWorld _ospWorld = nullptr;
60 OSPCamera _ospCamera = nullptr;
61 OSPTransferFunction _ospTF = nullptr;
62 OSPInstance _ospInstance = nullptr;
63 OSPVolumetricModel _ospVolumeModel = nullptr;
64 OSPLight _ospLightAmbient = nullptr;
65 OSPLight _ospLightDistant = nullptr;
66 OSPGeometry _ospIso = nullptr;
67 OSPGeometricModel _ospIsoModel = nullptr;
68
69 void _setupRenderer(bool fast);
70 void _setupCamera();
71 void _setupIso();
72 void _loadTF();
73 void _applyTransform();
74 void _copyDepth();
75 void _copyBackplate();
76
77 float _guessSamplingRateScalar(const Grid *grid) const;
78 OSPVolume _loadVolumeRegular(const Grid *grid);
79 OSPVolume _loadVolumeStructured(const Grid *grid);
80 OSPVolume _loadVolumeUnstructured(const Grid *grid);
81 OSPVolume _loadVolumeTest(const Grid *grid);
82
83 static WindingOrder getWindingOrderRespectToZ(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c);
84 static WindingOrder getWindingOrderTetra(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c, const glm::vec3 &d);
85 static const char * windingOrderToString(WindingOrder o);
86 static bool isQuadCoPlanar(const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c, const glm::vec3 &d);
87};
88#else
90public:
91 VolumeOSPRay(GLManager *gl, VolumeRenderer *renderer) : VolumeAlgorithm(gl, renderer) {}
92
93 static std::string GetName() { return "OSPRay"; }
94};
95#endif
96
103
105public:
106 VolumeOSPRayIso(GLManager *gl, VolumeRenderer *renderer) : VolumeOSPRay(gl, renderer) {}
107 static std::string GetName() { return "Iso OSPRay (experimental)"; }
108 static Type GetType() { return Type::Iso; }
109
110protected:
111 bool _isIso() const { return true; }
112};
113
114} // namespace VAPoR
Strategy pattern for volume rendering algorithms.
OSPRay isosurface rendering adapter.
Definition: VolumeOSPRay.h:104
static std::string GetName()
Definition: VolumeOSPRay.h:107
VolumeOSPRayIso(GLManager *gl, VolumeRenderer *renderer)
Definition: VolumeOSPRay.h:106
static Type GetType()
Definition: VolumeOSPRay.h:108
OSPRay volume rendering adapter.
Definition: VolumeOSPRay.h:89
static std::string GetName()
Definition: VolumeOSPRay.h:93
VolumeOSPRay(GLManager *gl, VolumeRenderer *renderer)
Definition: VolumeOSPRay.h:91
#define RENDER_API
Definition: common.h:78
Contains references to context scope OpenGL data.
Definition: GLManager.h:18