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