Index: /trunk/packages/vizservers/nanovis/ColorTableShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/ColorTableShader.cpp	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/ColorTableShader.cpp	(revision 3612)
@@ -0,0 +1,40 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#include "ColorTableShader.h"
+
+using namespace nv;
+
+ColorTableShader::ColorTableShader()
+{
+    init();
+}
+
+ColorTableShader::~ColorTableShader()
+{
+}
+
+void ColorTableShader::init()
+{
+    loadFragmentProgram("one_plane.cg", "main"); 
+}
+
+void ColorTableShader::bind(Texture2D *plane, TransferFunction *tf)
+{
+    setFPTextureParameter("data", plane->id());
+    setFPTextureParameter("tf", tf->id());
+
+    setFPParameter4f("render_param", 0., 0., 0., 0.);
+
+    Shader::bind();
+}
+
+void ColorTableShader::unbind()
+{
+    disableFPTextureParameter("data");
+    disableFPTextureParameter("tf");
+
+    Shader::unbind();
+}
Index: /trunk/packages/vizservers/nanovis/ColorTableShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/ColorTableShader.h	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/ColorTableShader.h	(revision 3612)
@@ -0,0 +1,32 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#ifndef NV_COLORTABLE_SHADER_H
+#define NV_COLORTABLE_SHADER_H
+
+#include "Shader.h"
+#include "Texture2D.h"
+#include "TransferFunction.h"
+
+namespace nv {
+
+class ColorTableShader : public Shader
+{
+public:
+    ColorTableShader();
+
+    virtual ~ColorTableShader();
+
+    virtual void bind(Texture2D *plane, TransferFunction *tf);
+
+    virtual void unbind();
+
+private :
+    void init();
+};
+
+}
+
+#endif 
Index: /trunk/packages/vizservers/nanovis/HeightMap.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/HeightMap.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/HeightMap.cpp	(revision 3612)
@@ -39,5 +39,5 @@
     _heights(NULL)
 {
-    _shader = new NvShader();
+    _shader = new Shader();
     _shader->loadFragmentProgram("heightcolor.cg", "main");
 }
Index: /trunk/packages/vizservers/nanovis/HeightMap.h
===================================================================
--- /trunk/packages/vizservers/nanovis/HeightMap.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/HeightMap.h	(revision 3612)
@@ -12,5 +12,5 @@
 
 #include "TransferFunction.h"
-#include "NvShader.h"
+#include "Shader.h"
 #include "AxisRange.h"
 
@@ -132,5 +132,5 @@
     TransferFunction *_transferFunc;
     float _opacity;
-    NvShader *_shader;
+    Shader *_shader;
     int *_indexBuffer;
     int _indexCount;
Index: /trunk/packages/vizservers/nanovis/LIC.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/LIC.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/LIC.cpp	(revision 3612)
@@ -1,16 +1,8 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
- * ----------------------------------------------------------------------
- * NvLIC.h: line integral convolution class
- *
- * ======================================================================
- *  AUTHOR:  Insoo Woo <iwoo@purdue.edu, Wei Qiao <qiaow@purdue.edu>
- *           Purdue Rendering and Perceptualization Lab (PURPL)
- *
  *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
  *
- *  See the file "license.terms" for information on usage and
- *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- * ======================================================================
+ *  Authors:
+ *    Wei Qiao <qiaow@purdue.edu>
  */
 #include <stdlib.h>
@@ -22,5 +14,5 @@
 
 #include "LIC.h"
-#include "NvShader.h"
+#include "Shader.h"
 #include "Trace.h"
 
@@ -111,5 +103,5 @@
     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
 
-    _renderVelShader = new NvShader();
+    _renderVelShader = new Shader();
     _renderVelShader->loadFragmentProgram("render_vel.cg", "main");
 
Index: /trunk/packages/vizservers/nanovis/LIC.h
===================================================================
--- /trunk/packages/vizservers/nanovis/LIC.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/LIC.h	(revision 3612)
@@ -1,16 +1,8 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
- * ----------------------------------------------------------------------
- * NvLIC.h: line integral convolution class
- *
- * ======================================================================
- *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
- *           Purdue Rendering and Perceptualization Lab (PURPL)
- *
  *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
  *
- *  See the file "license.terms" for information on usage and
- *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- * ======================================================================
+ *  Authors:
+ *    Wei Qiao <qiaow@purdue.edu>
  */
 #ifndef NV_LIC_H
@@ -22,5 +14,5 @@
 
 #include "Volume.h"
