1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | #ifndef __NV_ZINCBLENDE_SHADER_H__ |
---|
3 | #define __NV_ZINCBLENDE_SHADER_H__ |
---|
4 | |
---|
5 | #include "ZincBlendeVolume.h" |
---|
6 | #include "NvVolumeShader.h" |
---|
7 | |
---|
8 | class NvZincBlendeVolumeShader : public NvVolumeShader { |
---|
9 | CGparameter _tfParam; |
---|
10 | CGparameter _volumeAParam; |
---|
11 | CGparameter _volumeBParam; |
---|
12 | CGparameter _cellSizeParam; |
---|
13 | CGparameter _mviParam; |
---|
14 | CGparameter _renderParam; |
---|
15 | CGparameter _option_one_volume_param; |
---|
16 | |
---|
17 | private : |
---|
18 | void init(); |
---|
19 | public : |
---|
20 | NvZincBlendeVolumeShader(); |
---|
21 | ~NvZincBlendeVolumeShader(); |
---|
22 | |
---|
23 | void bind(unsigned int tfID, Volume* volume, int sliceMode); |
---|
24 | void unbind(); |
---|
25 | }; |
---|
26 | |
---|
27 | inline void NvZincBlendeVolumeShader::bind(unsigned int tfID, Volume* volume, int sliceMode) |
---|
28 | { |
---|
29 | ZincBlendeVolume* vol = (ZincBlendeVolume*)volume; |
---|
30 | cgGLSetStateMatrixParameter(_mviParam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE); |
---|
31 | cgGLSetTextureParameter(_tfParam, tfID); |
---|
32 | cgGLSetParameter4f(_cellSizeParam, vol->cell_size.x, vol->cell_size.y, vol->cell_size.z, 0.); |
---|
33 | |
---|
34 | if(!sliceMode) |
---|
35 | cgGLSetParameter4f(_renderParam, |
---|
36 | vol->n_slices(), |
---|
37 | vol->opacity_scale(), |
---|
38 | vol->diffuse(), |
---|
39 | vol->specular()); |
---|
40 | else |
---|
41 | cgGLSetParameter4f(_renderParam, |
---|
42 | 0., |
---|
43 | vol->opacity_scale(), |
---|
44 | vol->diffuse(), |
---|
45 | vol->specular()); |
---|
46 | |
---|
47 | cgGLSetParameter4f(_option_one_volume_param, |
---|
48 | 0.0f, |
---|
49 | volume->isosurface(), |
---|
50 | 0.0f, |
---|
51 | 0.0f); |
---|
52 | |
---|
53 | cgGLSetTextureParameter(_volumeAParam, vol->zincblende_tex[0]->id); |
---|
54 | cgGLSetTextureParameter(_volumeBParam, vol->zincblende_tex[1]->id); |
---|
55 | cgGLEnableTextureParameter(_volumeAParam); |
---|
56 | cgGLEnableTextureParameter(_volumeBParam); |
---|
57 | |
---|
58 | cgGLBindProgram(_cgFP); |
---|
59 | cgGLEnableProfile(CG_PROFILE_FP30); |
---|
60 | } |
---|
61 | |
---|
62 | inline void NvZincBlendeVolumeShader::unbind() |
---|
63 | { |
---|
64 | cgGLDisableTextureParameter(_volumeAParam); |
---|
65 | cgGLDisableTextureParameter(_volumeBParam); |
---|
66 | cgGLDisableTextureParameter(_tfParam); |
---|
67 | |
---|
68 | cgGLDisableProfile(CG_PROFILE_FP30); |
---|
69 | } |
---|
70 | |
---|
71 | #endif |
---|