source: nanovis/branches/1.1/RegularVolumeShader.cpp @ 4889

Last change on this file since 4889 was 4889, checked in by ldelgass, 5 years ago

Merge r3611:3618 from trunk

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
4 *
5 */
6#include "RegularVolumeShader.h"
7
8using namespace nv;
9
10RegularVolumeShader::RegularVolumeShader()
11{
12    init();
13}
14
15RegularVolumeShader::~RegularVolumeShader()
16{
17}
18
19void RegularVolumeShader::init()
20{
21    loadFragmentProgram("one_volume.cg", "main");
22}
23
24void RegularVolumeShader::bind(unsigned int tfID, Volume *volume,
25                                 int sliceMode, float sampleRatio)
26{
27    //regular cubic volume
28    setGLStateMatrixFPParameter("modelViewInv", MODELVIEW_MATRIX,
29                                MATRIX_INVERSE);
30    setGLStateMatrixFPParameter("modelView", MODELVIEW_MATRIX,
31                                MATRIX_IDENTITY);
32
33    setFPTextureParameter("volume", volume->textureID());
34    setFPTextureParameter("tf", tfID);
35
36    setFPParameter4f("material",
37                     volume->ambient(),
38                     volume->diffuse(),
39                     volume->specularLevel(),
40                     volume->specularExponent());
41
42    setFPParameter4f("renderParams",
43                     (sliceMode ? 0.0f : sampleRatio),
44                     volume->isosurface(),
45                     volume->opacityScale(),
46                     (volume->twoSidedLighting() ? 1.0f : 0.0f));
47
48    Shader:: bind();
49}
50
51void RegularVolumeShader::unbind()
52{
53    disableFPTextureParameter("volume");
54    disableFPTextureParameter("tf");
55
56    Shader::unbind();
57}
Note: See TracBrowser for help on using the repository browser.