-#include "NvShader.h"
+#include "Shader.h"
 
 namespace nv {
@@ -84,5 +76,5 @@
 private:
     /**
-     * @brief the normal vector of the NvLIC plane, 
+     * @brief the normal vector of the LIC plane, 
      * the inherited Vector3 location is its center
      */
@@ -111,5 +103,5 @@
     GLuint _disListID;
 
-    NvShader *_renderVelShader;
+    Shader *_renderVelShader;
 
     GLuint _colorTex, _patternTex, _magTex;
Index: /trunk/packages/vizservers/nanovis/Makefile.in
===================================================================
--- /trunk/packages/vizservers/nanovis/Makefile.in	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/Makefile.in	(revision 3612)
@@ -111,4 +111,5 @@
 		Chain.o \
 		CmdProc.o \
+		ColorTableShader.o \
 		Command.o \
 		ContourLineFilter.o \
@@ -122,12 +123,6 @@
 		HeightMap.o \
 		LIC.o \
-		NvColorTableShader.o \
-		NvParticleAdvectionShader.o \
-		NvRegularVolumeShader.o \
-		NvShader.o \
-		NvStdVertexShader.o \
-		NvVolumeShader.o \
-		NvZincBlendeVolumeShader.o \
 		OrientationIndicator.o \
+		ParticleAdvectionShader.o \
 		ParticleRenderer.o \
 		PerfQuery.o \
@@ -137,6 +132,9 @@
 		ReadBuffer.o \
 		ReaderCommon.o \
+		RegularVolumeShader.o \
 		RenderVertexArray.o \
 		ResponseQueue.o \
+		Shader.o \
+		StdVertexShader.o \
 		Switch.o \
 		Texture1D.o \
@@ -150,7 +148,9 @@
 		VolumeInterpolator.o \
 		VolumeRenderer.o \
+		VolumeShader.o \
 		VtkReader.o \
 		ZincBlendeReconstructor.o \
 		ZincBlendeVolume.o \
+		ZincBlendeVolumeShader.o \
 		dxReader.o \
 		md5.o \
@@ -282,4 +282,5 @@
 Chain.o: Chain.cpp Chain.h
 CmdProc.o: CmdProc.cpp CmdProc.h
+ColorTableShader.o: ColorTableShader.cpp ColorTableShader.h Shader.h
 Command.o: Command.cpp nanovis.h config.h define.h FlowCmd.h CmdProc.h Trace.h PlaneRenderer.h PPMWriter.h BMPWriter.h dxReader.h Grid.h HeightMap.h Camera.h ZincBlendeReconstructor.h OrientationIndicator.h Unirect.h Volume.h VolumeRenderer.h
 ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h
@@ -293,12 +294,6 @@
 HeightMap.o: HeightMap.cpp HeightMap.h
 LIC.o: LIC.cpp LIC.h
-NvColorTableShader.o: NvColorTableShader.cpp NvColorTableShader.h NvShader.h
-NvParticleAdvectionShader.o: NvParticleAdvectionShader.cpp NvParticleAdvectionShader.h NvShader.h
-NvRegularVolumeShader.o: NvRegularVolumeShader.cpp NvRegularVolumeShader.h NvVolumeShader.h NvShader.h
-NvShader.o: NvShader.cpp NvShader.h
-NvStdVertexShader.o: NvStdVertexShader.cpp NvStdVertexShader.h NvShader.h
-NvVolumeShader.o: NvVolumeShader.cpp NvVolumeShader.h NvShader.h
-NvZincBlendeVolumeShader.o: NvZincBlendeVolumeShader.cpp NvZincBlendeVolumeShader.h NvVolumeShader.h NvShader.h
 OrientationIndicator.o: OrientationIndicator.cpp OrientationIndicator.h
+ParticleAdvectionShader.o: ParticleAdvectionShader.cpp ParticleAdvectionShader.h Shader.h
 ParticleEmitter.o: ParticleEmitter.cpp ParticleEmitter.h
 ParticleRenderer.o: ParticleRenderer.cpp ParticleRenderer.h
@@ -314,5 +309,8 @@
 PPMWriter.o: PPMWriter.cpp PPMWriter.h
 ReaderCommon.o: ReaderCommon.cpp ReaderCommon.h GradientFilter.h $(VRMATH_DIR)/include/vrmath/Vector3f.h
+RegularVolumeShader.o: RegularVolumeShader.cpp RegularVolumeShader.h VolumeShader.h Shader.h
 RenderVertexArray.o: RenderVertexArray.cpp RenderVertexArray.h
+Shader.o: Shader.cpp Shader.h
+StdVertexShader.o: StdVertexShader.cpp StdVertexShader.h Shader.h
 Switch.o: Switch.cpp Switch.h
 Texture1D.o: Texture1D.cpp Texture1D.h
@@ -325,10 +323,12 @@
 Volume.o: Volume.cpp Volume.h config.h define.h
 VolumeInterpolator.o: VolumeInterpolator.cpp VolumeInterpolator.h Volume.h
-VolumeRenderer.o: VolumeRenderer.cpp VolumeRenderer.h ConvexPolygon.h Volume.h nanovis.h Trace.h Plane.h NvStdVertexShader.h NvShader.h
+VolumeRenderer.o: VolumeRenderer.cpp VolumeRenderer.h ConvexPolygon.h Volume.h nanovis.h Trace.h Plane.h StdVertexShader.h Shader.h
+VolumeShader.o: VolumeShader.cpp VolumeShader.h Shader.h
 VtkReader.o: VtkReader.h Trace.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h ReaderCommon.h nanovis.h
 ZincBlendeReconstructor.o: ZincBlendeReconstructor.cpp ZincBlendeReconstructor.h ZincBlendeVolume.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h
 ZincBlendeVolume.o: ZincBlendeVolume.cpp ZincBlendeVolume.h config.h define.h
+ZincBlendeVolumeShader.o: ZincBlendeVolumeShader.cpp ZincBlendeVolumeShader.h VolumeShader.h Shader.h
 dxReader.o: dxReader.cpp ReaderCommon.h config.h nanovis.h Unirect.h ZincBlendeVolume.h ZincBlendeReconstructor.h
 md5.o: md5.h
 nanovis.o: nanovis.cpp nanovis.h config.h define.h Command.h Flow.h Grid.h HeightMap.h Camera.h LIC.h ZincBlendeReconstructor.h OrientationIndicator.h PerfQuery.h PlaneRenderer.h PointSetRenderer.h PointSet.h Switch.h Trace.h Unirect.h VelocityArrowsSlice.h VolumeInterpolator.h VolumeRenderer.h ZincBlendeVolume.h Axis.h Chain.h
-nanovisServer.o: nanovisServer.cpp nanovisServer.h config.h nanovis.h define.h Command.h PPMWriter.h ReadBuffer.h NvShader.h ResponseQueue.h Trace.h
+nanovisServer.o: nanovisServer.cpp nanovisServer.h config.h nanovis.h define.h Command.h PPMWriter.h ReadBuffer.h Shader.h ResponseQueue.h Trace.h
Index: unk/packages/vizservers/nanovis/NvColorTableShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/NvColorTableShader.cpp	(revision 3611)
+++ 	(revision )
@@ -1,40 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#include "NvColorTableShader.h"
-
-using namespace nv;
-
-NvColorTableShader::NvColorTableShader()
-{
-    init();
-}
-
-NvColorTableShader::~NvColorTableShader()
-{
-}
-
-void NvColorTableShader::init()
-{
-    loadFragmentProgram("one_plane.cg", "main"); 
-}
-
-void NvColorTableShader::bind(Texture2D *plane, TransferFunction *tf)
-{
-    setFPTextureParameter("data", plane->id());
-    setFPTextureParameter("tf", tf->id());
-
-    setFPParameter4f("render_param", 0., 0., 0., 0.);
-
-    NvShader::bind();
-}
-
-void NvColorTableShader::unbind()
-{
-    disableFPTextureParameter("data");
-    disableFPTextureParameter("tf");
-
-    NvShader::unbind();
-}
Index: unk/packages/vizservers/nanovis/NvColorTableShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/NvColorTableShader.h	(revision 3611)
+++ 	(revision )
@@ -1,32 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#ifndef NV_COLORTABLE_SHADER_H
-#define NV_COLORTABLE_SHADER_H
-
-#include "NvShader.h"
-#include "Texture2D.h"
-#include "TransferFunction.h"
-
-namespace nv {
-
-class NvColorTableShader : public NvShader
-{
-public:
-    NvColorTableShader();
-
-    virtual ~NvColorTableShader();
-
-    virtual void bind(Texture2D *plane, TransferFunction *tf);
-
-    virtual void unbind();
-
-private :
-    void init();
-};
-
-}
-
-#endif 
Index: unk/packages/vizservers/nanovis/NvParticleAdvectionShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/NvParticleAdvectionShader.cpp	(revision 3611)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#include "NvParticleAdvectionShader.h"
-
-using namespace nv;
-
-NvParticleAdvectionShader::NvParticleAdvectionShader() : 
-    _velocityVolumeID(0), 
-    _scale(1.0f, 1.0f, 1.0f), 
-    _max(1.0f), 
-    _timeStep(0.0005f),
-    _mode(1)
-{
-    init();
-}
-
-NvParticleAdvectionShader::~NvParticleAdvectionShader()
-{
-}
-
-void NvParticleAdvectionShader::init()
-{
-    loadFragmentProgram("update_pos.cg", "main");
-}
-
-void 
-NvParticleAdvectionShader::bind(unsigned int texID, unsigned int initPosTexID)
-{
-    setFPTextureParameter("pos_tex", texID);
-    setFPTextureParameter("init_pos_tex", initPosTexID);
-    setFPTextureParameter("vel_tex", _velocityVolumeID);
-
-    setFPParameter1f("timestep", _timeStep);
-    setFPParameter1f("max", _max);
-    setFPParameter1f("mode", _mode);
-    setFPParameter3f("scale", _scale.x, _scale.y, _scale.z);
-
-    NvShader::bind();
-}
-
-void
-NvParticleAdvectionShader::unbind()
-{
-     disableFPTextureParameter("pos_tex");
-     disableFPTextureParameter("init_pos_tex");
-     disableFPTextureParameter("vel_tex");
-
-     NvShader::unbind();
-}
Index: unk/packages/vizservers/nanovis/NvParticleAdvectionShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/NvParticleAdvectionShader.h	(revision 3611)
+++ 	(revision )
@@ -1,62 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#ifndef NV_PARTICLE_ADV_SHADER_H
-#define NV_PARTICLE_ADV_SHADER_H
-
-#include <vrmath/Vector3f.h>
-
-#include "NvShader.h"
-
-namespace nv {
-
-class NvParticleAdvectionShader : public NvShader
-{
-public:
-    NvParticleAdvectionShader();
-
-    virtual ~NvParticleAdvectionShader();
-
-    virtual void bind(unsigned int texID, unsigned int initPosTexID);
-
-    virtual void unbind();
-
-    void setScale(const vrmath::Vector3f& scale)
-    {
-        _scale = scale;
-    }
-
-    void setVelocityVolume(unsigned int texID, float max)
-    {
-        _velocityVolumeID = texID;
-        _max = max;
-        // FIXME: Is this needed?
-        if (_max > 100.f)
-            _max = 100.0f;
-    }
-
-    void setTimeStep(float timeStep)
-    {
-        _timeStep = timeStep;
-    }
-
-    void setRenderMode(int mode)
-    {
-        _mode = mode;
-    }
-
-private:
-    void init();
-
-    unsigned int _velocityVolumeID;
-    vrmath::Vector3f _scale;
-    float _max;
-    float _timeStep;
-    int _mode;
-};
-
-}
-
-#endif
Index: unk/packages/vizservers/nanovis/NvRegularVolumeShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/NvRegularVolumeShader.cpp	(revision 3611)
+++ 	(revision )
@@ -1,57 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#include "NvRegularVolumeShader.h"
-
-using namespace nv;
-
-NvRegularVolumeShader::NvRegularVolumeShader()
-{
-    init();
-}
-
-NvRegularVolumeShader::~NvRegularVolumeShader()
-{
-}
-
-void NvRegularVolumeShader::init()
-{
-    loadFragmentProgram("one_volume.cg", "main");
-}
-
-void NvRegularVolumeShader::bind(unsigned int tfID, Volume *volume,
-                                 int sliceMode, float sampleRatio)
-{
-    //regular cubic volume
-    setGLStateMatrixFPParameter("modelViewInv", MODELVIEW_MATRIX,
-                                MATRIX_INVERSE);
-    setGLStateMatrixFPParameter("modelView", MODELVIEW_MATRIX,
-                                MATRIX_IDENTITY);
-
-    setFPTextureParameter("volume", volume->textureID());
-    setFPTextureParameter("tf", tfID);
-
-    setFPParameter4f("material",
-                     volume->ambient(),
-                     volume->diffuse(),
-                     volume->specularLevel(),
-                     volume->specularExponent());
-
-    setFPParameter4f("renderParams",
-                     (sliceMode ? 0.0f : sampleRatio),
-                     volume->isosurface(),
-                     volume->opacityScale(),
-                     (volume->twoSidedLighting() ? 1.0f : 0.0f));
-
-    NvShader:: bind();
-}
-
-void NvRegularVolumeShader::unbind()
-{
-    disableFPTextureParameter("volume");
-    disableFPTextureParameter("tf");
-
-    NvShader::unbind();
-}
Index: unk/packages/vizservers/nanovis/NvRegularVolumeShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/NvRegularVolumeShader.h	(revision 3611)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#ifndef NV_REGULAR_SHADER_H
-#define NV_REGULAR_SHADER_H
-
-#include "Volume.h"
-#include "NvVolumeShader.h"
-
-namespace nv {
-
-/// Shader for regular volume (uniform grid)
-class NvRegularVolumeShader : public NvVolumeShader
-{
-public:
-    NvRegularVolumeShader();
-
-    virtual ~NvRegularVolumeShader();
-
-    virtual void bind(unsigned int tfID, Volume *volume,
-                      int sliceMode, float sampleRatio);
-
-    virtual void unbind();
-
-private:
-    void init();
-};
-
-}
-
-#endif
Index: unk/packages/vizservers/nanovis/NvShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/NvShader.cpp	(revision 3611)
+++ 	(revision )
@@ -1,133 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#include <stdio.h>
-
-#include <GL/glew.h>
-#include <Cg/cg.h>
-#include <Cg/cgGL.h>
-
-#include <util/FilePath.h>
-
-#include "NvShader.h"
-#include "Trace.h"
-
-using namespace nv;
-using namespace nv::util;
-
-CGprofile NvShader::_defaultVertexProfile = CG_PROFILE_VP40;
-CGprofile NvShader::_defaultFragmentProfile = CG_PROFILE_FP40;
-CGcontext NvShader::_cgContext = NULL;
-
-void NvShader::initCg(CGprofile defaultVertexProfile,
-                      CGprofile defaultFragmentProfile)
-{
-    _defaultVertexProfile = defaultVertexProfile;
-    _defaultFragmentProfile = defaultFragmentProfile;
-    _cgContext = cgCreateContext();
-}
-
-void NvShader::exitCg()
-{
-    setErrorCallback(NULL);
-    printErrorInfo();
-    if (_cgContext != NULL) {
-        TRACE("Before DestroyContext");
-        cgDestroyContext(_cgContext);
-        TRACE("After DestroyContext");
-        _cgContext = NULL;
-    }
-}
-
-bool NvShader::printErrorInfo()
-{
-    CGerror lastError = cgGetError();
-
-    if (lastError) {
-        TRACE("Cg Error: %s", cgGetErrorString(lastError));
-        if (getCgContext())
-            TRACE("%s", cgGetLastListing(getCgContext()));
-        return false;
-    }
-    return true;
-}
-
-CGprogram
-NvShader::loadCgSourceProgram(CGcontext context, const char *fileName,
-                              CGprofile profile, const char *entryPoint)
-{
-    std::string path = FilePath::getInstance()->getPath(fileName);
-    if (path.empty()) {
-        ERROR("can't find program \"%s\"", fileName);
-    }
-    TRACE("cg program compiling: %s", path.c_str());
-    CGprogram program;
-    program = cgCreateProgramFromFile(context, CG_SOURCE, path.c_str(), profile, 
-                                      entryPoint, NULL);
-    cgGLLoadProgram(program);
-    CGerror LastError = cgGetError();
-    if (LastError) {
-        ERROR("Error message: %s", cgGetLastListing(context));
-    }
-    TRACE("successfully compiled program: %s", path.c_str());
-    return program;
-}
-
-NvShader::NvShader():
-    _vertexProfile(_defaultVertexProfile),
-    _fragmentProfile(_defaultFragmentProfile),
-    _cgVP(NULL),
-    _cgFP(NULL)
-{
-}
-
-NvShader::~NvShader()
-{
-    TRACE("In ~NvShader");
-    if (_cgContext == NULL) {
-        TRACE("Lost Cg context: vp: %s, fp: %s", _vpFile.c_str(), _fpFile.c_str());
-    } else {
-        resetPrograms();
-    }
-}
-
-void NvShader::loadVertexProgram(const char *fileName, const char *entryPoint)
-{
-    if (_cgVP != NULL) {
-        cgDestroyProgram(_cgVP);
-    }
-    _cgVP = loadCgSourceProgram(_cgContext, fileName,
-                                _vertexProfile, entryPoint);
-    _vpFile = fileName;
-}
-
-void NvShader::loadFragmentProgram(const char *fileName, const char *entryPoint)
-{
-    if (_cgFP != NULL) {
-        cgDestroyProgram(_cgFP);
-    }
-    _cgFP = loadCgSourceProgram(_cgContext, fileName,
-                                _fragmentProfile, entryPoint);
-    _fpFile = fileName;
-}
-
-void NvShader::resetPrograms()
-{
-    if (_cgVP != NULL) {
-        TRACE("Destroying vertex program: %s", _vpFile.c_str());
-        cgDestroyProgram(_cgVP);
-    }
-
-    if (_cgFP != NULL) {
-        TRACE("Destroying fragment program: %s", _fpFile.c_str());
-        cgDestroyProgram(_cgFP);
-    }
-}
-
-void NvShader::setErrorCallback(NvCgCallbackFunction callback)
-{
-    TRACE("NvShader setting error callback to: %p", callback);
-    cgSetErrorCallback(callback);
-}
Index: unk/packages/vizservers/nanovis/NvShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/NvShader.h	(revision 3611)
+++ 	(revision )
@@ -1,343 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#ifndef NV_SHADER_H
-#define NV_SHADER_H
-
-#include <string>
-#include <tr1/unordered_map>
-
-#include <GL/glew.h>
-#include <Cg/cg.h>
-#include <Cg/cgGL.h>
-
-#include "Trace.h"
-
-namespace nv {
-
-class NvShader
-{
-public:
-    enum NvGLMatrix {
-        MODELVIEW_MATRIX = CG_GL_MODELVIEW_MATRIX,
-        PROJECTION_MATRIX = CG_GL_PROJECTION_MATRIX,
-        MODELVIEW_PROJECTION_MATRIX = CG_GL_MODELVIEW_PROJECTION_MATRIX
-    };
-    enum NvGLMatrixType {
-        MATRIX_IDENTITY = CG_GL_MATRIX_IDENTITY,
-        MATRIX_INVERSE = CG_GL_MATRIX_INVERSE
-    };
-
-    typedef void NvCgCallbackFunction(void);
-
-    NvShader();
-
-    virtual ~NvShader();
-
-    /**
-     * @brief create a Cg vertex program and load it
-     * @param fileName the name of Cg program file
-     * @param entryPoint a entry point of the Cg program
-     */
-    void loadVertexProgram(const char *fileName, const char *entryPoint);
-
-    /**
-     * @brief create a Cg fragment program and load it
-     * @param fileName the name of Cg program file
-     * @param entryPoint a entry point of the Cg program
-     */
-    void loadFragmentProgram(const char *fileName, const char *entryPoint);
-
-    CGparameter getNamedParameterFromFP(const char *paramName)
-    {
-        if (_cgFP) {
-            return cgGetNamedParameter(_cgFP, paramName);
-        }
-        ERROR("Unknown fragment program parameter: %s", paramName);
-        return 0;
-    }
-
-    CGparameter getNamedParameterFromVP(const char *paramName)
-    {
-        if (_cgVP) {
-            return cgGetNamedParameter(_cgVP, paramName);
-        }
-        ERROR("Unknown vertex program parameter: %s", paramName);
-        return 0;
-    }
-
-    void setVPParameter1f(const char *name, float val)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgSetParameter1f(param, val);
-    }
-
-    void setFPParameter1f(const char *name, float val)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgSetParameter1f(param, val);
-    }
-
-    void setVPParameter2f(const char *name, float val1, float val2)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgSetParameter2f(param, val1, val2);
-    }
-
-    void setFPParameter2f(const char *name, float val1, float val2)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgSetParameter2f(param, val1, val2);
-    }
-
-    void setVPParameter3f(const char *name, float val1, float val2, float val3)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgSetParameter3f(param, val1, val2, val3);
-    }
-
-    void setFPParameter3f(const char *name, float val1, float val2, float val3)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgSetParameter3f(param, val1, val2, val3);
-    }
-
-    void setVPParameter4f(const char *name, float val1, float val2, float val3, float val4)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgSetParameter4f(param, val1, val2, val3, val4);
-    }
-
-    void setFPParameter4f(const char *name, float val1, float val2, float val3, float val4)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgSetParameter4f(param, val1, val2, val3, val4);
-    }
-
-    void setVPMatrixParameterf(const char *name, float *mat)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgSetMatrixParameterfc(param, mat);
-    }
-
-    void setFPMatrixParameterf(const char *name, float *mat)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgSetMatrixParameterfc(param, mat);
-    }
-
-    void setVPTextureParameter(const char *name, GLuint texobj, bool enable = true)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgGLSetTextureParameter(param, texobj);
-        if (enable)
-            cgGLEnableTextureParameter(param);
-    }
-
-    void setFPTextureParameter(const char *name, GLuint texobj, bool enable = true)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgGLSetTextureParameter(param, texobj);
-        if (enable)
-            cgGLEnableTextureParameter(param);
-    }
-
-    void enableVPTextureParameter(const char *name)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgGLEnableTextureParameter(param);
-    }
-
-    void enaableFPTextureParameter(const char *name)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgGLEnableTextureParameter(param);
-    }
-
-    void disableVPTextureParameter(const char *name)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgGLDisableTextureParameter(param);
-    }
-
-    void disableFPTextureParameter(const char *name)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgGLDisableTextureParameter(param);
-    }
-
-    void setGLStateMatrixVPParameter(const char *name, NvGLMatrix matrix,
-                                     NvGLMatrixType type = MATRIX_IDENTITY)
-    {
-        CGparameter param = getVPParam(name);
-        if (param == NULL)
-            return;
-        cgGLSetStateMatrixParameter(param, (CGGLenum)matrix, (CGGLenum)type);
-    }
-
-    void setGLStateMatrixFPParameter(const char *name, NvGLMatrix matrix,
-                                     NvGLMatrixType type = MATRIX_IDENTITY)
-    {
-        CGparameter param = getFPParam(name);
-        if (param == NULL)
-            return;
-        cgGLSetStateMatrixParameter(param, (CGGLenum)matrix, (CGGLenum)type);
-    }
-
-    virtual void bind()
-    {
-        if (_cgVP) {
-            cgGLBindProgram(_cgVP);
-            enableVertexProfile();
-        }
-        if (_cgFP) {
-            cgGLBindProgram(_cgFP);
-            enableFragmentProfile();
-        }
-    }
-
-    virtual void unbind()
-    {
-        if (_cgVP)
-            disableVertexProfile();
-        if (_cgFP)
-            disableFragmentProfile();
-    }
-
-    void enableVertexProfile()
-    {
-        cgGLEnableProfile(_vertexProfile);
-    }
-
-    void disableVertexProfile()
-    {
-        cgGLDisableProfile(_vertexProfile);
-    }
-
-    void enableFragmentProfile()
-    {
-        cgGLEnableProfile(_fragmentProfile);
-    }
-
-    void disableFragmentProfile()
-    {
-        cgGLDisableProfile(_fragmentProfile);
-    }
-
-    static void initCg(CGprofile defaultVertexProfile = CG_PROFILE_VP40,
-                       CGprofile defaultFragmentProfile = CG_PROFILE_FP40);
-
-    static void exitCg();
-
-    static bool printErrorInfo();
-
-    static void setErrorCallback(NvCgCallbackFunction callback);
-
-    static CGcontext getCgContext()
-    {
-        return _cgContext;
-    }
-
-protected:
-    typedef std::tr1::unordered_map<std::string, CGparameter> ParameterHashmap;
-
-    CGprogram getVP()
-    {
-        return _cgVP;
-    }
-
-    CGprogram getFP()
-    {
-        return _cgFP;
-    }
-
-    CGparameter getVPParam(const char *name)
-    {
-        CGparameter param;
-        ParameterHashmap::iterator itr = _vpParams.find(name);
-        if (itr == _vpParams.end()) {
-            param = getNamedParameterFromVP(name);
-            if (param != NULL)
-                _vpParams[name] = param;
-            else
-                ERROR("Unknown vertex program parameter: %s", name);
-        } else {
-            param = itr->second;
-        }
-        return param;
-    }
-
-    CGparameter getFPParam(const char *name)
-    {
-        CGparameter param;
-        ParameterHashmap::iterator itr = _fpParams.find(name);
-        if (itr == _fpParams.end()) {
-            param = getNamedParameterFromFP(name);
-            if (param != NULL)
-                _fpParams[name] = param;
-            else
-                ERROR("Unknown fragment program parameter: %s", name);
-        } else {
-            param = itr->second;
-        }
-        return param;
-    }
-
-    void resetPrograms();
-
-    CGprofile _vertexProfile;
-    CGprofile _fragmentProfile;
-    std::string _vpFile;
-    CGprogram _cgVP;
-    std::string _fpFile;
-    CGprogram _cgFP;
-    ParameterHashmap _vpParams;
-    ParameterHashmap _fpParams;
-
-    static CGprofile _defaultVertexProfile;
-    static CGprofile _defaultFragmentProfile;
-    static CGcontext _cgContext;
-
-private:
-    static CGprogram
-    loadCgSourceProgram(CGcontext context, const char *filename, 
-                        CGprofile profile, const char *entryPoint);
-};
-
-}
-
-#endif
Index: unk/packages/vizservers/nanovis/NvStdVertexShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/NvStdVertexShader.cpp	(revision 3611)
+++ 	(revision )
@@ -1,38 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#include "NvStdVertexShader.h"
-
-using namespace nv;
-
-NvStdVertexShader::NvStdVertexShader()
-{
-    init();
-}
-
-NvStdVertexShader::~NvStdVertexShader()
-{
-}
-
-void NvStdVertexShader::init()
-{
-    loadVertexProgram("vertex_std.cg", "main");
-}
-
-void NvStdVertexShader::bind(float *mvp, float *mvInv)
-{
-    if (mvp != NULL) {
-        setVPMatrixParameterf("modelViewProjMatrix", mvp);
-    } else {
-        setGLStateMatrixVPParameter("modelViewProjMatrix", MODELVIEW_PROJECTION_MATRIX);
-    }
-    if (mvInv != NULL) {
-        setVPMatrixParameterf("modelViewInv", mvInv);
-    } else {
-        setGLStateMatrixVPParameter("modelViewInv", MODELVIEW_MATRIX, MATRIX_INVERSE);
-    }
-
-    NvShader::bind();
-}
Index: unk/packages/vizservers/nanovis/NvStdVertexShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/NvStdVertexShader.h	(revision 3611)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#ifndef NV_STD_VERTEX_SHADER_H
-#define NV_STD_VERTEX_SHADER_H
-
-#include "NvShader.h"
-
-namespace nv {
-
-class NvStdVertexShader : public NvShader
-{
-public:
-    NvStdVertexShader();
-
-    virtual ~NvStdVertexShader();
-
-    virtual void bind(float *mvp = NULL, float *mvInv = NULL);
-
-    virtual void unbind()
-    {
-        NvShader::unbind();
-    }
-
-private:
-    void init();
-};
-
-}
-
-#endif 
-
Index: unk/packages/vizservers/nanovis/NvVolumeShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/NvVolumeShader.cpp	(revision 3611)
+++ 	(revision )
@@ -1,17 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#include "NvVolumeShader.h"
-
-using namespace nv;
-
-NvVolumeShader::NvVolumeShader()
-{
-}
-
-NvVolumeShader::~NvVolumeShader()
-{
-}
-
Index: unk/packages/vizservers/nanovis/NvVolumeShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/NvVolumeShader.h	(revision 3611)
+++ 	(revision )
@@ -1,35 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#ifndef NV_VOLUME_SHADER_H
-#define NV_VOLUME_SHADER_H
-
-#include "NvShader.h"
-
-namespace nv {
-
-class Volume;
-
-class NvVolumeShader : public NvShader
-{
-public :
-    virtual ~NvVolumeShader();
-
-    virtual void bind(unsigned int tfID, Volume *volume,
-                      int sliceMode, float sampleRatio) = 0;
-
-    virtual void unbind()
-    {
-        NvShader::unbind();
-    }
-
-protected :
-    NvVolumeShader();
-};
-
-}
-
-#endif // 
-
Index: unk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.cpp	(revision 3611)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-
-#include "NvZincBlendeVolumeShader.h"
-#include "ZincBlendeVolume.h"
-
-using namespace nv;
-
-NvZincBlendeVolumeShader::NvZincBlendeVolumeShader()
-{
-    init();
-}
-
-NvZincBlendeVolumeShader::~NvZincBlendeVolumeShader()
-{
-}
-
-void NvZincBlendeVolumeShader::init()
-{
-    loadFragmentProgram("zincblende_volume.cg", "main");
-}
-
-void NvZincBlendeVolumeShader::bind(unsigned int tfID, Volume *volume,
-                                    int sliceMode, float sampleRatio)
-{
-    ZincBlendeVolume *vol = (ZincBlendeVolume *)volume;
-    setGLStateMatrixFPParameter("modelViewInv", MODELVIEW_MATRIX,
-                                MATRIX_INVERSE);
-
-    setFPTextureParameter("tf", tfID);
-    setFPTextureParameter("volumeA", vol->zincblendeTex[0]->id());
-    setFPTextureParameter("volumeB", vol->zincblendeTex[1]->id());
-
-    setFPParameter4f("cellSize",
-                     vol->cellSize.x,
-                     vol->cellSize.y,
-                     vol->cellSize.z, 0.);
-
-    setFPParameter4f("renderParams",
-                     (sliceMode ? 0.0f : sampleRatio),
-                     volume->isosurface(),
-                     volume->opacityScale(),
-                     0.0f);
-
-    NvShader::bind();
-}
-
-void NvZincBlendeVolumeShader::unbind() 
-{
-    disableFPTextureParameter("tf");
-    disableFPTextureParameter("volumeA");
-    disableFPTextureParameter("volumeB");
-
-    NvShader::unbind();
-}
Index: unk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h	(revision 3611)
+++ 	(revision )
@@ -1,31 +1,0 @@
-/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright (c) 2004-2013  HUBzero Foundation, LLC
- *
- */
-#ifndef NV_ZINCBLENDE_SHADER_H
-#define NV_ZINCBLENDE_SHADER_H
-
-#include "NvVolumeShader.h"
-
-namespace nv {
-
-class NvZincBlendeVolumeShader : public NvVolumeShader
-{
-public:
-    NvZincBlendeVolumeShader();
-
-    virtual ~NvZincBlendeVolumeShader();
-
-    virtual void bind(unsigned int tfID, Volume *volume,
-                      int sliceMode, float sampleRatio);
-
-    virtual void unbind();
-
-private:
-    void init();
-};
-
-}
-
-#endif 
Index: /trunk/packages/vizservers/nanovis/ParticleAdvectionShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/ParticleAdvectionShader.cpp	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/ParticleAdvectionShader.cpp	(revision 3612)
@@ -0,0 +1,52 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#include "ParticleAdvectionShader.h"
+
+using namespace nv;
+
+ParticleAdvectionShader::ParticleAdvectionShader() : 
+    _velocityVolumeID(0), 
+    _scale(1.0f, 1.0f, 1.0f), 
+    _max(1.0f), 
+    _timeStep(0.0005f),
+    _mode(1)
+{
+    init();
+}
+
+ParticleAdvectionShader::~ParticleAdvectionShader()
+{
+}
+
+void ParticleAdvectionShader::init()
+{
+    loadFragmentProgram("update_pos.cg", "main");
+}
+
+void 
+ParticleAdvectionShader::bind(unsigned int texID, unsigned int initPosTexID)
+{
+    setFPTextureParameter("pos_tex", texID);
+    setFPTextureParameter("init_pos_tex", initPosTexID);
+    setFPTextureParameter("vel_tex", _velocityVolumeID);
+
+    setFPParameter1f("timestep", _timeStep);
+    setFPParameter1f("max", _max);
+    setFPParameter1f("mode", _mode);
+    setFPParameter3f("scale", _scale.x, _scale.y, _scale.z);
+
+    Shader::bind();
+}
+
+void
+ParticleAdvectionShader::unbind()
+{
+     disableFPTextureParameter("pos_tex");
+     disableFPTextureParameter("init_pos_tex");
+     disableFPTextureParameter("vel_tex");
+
+     Shader::unbind();
+}
Index: /trunk/packages/vizservers/nanovis/ParticleAdvectionShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/ParticleAdvectionShader.h	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/ParticleAdvectionShader.h	(revision 3612)
@@ -0,0 +1,62 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#ifndef NV_PARTICLE_ADV_SHADER_H
+#define NV_PARTICLE_ADV_SHADER_H
+
+#include <vrmath/Vector3f.h>
+
+#include "Shader.h"
+
+namespace nv {
+
+class ParticleAdvectionShader : public Shader
+{
+public:
+    ParticleAdvectionShader();
+
+    virtual ~ParticleAdvectionShader();
+
+    virtual void bind(unsigned int texID, unsigned int initPosTexID);
+
+    virtual void unbind();
+
+    void setScale(const vrmath::Vector3f& scale)
+    {
+        _scale = scale;
+    }
+
+    void setVelocityVolume(unsigned int texID, float max)
+    {
+        _velocityVolumeID = texID;
+        _max = max;
+        // FIXME: Is this needed?
+        if (_max > 100.f)
+            _max = 100.0f;
+    }
+
+    void setTimeStep(float timeStep)
+    {
+        _timeStep = timeStep;
+    }
+
+    void setRenderMode(int mode)
+    {
+        _mode = mode;
+    }
+
+private:
+    void init();
+
+    unsigned int _velocityVolumeID;
+    vrmath::Vector3f _scale;
+    float _max;
+    float _timeStep;
+    int _mode;
+};
+
+}
+
+#endif
Index: /trunk/packages/vizservers/nanovis/ParticleRenderer.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/ParticleRenderer.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/ParticleRenderer.cpp	(revision 3612)
@@ -19,5 +19,5 @@
 using namespace nv;
 
