1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | */ |
---|
6 | |
---|
7 | #include "ZincBlendeVolumeShader.h" |
---|
8 | #include "ZincBlendeVolume.h" |
---|
9 | |
---|
10 | using namespace nv; |
---|
11 | |
---|
12 | ZincBlendeVolumeShader::ZincBlendeVolumeShader() |
---|
13 | { |
---|
14 | init(); |
---|
15 | } |
---|
16 | |
---|
17 | ZincBlendeVolumeShader::~ZincBlendeVolumeShader() |
---|
18 | { |
---|
19 | } |
---|
20 | |
---|
21 | void ZincBlendeVolumeShader::init() |
---|
22 | { |
---|
23 | loadFragmentProgram("zincblende_volume.cg"); |
---|
24 | } |
---|
25 | |
---|
26 | void ZincBlendeVolumeShader::bind(unsigned int tfID, Volume *volume, |
---|
27 | int sliceMode, float sampleRatio) |
---|
28 | { |
---|
29 | ZincBlendeVolume *vol = (ZincBlendeVolume *)volume; |
---|
30 | setGLStateMatrixFPParameter("modelViewInv", MODELVIEW_MATRIX, |
---|
31 | MATRIX_INVERSE); |
---|
32 | |
---|
33 | setFPTextureParameter("tf", tfID); |
---|
34 | setFPTextureParameter("volumeA", vol->zincblendeTex[0]->id()); |
---|
35 | setFPTextureParameter("volumeB", vol->zincblendeTex[1]->id()); |
---|
36 | |
---|
37 | setFPParameter4f("cellSize", |
---|
38 | vol->cellSize.x, |
---|
39 | vol->cellSize.y, |
---|
40 | vol->cellSize.z, 0.); |
---|
41 | |
---|
42 | setFPParameter4f("renderParams", |
---|
43 | (sliceMode ? 0.0f : sampleRatio), |
---|
44 | volume->isosurface(), |
---|
45 | volume->opacityScale(), |
---|
46 | 0.0f); |
---|
47 | |
---|
48 | Shader::bind(); |
---|
49 | } |
---|
50 | |
---|
51 | void ZincBlendeVolumeShader::unbind() |
---|
52 | { |
---|
53 | disableFPTextureParameter("tf"); |
---|
54 | disableFPTextureParameter("volumeA"); |
---|
55 | disableFPTextureParameter("volumeB"); |
---|
56 | |
---|
57 | Shader::unbind(); |
---|
58 | } |
---|