-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVolumeRenderer.h
121 lines (98 loc) · 2.82 KB
/
VolumeRenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class VolumeRenderer
{
public:
/*
* Constructor
*/
VolumeRenderer(ID3DX11Effect* pEffect);
/*
* Destructor
*/
~VolumeRenderer();
/*
* Initialize volumerenderer
* - shader variables
* - index buffer and layout of the bounding box
*/
HRESULT Initialize();
/*
* Update stepsize and iterations according to the texture size
*/
HRESULT Update(int iWidth, int iHeight, int iDepth);
/*
* Update screen size
*/
HRESULT SetScreenSize(int iWidth, int iHeight);
/*
* Switch between nearest neighbour and linear sampling
*/
void ChangeSampling();
/*
* Switch between settings for "normal" volume rendering and isosurface rendering
*/
void ShowIsoSurface(bool bShow);
/*
* Controls the visibility of the bounding box
*/
void ShowBoundingBox(bool bShow);
/*
* Render a given 3D Texture into the bounding box
*/
void Render(SURFACE_VERTEX* pBBVertices,
D3DXVECTOR3 vBBMin,
D3DXVECTOR3 vBBMax,
D3DXMATRIX mWorldViewProjection,
const unsigned int n3DTexture);
private:
//true, if linear sampling, false if nearest neighbor
bool m_bLinearSampling;
//controls the setting when isosurface is rendered
bool m_bShowIsoSurface;
//controls the visibility of the bounding box
bool m_bShowBoundingBox;
// Shader effect and variables
ID3DX11Effect* m_pEffect;
ID3DX11EffectTechnique* m_pVolumeRenderTechnique;
ID3DX11EffectMatrixVariable* m_pWorldViewProjectionVar;
ID3DX11EffectShaderResourceVariable* m_pFrontTextureVar;
ID3DX11EffectShaderResourceVariable* m_pBackTextureVar;
ID3DX11EffectShaderResourceVariable* m_pVolumeTextureVar;
ID3DX11EffectVectorVariable* m_pStepSizeVar;
ID3DX11EffectVectorVariable* m_pBBMinVar;
ID3DX11EffectVectorVariable* m_pBBMaxVar;
ID3DX11EffectScalarVariable* m_pIterationsVar;
ID3DX11EffectScalarVariable* m_fAlphaVar;
ID3DX11EffectScalarVariable* m_pSamplingVar;
ID3DX11EffectScalarVariable* m_pShowIsoSurfaceVar;
//Screen size
int m_iWidth;
int m_iHeight;
//Bounding Box
ID3D11Buffer* m_pBBVertexBuffer;
ID3D11Buffer* m_pBBIndexBuffer;
ID3D11InputLayout* m_pBBInputLayout;
//front and back textures of the bounding box
ID3D11Texture2D* m_pFrontTexture2D;
ID3D11RenderTargetView* m_pFrontRTV;
ID3D11ShaderResourceView* m_pFrontSRV;
ID3D11Texture2D* m_pBackTexture2D;
ID3D11RenderTargetView* m_pBackRTV;
ID3D11ShaderResourceView* m_pBackSRV;
//Screen Quad
ID3D11Buffer* m_pSQVertexBuffer;
ID3D11InputLayout* m_pSQInputLayout;
/*
* Initializing functions
*/
HRESULT InitShader();
HRESULT InitBoundingIndicesAndLayout();
HRESULT UpdateBoundingVertices(SURFACE_VERTEX* BBVertices);
/*
* Gets called when:
* 1. Draw front face of bounding box
* 2. Draw back face of bounding box
* 3. Raycast
* 4. Draw wireframe bounding box
*/
void DrawBoundingBox();
};