-NvParticleAdvectionShader *ParticleRenderer::_advectionShader = NULL;
+ParticleAdvectionShader *ParticleRenderer::_advectionShader = NULL;
 ParticleAdvectionShaderInstance shaderInstance;
 
@@ -103,5 +103,5 @@
 
     if (_advectionShader == NULL) {
-        _advectionShader = new NvParticleAdvectionShader();
+        _advectionShader = new ParticleAdvectionShader();
     }
 }
Index: /trunk/packages/vizservers/nanovis/ParticleRenderer.h
===================================================================
--- /trunk/packages/vizservers/nanovis/ParticleRenderer.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/ParticleRenderer.h	(revision 3612)
@@ -14,5 +14,5 @@
 #include <vrmath/Vector4f.h>
 
-#include "NvParticleAdvectionShader.h"
+#include "ParticleAdvectionShader.h"
 #include "RenderVertexArray.h"
 
@@ -84,5 +84,5 @@
     }
 
-   static NvParticleAdvectionShader *_advectionShader;
+   static ParticleAdvectionShader *_advectionShader;
 
 private:
Index: /trunk/packages/vizservers/nanovis/ParticleSystem.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/ParticleSystem.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/ParticleSystem.cpp	(revision 3612)
@@ -30,5 +30,5 @@
 #include "Texture2D.h"
 #include "Texture3D.h"
-#include "NvShader.h"
+#include "Shader.h"
 #include "Trace.h"
 
@@ -423,5 +423,5 @@
 {
     // TBD...
-    _context = NvShader::getCgContext();
+    _context = Shader::getCgContext();
 
     std::string path = FilePath::getInstance()->getPath("distance.cg");
Index: /trunk/packages/vizservers/nanovis/PlaneRenderer.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/PlaneRenderer.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/PlaneRenderer.cpp	(revision 3612)
@@ -1,16 +1,8 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
- * ----------------------------------------------------------------------
- * PlaneRenderer.cpp : PlaneRenderer class for volume visualization
- *
- * ======================================================================
- *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
- *           Purdue Rendering and Perceptualization Lab (PURPL)
- *
  *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
  *
- *  See the file "license.terms" for information on usage and
- *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- * ======================================================================
+ *  Authors:
+ *    Wei Qiao <qiaow@purdue.edu>
  */
 
@@ -27,5 +19,5 @@
     _renderWidth(width),
     _renderHeight(height),
-    _shader(new NvColorTableShader())
+    _shader(new ColorTableShader())
 {
     _plane.clear();
Index: /trunk/packages/vizservers/nanovis/PlaneRenderer.h
===================================================================
--- /trunk/packages/vizservers/nanovis/PlaneRenderer.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/PlaneRenderer.h	(revision 3612)
@@ -1,16 +1,8 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
- * ----------------------------------------------------------------------
- * PlaneRenderer.h : PlaneRenderer class for 2D visualization
- *
- * ======================================================================
- *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
- *           Purdue Rendering and Perceptualization Lab (PURPL)
- *
  *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
  *
- *  See the file "license.terms" for information on usage and
- *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- * ======================================================================
+ *  Authors:
+ *    Wei Qiao <qiaow@purdue.edu>
  */
 #ifndef PLANE_RENDERER_H
@@ -19,5 +11,5 @@
 #include <vector>
 
-#include "NvColorTableShader.h"
+#include "ColorTableShader.h"
 #include "TransferFunction.h"
 #include "Texture2D.h"
@@ -54,5 +46,5 @@
     int _renderHeight;  
 
-    NvColorTableShader *_shader;
+    ColorTableShader *_shader;
 };
 
Index: /trunk/packages/vizservers/nanovis/PointSet.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/PointSet.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/PointSet.cpp	(revision 3612)
@@ -12,4 +12,6 @@
 #include "PointSet.h"
 #include "PCASplit.h"
+
+using namespace nv;
 
 void 
Index: /trunk/packages/vizservers/nanovis/PointSet.h
===================================================================
--- /trunk/packages/vizservers/nanovis/PointSet.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/PointSet.h	(revision 3612)
@@ -11,4 +11,6 @@
 
 #include "PCASplit.h"
+
+namespace nv {
 
 class PointSet
@@ -87,3 +89,5 @@
 };
 
+}
+
 #endif
Index: /trunk/packages/vizservers/nanovis/PointSetRenderer.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/PointSetRenderer.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/PointSetRenderer.cpp	(revision 3612)
@@ -14,4 +14,5 @@
 #include "PCASplit.h"
 
+using namespace nv;
 using namespace nv::util;
 
Index: /trunk/packages/vizservers/nanovis/PointSetRenderer.h
===================================================================
--- /trunk/packages/vizservers/nanovis/PointSetRenderer.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/PointSetRenderer.h	(revision 3612)
@@ -14,4 +14,6 @@
 #include "PointShader.h"
 #include "Texture2D.h"
+
+namespace nv {
 
 class PointSetRenderer
@@ -34,3 +36,5 @@
 };
 
+}
+
 #endif
Index: /trunk/packages/vizservers/nanovis/PointShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/PointShader.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/PointShader.cpp	(revision 3612)
@@ -6,6 +6,8 @@
 #include "PointShader.h"
 
+using namespace nv;
+
 PointShader::PointShader() : 
-    NvShader(),
+    Shader(),
     _scale(1.0f),
     _normal(NULL)
@@ -29,5 +31,5 @@
     //setVPTextureParameter("normal", _normal->getGraphicsObjectID());
 
-    NvShader::bind();
+    Shader::bind();
 }
 
@@ -36,4 +38,4 @@
     //disableVPTextureParameter("normal");
 
-    NvShader::unbind();
+    Shader::unbind();
 }
Index: /trunk/packages/vizservers/nanovis/PointShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/PointShader.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/PointShader.h	(revision 3612)
@@ -7,8 +7,10 @@
 #define POINTSHADER_H
 
-#include "NvShader.h"
+#include "Shader.h"
 #include "Texture3D.h"
 
-class PointShader : public NvShader
+namespace nv {
+
+class PointShader : public Shader
 {
 public:
@@ -37,3 +39,5 @@
 };
 
+}
+
 #endif
Index: /trunk/packages/vizservers/nanovis/RegularVolumeShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/RegularVolumeShader.cpp	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/RegularVolumeShader.cpp	(revision 3612)
@@ -0,0 +1,57 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#include "RegularVolumeShader.h"
+
+using namespace nv;
+
+RegularVolumeShader::RegularVolumeShader()
+{
+    init();
+}
+
+RegularVolumeShader::~RegularVolumeShader()
+{
+}
+
+void RegularVolumeShader::init()
+{
+    loadFragmentProgram("one_volume.cg", "main");
+}
+
+void RegularVolumeShader::bind(unsigned int tfID, Volume *volume,
+                                 int sliceMode, float sampleRatio)
+{
+    //regular cubic volume
+    setGLStateMatrixFPParameter("modelViewInv", MODELVIEW_MATRIX,
+                                MATRIX_INVERSE);
+    setGLStateMatrixFPParameter("modelView", MODELVIEW_MATRIX,
+                                MATRIX_IDENTITY);
+
+    setFPTextureParameter("volume", volume->textureID());
+    setFPTextureParameter("tf", tfID);
+
+    setFPParameter4f("material",
+                     volume->ambient(),
+                     volume->diffuse(),
+                     volume->specularLevel(),
+                     volume->specularExponent());
+
+    setFPParameter4f("renderParams",
+                     (sliceMode ? 0.0f : sampleRatio),
+                     volume->isosurface(),
+                     volume->opacityScale(),
+                     (volume->twoSidedLighting() ? 1.0f : 0.0f));
+
+    Shader:: bind();
+}
+
+void RegularVolumeShader::unbind()
+{
+    disableFPTextureParameter("volume");
+    disableFPTextureParameter("tf");
+
+    Shader::unbind();
+}
Index: /trunk/packages/vizservers/nanovis/RegularVolumeShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/RegularVolumeShader.h	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/RegularVolumeShader.h	(revision 3612)
@@ -0,0 +1,33 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#ifndef NV_REGULAR_SHADER_H
+#define NV_REGULAR_SHADER_H
+
+#include "Volume.h"
+#include "VolumeShader.h"
+
+namespace nv {
+
+/// Shader for regular volume (uniform grid)
+class RegularVolumeShader : public VolumeShader
+{
+public:
+    RegularVolumeShader();
+
+    virtual ~RegularVolumeShader();
+
+    virtual void bind(unsigned int tfID, Volume *volume,
+                      int sliceMode, float sampleRatio);
+
+    virtual void unbind();
+
+private:
+    void init();
+};
+
+}
+
+#endif
Index: /trunk/packages/vizservers/nanovis/Shader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/Shader.cpp	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/Shader.cpp	(revision 3612)
@@ -0,0 +1,133 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#include <stdio.h>
+
+#include <GL/glew.h>
+#include <Cg/cg.h>
+#include <Cg/cgGL.h>
+
+#include <util/FilePath.h>
+
+#include "Shader.h"
+#include "Trace.h"
+
+using namespace nv;
+using namespace nv::util;
+
+CGprofile Shader::_defaultVertexProfile = CG_PROFILE_VP40;
+CGprofile Shader::_defaultFragmentProfile = CG_PROFILE_FP40;
+CGcontext Shader::_cgContext = NULL;
+
+void Shader::initCg(CGprofile defaultVertexProfile,
+                    CGprofile defaultFragmentProfile)
+{
+    _defaultVertexProfile = defaultVertexProfile;
+    _defaultFragmentProfile = defaultFragmentProfile;
+    _cgContext = cgCreateContext();
+}
+
+void Shader::exitCg()
+{
+    setErrorCallback(NULL);
+    printErrorInfo();
+    if (_cgContext != NULL) {
+        TRACE("Before DestroyContext");
+        cgDestroyContext(_cgContext);
+        TRACE("After DestroyContext");
+        _cgContext = NULL;
+    }
+}
+
+bool Shader::printErrorInfo()
+{
+    CGerror lastError = cgGetError();
+
+    if (lastError) {
+        TRACE("Cg Error: %s", cgGetErrorString(lastError));
+        if (getCgContext())
+            TRACE("%s", cgGetLastListing(getCgContext()));
+        return false;
+    }
+    return true;
+}
+
+CGprogram
+Shader::loadCgSourceProgram(CGcontext context, const char *fileName,
+                            CGprofile profile, const char *entryPoint)
+{
+    std::string path = FilePath::getInstance()->getPath(fileName);
+    if (path.empty()) {
+        ERROR("can't find program \"%s\"", fileName);
+    }
+    TRACE("cg program compiling: %s", path.c_str());
+    CGprogram program;
+    program = cgCreateProgramFromFile(context, CG_SOURCE, path.c_str(), profile, 
+                                      entryPoint, NULL);
+    cgGLLoadProgram(program);
+    CGerror LastError = cgGetError();
+    if (LastError) {
+        ERROR("Error message: %s", cgGetLastListing(context));
+    }
+    TRACE("successfully compiled program: %s", path.c_str());
+    return program;
+}
+
+Shader::Shader():
+    _vertexProfile(_defaultVertexProfile),
+    _fragmentProfile(_defaultFragmentProfile),
+    _cgVP(NULL),
+    _cgFP(NULL)
+{
+}
+
+Shader::~Shader()
+{
+    TRACE("Enter");
+    if (_cgContext == NULL) {
+        TRACE("Lost Cg context: vp: %s, fp: %s", _vpFile.c_str(), _fpFile.c_str());
+    } else {
+        resetPrograms();
+    }
+}
+
+void Shader::loadVertexProgram(const char *fileName, const char *entryPoint)
+{
+    if (_cgVP != NULL) {
+        cgDestroyProgram(_cgVP);
+    }
+    _cgVP = loadCgSourceProgram(_cgContext, fileName,
+                                _vertexProfile, entryPoint);
+    _vpFile = fileName;
+}
+
+void Shader::loadFragmentProgram(const char *fileName, const char *entryPoint)
+{
+    if (_cgFP != NULL) {
+        cgDestroyProgram(_cgFP);
+    }
+    _cgFP = loadCgSourceProgram(_cgContext, fileName,
+                                _fragmentProfile, entryPoint);
+    _fpFile = fileName;
+}
+
+void Shader::resetPrograms()
+{
+    if (_cgVP != NULL) {
+        TRACE("Destroying vertex program: %s", _vpFile.c_str());
+        cgDestroyProgram(_cgVP);
+    }
+
+    if (_cgFP != NULL) {
+        TRACE("Destroying fragment program: %s", _fpFile.c_str());
+        cgDestroyProgram(_cgFP);
+    }
+}
+
+void Shader::setErrorCallback(CgCallbackFunction callback)
+{
+    TRACE("Shader setting error callback to: %p", callback);
+    cgSetErrorCallback(callback);
+}
Index: /trunk/packages/vizservers/nanovis/Shader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/Shader.h	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/Shader.h	(revision 3612)
@@ -0,0 +1,343 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#ifndef NV_SHADER_H
+#define NV_SHADER_H
+
+#include <string>
+#include <tr1/unordered_map>
+
+#include <GL/glew.h>
+#include <Cg/cg.h>
+#include <Cg/cgGL.h>
+
+#include "Trace.h"
+
+namespace nv {
+
+class Shader
+{
+public:
+    enum GLMatrix {
+        MODELVIEW_MATRIX = CG_GL_MODELVIEW_MATRIX,
+        PROJECTION_MATRIX = CG_GL_PROJECTION_MATRIX,
+        MODELVIEW_PROJECTION_MATRIX = CG_GL_MODELVIEW_PROJECTION_MATRIX
+    };
+    enum GLMatrixType {
+        MATRIX_IDENTITY = CG_GL_MATRIX_IDENTITY,
+        MATRIX_INVERSE = CG_GL_MATRIX_INVERSE
+    };
+
+    typedef void CgCallbackFunction(void);
+
+    Shader();
+
+    virtual ~Shader();
+
+    /**
+     * @brief create a Cg vertex program and load it
+     * @param fileName the name of Cg program file
+     * @param entryPoint a entry point of the Cg program
+     */
+    void loadVertexProgram(const char *fileName, const char *entryPoint);
+
+    /**
+     * @brief create a Cg fragment program and load it
+     * @param fileName the name of Cg program file
+     * @param entryPoint a entry point of the Cg program
+     */
+    void loadFragmentProgram(const char *fileName, const char *entryPoint);
+
+    CGparameter getNamedParameterFromFP(const char *paramName)
+    {
+        if (_cgFP) {
+            return cgGetNamedParameter(_cgFP, paramName);
+        }
+        ERROR("Unknown fragment program parameter: %s", paramName);
+        return 0;
+    }
+
+    CGparameter getNamedParameterFromVP(const char *paramName)
+    {
+        if (_cgVP) {
+            return cgGetNamedParameter(_cgVP, paramName);
+        }
+        ERROR("Unknown vertex program parameter: %s", paramName);
+        return 0;
+    }
+
+    void setVPParameter1f(const char *name, float val)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgSetParameter1f(param, val);
+    }
+
+    void setFPParameter1f(const char *name, float val)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgSetParameter1f(param, val);
+    }
+
+    void setVPParameter2f(const char *name, float val1, float val2)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgSetParameter2f(param, val1, val2);
+    }
+
+    void setFPParameter2f(const char *name, float val1, float val2)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgSetParameter2f(param, val1, val2);
+    }
+
+    void setVPParameter3f(const char *name, float val1, float val2, float val3)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgSetParameter3f(param, val1, val2, val3);
+    }
+
+    void setFPParameter3f(const char *name, float val1, float val2, float val3)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgSetParameter3f(param, val1, val2, val3);
+    }
+
+    void setVPParameter4f(const char *name, float val1, float val2, float val3, float val4)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgSetParameter4f(param, val1, val2, val3, val4);
+    }
+
+    void setFPParameter4f(const char *name, float val1, float val2, float val3, float val4)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgSetParameter4f(param, val1, val2, val3, val4);
+    }
+
+    void setVPMatrixParameterf(const char *name, float *mat)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgSetMatrixParameterfc(param, mat);
+    }
+
+    void setFPMatrixParameterf(const char *name, float *mat)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgSetMatrixParameterfc(param, mat);
+    }
+
+    void setVPTextureParameter(const char *name, GLuint texobj, bool enable = true)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgGLSetTextureParameter(param, texobj);
+        if (enable)
+            cgGLEnableTextureParameter(param);
+    }
+
+    void setFPTextureParameter(const char *name, GLuint texobj, bool enable = true)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgGLSetTextureParameter(param, texobj);
+        if (enable)
+            cgGLEnableTextureParameter(param);
+    }
+
+    void enableVPTextureParameter(const char *name)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgGLEnableTextureParameter(param);
+    }
+
+    void enaableFPTextureParameter(const char *name)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgGLEnableTextureParameter(param);
+    }
+
+    void disableVPTextureParameter(const char *name)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgGLDisableTextureParameter(param);
+    }
+
+    void disableFPTextureParameter(const char *name)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgGLDisableTextureParameter(param);
+    }
+
+    void setGLStateMatrixVPParameter(const char *name, GLMatrix matrix,
+                                     GLMatrixType type = MATRIX_IDENTITY)
+    {
+        CGparameter param = getVPParam(name);
+        if (param == NULL)
+            return;
+        cgGLSetStateMatrixParameter(param, (CGGLenum)matrix, (CGGLenum)type);
+    }
+
+    void setGLStateMatrixFPParameter(const char *name, GLMatrix matrix,
+                                     GLMatrixType type = MATRIX_IDENTITY)
+    {
+        CGparameter param = getFPParam(name);
+        if (param == NULL)
+            return;
+        cgGLSetStateMatrixParameter(param, (CGGLenum)matrix, (CGGLenum)type);
+    }
+
+    virtual void bind()
+    {
+        if (_cgVP) {
+            cgGLBindProgram(_cgVP);
+            enableVertexProfile();
+        }
+        if (_cgFP) {
+            cgGLBindProgram(_cgFP);
+            enableFragmentProfile();
+        }
+    }
+
+    virtual void unbind()
+    {
+        if (_cgVP)
+            disableVertexProfile();
+        if (_cgFP)
+            disableFragmentProfile();
+    }
+
+    void enableVertexProfile()
+    {
+        cgGLEnableProfile(_vertexProfile);
+    }
+
+    void disableVertexProfile()
+    {
+        cgGLDisableProfile(_vertexProfile);
+    }
+
+    void enableFragmentProfile()
+    {
+        cgGLEnableProfile(_fragmentProfile);
+    }
+
+    void disableFragmentProfile()
+    {
+        cgGLDisableProfile(_fragmentProfile);
+    }
+
+    static void initCg(CGprofile defaultVertexProfile = CG_PROFILE_VP40,
+                       CGprofile defaultFragmentProfile = CG_PROFILE_FP40);
+
+    static void exitCg();
+
+    static bool printErrorInfo();
+
+    static void setErrorCallback(CgCallbackFunction callback);
+
+    static CGcontext getCgContext()
+    {
+        return _cgContext;
+    }
+
+protected:
+    typedef std::tr1::unordered_map<std::string, CGparameter> ParameterHashmap;
+
+    CGprogram getVP()
+    {
+        return _cgVP;
+    }
+
+    CGprogram getFP()
+    {
+        return _cgFP;
+    }
+
+    CGparameter getVPParam(const char *name)
+    {
+        CGparameter param;
+        ParameterHashmap::iterator itr = _vpParams.find(name);
+        if (itr == _vpParams.end()) {
+            param = getNamedParameterFromVP(name);
+            if (param != NULL)
+                _vpParams[name] = param;
+            else
+                ERROR("Unknown vertex program parameter: %s", name);
+        } else {
+            param = itr->second;
+        }
+        return param;
+    }
+
+    CGparameter getFPParam(const char *name)
+    {
+        CGparameter param;
+        ParameterHashmap::iterator itr = _fpParams.find(name);
+        if (itr == _fpParams.end()) {
+            param = getNamedParameterFromFP(name);
+            if (param != NULL)
+                _fpParams[name] = param;
+            else
+                ERROR("Unknown fragment program parameter: %s", name);
+        } else {
+            param = itr->second;
+        }
+        return param;
+    }
+
+    void resetPrograms();
+
+    CGprofile _vertexProfile;
+    CGprofile _fragmentProfile;
+    std::string _vpFile;
+    CGprogram _cgVP;
+    std::string _fpFile;
+    CGprogram _cgFP;
+    ParameterHashmap _vpParams;
+    ParameterHashmap _fpParams;
+
+    static CGprofile _defaultVertexProfile;
+    static CGprofile _defaultFragmentProfile;
+    static CGcontext _cgContext;
+
+private:
+    static CGprogram
+    loadCgSourceProgram(CGcontext context, const char *filename, 
+                        CGprofile profile, const char *entryPoint);
+};
+
+}
+
+#endif
Index: /trunk/packages/vizservers/nanovis/StdVertexShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/StdVertexShader.cpp	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/StdVertexShader.cpp	(revision 3612)
@@ -0,0 +1,38 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#include "StdVertexShader.h"
+
+using namespace nv;
+
+StdVertexShader::StdVertexShader()
+{
+    init();
+}
+
+StdVertexShader::~StdVertexShader()
+{
+}
+
+void StdVertexShader::init()
+{
+    loadVertexProgram("vertex_std.cg", "main");
+}
+
+void StdVertexShader::bind(float *mvp, float *mvInv)
+{
+    if (mvp != NULL) {
+        setVPMatrixParameterf("modelViewProjMatrix", mvp);
+    } else {
+        setGLStateMatrixVPParameter("modelViewProjMatrix", MODELVIEW_PROJECTION_MATRIX);
+    }
+    if (mvInv != NULL) {
+        setVPMatrixParameterf("modelViewInv", mvInv);
+    } else {
+        setGLStateMatrixVPParameter("modelViewInv", MODELVIEW_MATRIX, MATRIX_INVERSE);
+    }
+
+    Shader::bind();
+}
Index: /trunk/packages/vizservers/nanovis/StdVertexShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/StdVertexShader.h	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/StdVertexShader.h	(revision 3612)
@@ -0,0 +1,34 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#ifndef NV_STD_VERTEX_SHADER_H
+#define NV_STD_VERTEX_SHADER_H
+
+#include "Shader.h"
+
+namespace nv {
+
+class StdVertexShader : public Shader
+{
+public:
+    StdVertexShader();
+
+    virtual ~StdVertexShader();
+
+    virtual void bind(float *mvp = NULL, float *mvInv = NULL);
+
+    virtual void unbind()
+    {
+        Shader::unbind();
+    }
+
+private:
+    void init();
+};
+
+}
+
+#endif 
+
Index: /trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp	(revision 3612)
@@ -19,5 +19,5 @@
 #include "nanovis.h"
 #include "VelocityArrowsSlice.h"
-#include "NvShader.h"
+#include "Shader.h"
 #include "Camera.h"
 
@@ -424,9 +424,9 @@
                                          tan(NanoVis::getCamera()->fov() * 0.5) * NanoVis::winHeight * 0.5);
         _particleShader.setGLStateMatrixVPParameter("modelview",
-                                                    NvShader::MODELVIEW_MATRIX,
-                                                    NvShader::MATRIX_IDENTITY);
+                                                    Shader::MODELVIEW_MATRIX,
+                                                    Shader::MATRIX_IDENTITY);
         _particleShader.setGLStateMatrixVPParameter("mvp",
-                                                    NvShader::MODELVIEW_PROJECTION_MATRIX,
-                                                    NvShader::MATRIX_IDENTITY);
+                                                    Shader::MODELVIEW_PROJECTION_MATRIX,
+                                                    Shader::MATRIX_IDENTITY);
 
         glEnableClientState(GL_VERTEX_ARRAY);
Index: /trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h
===================================================================
--- /trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h	(revision 3612)
@@ -12,5 +12,5 @@
 
 #include "Texture2D.h"
-#include "NvShader.h"
+#include "Shader.h"
 
 namespace nv {
@@ -105,7 +105,6 @@
     float _maxPointSize;
 
-    NvShader _queryVelocityFP;
-
-    NvShader _particleShader;
+    Shader _queryVelocityFP;
+    Shader _particleShader;
 
     int _renderTargetWidth;
Index: /trunk/packages/vizservers/nanovis/VolumeRenderer.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/VolumeRenderer.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/VolumeRenderer.cpp	(revision 3612)
@@ -28,5 +28,5 @@
 #include "Plane.h"
 #include "ConvexPolygon.h"
-#include "NvStdVertexShader.h"
+#include "StdVertexShader.h"
 #include "Trace.h"
 
@@ -53,13 +53,13 @@
 void VolumeRenderer::initShaders()
 {
-    _cutplaneShader = new NvShader();
+    _cutplaneShader = new Shader();
     _cutplaneShader->loadVertexProgram("cutplane_vp.cg", "main");
     _cutplaneShader->loadFragmentProgram("cutplane_fp.cg", "main");
 
     //standard vertex program
-    _stdVertexShader = new NvStdVertexShader();
+    _stdVertexShader = new StdVertexShader();
 
     //volume rendering shader: one cubic volume
-    _regularVolumeShader = new NvRegularVolumeShader();
+    _regularVolumeShader = new RegularVolumeShader();
 
     //volume rendering shader: one zincblende orbital volume.
@@ -71,5 +71,5 @@
     //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on
     //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering.
-    _zincBlendeShader = new NvZincBlendeVolumeShader();
+    _zincBlendeShader = new ZincBlendeVolumeShader();
 }
 
@@ -287,5 +287,5 @@
             glScalef(volScaling.x, volScaling.y, volScaling.z);
             _cutplaneShader->setGLStateMatrixVPParameter("modelViewProjMatrix",
-                                                         NvShader::MODELVIEW_PROJECTION_MATRIX);
+                                                         Shader::MODELVIEW_PROJECTION_MATRIX);
             glPopMatrix();
 
Index: /trunk/packages/vizservers/nanovis/VolumeRenderer.h
===================================================================
--- /trunk/packages/vizservers/nanovis/VolumeRenderer.h	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/VolumeRenderer.h	(revision 3612)
@@ -21,7 +21,7 @@
 #include "Volume.h"
 #include "VolumeInterpolator.h"
-#include "NvRegularVolumeShader.h"
-#include "NvZincBlendeVolumeShader.h"
-#include "NvStdVertexShader.h"
+#include "RegularVolumeShader.h"
+#include "ZincBlendeVolumeShader.h"
+#include "StdVertexShader.h"
 
 namespace nv {
@@ -87,10 +87,10 @@
      * Shader for single slice cutplane render
      */
-    NvShader *_cutplaneShader;
+    Shader *_cutplaneShader;
 
     /**
      * Shader for rendering a single cubic volume
      */
-    NvRegularVolumeShader *_regularVolumeShader;
+    RegularVolumeShader *_regularVolumeShader;
 
     /**
@@ -108,10 +108,10 @@
      * same space.
      */
-    NvZincBlendeVolumeShader *_zincBlendeShader;
+    ZincBlendeVolumeShader *_zincBlendeShader;
 
     /**
      * standard vertex shader 
      */
-    NvStdVertexShader *_stdVertexShader;
+    StdVertexShader *_stdVertexShader;
 };
 
Index: /trunk/packages/vizservers/nanovis/VolumeShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/VolumeShader.cpp	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/VolumeShader.cpp	(revision 3612)
@@ -0,0 +1,17 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#include "VolumeShader.h"
+
+using namespace nv;
+
+VolumeShader::VolumeShader()
+{
+}
+
+VolumeShader::~VolumeShader()
+{
+}
+
Index: /trunk/packages/vizservers/nanovis/VolumeShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/VolumeShader.h	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/VolumeShader.h	(revision 3612)
@@ -0,0 +1,35 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#ifndef NV_VOLUME_SHADER_H
+#define NV_VOLUME_SHADER_H
+
+#include "Shader.h"
+
+namespace nv {
+
+class Volume;
+
+class VolumeShader : public Shader
+{
+public :
+    virtual ~VolumeShader();
+
+    virtual void bind(unsigned int tfID, Volume *volume,
+                      int sliceMode, float sampleRatio) = 0;
+
+    virtual void unbind()
+    {
+        Shader::unbind();
+    }
+
+protected :
+    VolumeShader();
+};
+
+}
+
+#endif // 
+
Index: /trunk/packages/vizservers/nanovis/ZincBlendeVolumeShader.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/ZincBlendeVolumeShader.cpp	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/ZincBlendeVolumeShader.cpp	(revision 3612)
@@ -0,0 +1,58 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+
+#include "ZincBlendeVolumeShader.h"
+#include "ZincBlendeVolume.h"
+
+using namespace nv;
+
+ZincBlendeVolumeShader::ZincBlendeVolumeShader()
+{
+    init();
+}
+
+ZincBlendeVolumeShader::~ZincBlendeVolumeShader()
+{
+}
+
+void ZincBlendeVolumeShader::init()
+{
+    loadFragmentProgram("zincblende_volume.cg", "main");
+}
+
+void ZincBlendeVolumeShader::bind(unsigned int tfID, Volume *volume,
+                                    int sliceMode, float sampleRatio)
+{
+    ZincBlendeVolume *vol = (ZincBlendeVolume *)volume;
+    setGLStateMatrixFPParameter("modelViewInv", MODELVIEW_MATRIX,
+                                MATRIX_INVERSE);
+
+    setFPTextureParameter("tf", tfID);
+    setFPTextureParameter("volumeA", vol->zincblendeTex[0]->id());
+    setFPTextureParameter("volumeB", vol->zincblendeTex[1]->id());
+
+    setFPParameter4f("cellSize",
+                     vol->cellSize.x,
+                     vol->cellSize.y,
+                     vol->cellSize.z, 0.);
+
+    setFPParameter4f("renderParams",
+                     (sliceMode ? 0.0f : sampleRatio),
+                     volume->isosurface(),
+                     volume->opacityScale(),
+                     0.0f);
+
+    Shader::bind();
+}
+
+void ZincBlendeVolumeShader::unbind() 
+{
+    disableFPTextureParameter("tf");
+    disableFPTextureParameter("volumeA");
+    disableFPTextureParameter("volumeB");
+
+    Shader::unbind();
+}
Index: /trunk/packages/vizservers/nanovis/ZincBlendeVolumeShader.h
===================================================================
--- /trunk/packages/vizservers/nanovis/ZincBlendeVolumeShader.h	(revision 3612)
+++ /trunk/packages/vizservers/nanovis/ZincBlendeVolumeShader.h	(revision 3612)
@@ -0,0 +1,31 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright (c) 2004-2013  HUBzero Foundation, LLC
+ *
+ */
+#ifndef NV_ZINCBLENDE_SHADER_H
+#define NV_ZINCBLENDE_SHADER_H
+
+#include "VolumeShader.h"
+
+namespace nv {
+
+class ZincBlendeVolumeShader : public VolumeShader
+{
+public:
+    ZincBlendeVolumeShader();
+
+    virtual ~ZincBlendeVolumeShader();
+
+    virtual void bind(unsigned int tfID, Volume *volume,
+                      int sliceMode, float sampleRatio);
+
+    virtual void unbind();
+
+private:
+    void init();
+};
+
+}
+
+#endif 
Index: /trunk/packages/vizservers/nanovis/nanovis.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/nanovis.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/nanovis.cpp	(revision 3612)
@@ -42,5 +42,5 @@
 #include "Camera.h"
 #include "LIC.h"
-#include "NvShader.h"
+#include "Shader.h"
 #include "OrientationIndicator.h"
 #include "PlaneRenderer.h"
@@ -461,5 +461,5 @@
 void cgErrorCallback(void)
 {
-    if (!NvShader::printErrorInfo()) {
+    if (!Shader::printErrorInfo()) {
         TRACE("Cg error, exiting...");
         exit(1);
@@ -536,6 +536,6 @@
     ImageLoaderFactory::getInstance()->addLoaderImpl("bmp", new BMPImageLoaderImpl());
 
-    NvShader::initCg();
-    NvShader::setErrorCallback(cgErrorCallback);
+    Shader::initCg();
+    Shader::setErrorCallback(cgErrorCallback);
 
     fonts = new Fonts();
Index: /trunk/packages/vizservers/nanovis/nanovisServer.cpp
===================================================================
--- /trunk/packages/vizservers/nanovis/nanovisServer.cpp	(revision 3611)
+++ /trunk/packages/vizservers/nanovis/nanovisServer.cpp	(revision 3612)
@@ -33,5 +33,5 @@
 #include "PPMWriter.h"
 #include "ReadBuffer.h"
-#include "NvShader.h"
+#include "Shader.h"
 #ifdef USE_THREADS
 #include <pthread.h>
@@ -352,5 +352,5 @@
     NanoVis::removeAllData();
 
-    NvShader::exitCg();
+    Shader::exitCg();
 
     //close log file
@@ -436,5 +436,5 @@
 void cgErrorCallback(void)
 {
-    if (!NvShader::printErrorInfo()) {
+    if (!Shader::printErrorInfo()) {
         TRACE("Cg error, exiting...");
         exitService(1);
@@ -580,5 +580,5 @@
 
     // Override callback with one that cleans up server on exit
-    NvShader::setErrorCallback(cgErrorCallback);
+    Shader::setErrorCallback(cgErrorCallback);
 
     if (!NanoVis::initGL()) {
