Commit de8deb6a authored by Ken Martin's avatar Ken Martin
Browse files

Use MCDCMatrix in shaders

A few changes here. The motivation is to support using the MCDCMatrix
in the vertex shader where possible. This has the advantage of
performing the MCVC x VCDC multiplication in double precision
on the CPU as opposed to float precision on the shader. This fixes
a couple test failures.

Along with that change cleanup a bit how we determine what uniforms
to set. There were some uniforms being set when they did not exist
in the program. Provided a more general approach for passing that
type of information between the code that builds the shader program
and the code that sets the uniforms.

Add a substitute helper function that does the same job as replace
but returns a bool if a replacement was made. Also operates on
the source string by reference.

Cleaned up some long lines to be shorter.

Change-Id: Ic23133679f1d40d51c29f11810d29baf85edd306
parent 33b149bd
......@@ -43,8 +43,7 @@ uniform mat3 normalMatrix; // transform model coordinate directions to view coor
//VTK::Clip::Dec
// camera and actor matrix values
uniform mat4 MCVCMatrix; // combined Model to View transform
uniform mat4 VCDCMatrix; // the camera's projection matrix
//VTK::Camera::Dec
varying vec4 vertexVCClose;
varying float radiusVC;
......
......@@ -47,8 +47,7 @@ uniform mat3 normalMatrix; // transform model coordinate directions to view coor
//VTK::Clip::Dec
// camera and actor matrix values
uniform mat4 MCVCMatrix; // combined Model to View transform
uniform mat4 VCDCMatrix; // the camera's projection matrix
//VTK::Camera::Dec
varying vec4 vertexVCClose;
varying float radiusVC;
......
......@@ -15,9 +15,10 @@
#include "vtkglVBOHelper.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkMath.h"
#include "vtkMatrix4x4.h"
#include "vtkOpenGLActor.h"
#include "vtkOpenGLCamera.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
......@@ -27,7 +28,7 @@
#include "vtkSphereMapperVS.h"
using vtkgl::replace;
using vtkgl::substitute;
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkOpenGLSphereMapper)
......@@ -41,11 +42,12 @@ vtkOpenGLSphereMapper::vtkOpenGLSphereMapper()
//-----------------------------------------------------------------------------
void vtkOpenGLSphereMapper::GetShaderTemplate(std::string &VSSource,
std::string &FSSource,
std::string &GSSource,
int lightComplexity, vtkRenderer* ren, vtkActor *actor)
std::string &FSSource,
std::string &GSSource,
int lightComplexity, vtkRenderer* ren, vtkActor *actor)
{
this->Superclass::GetShaderTemplate(VSSource,FSSource,GSSource,lightComplexity,ren,actor);
this->Superclass::GetShaderTemplate(VSSource,FSSource,GSSource,
lightComplexity,ren,actor);
VSSource = vtkSphereMapperVS;
}
......@@ -57,7 +59,12 @@ void vtkOpenGLSphereMapper::ReplaceShaderValues(std::string &VSSource,
vtkRenderer* ren,
vtkActor *actor)
{
FSSource = replace(FSSource,
substitute(VSSource,
"//VTK::Camera::Dec",
"uniform mat4 VCDCMatrix;\n"
"uniform mat4 MCVCMatrix;");
substitute(FSSource,
"//VTK::PositionVC::Dec",
"varying vec4 vertexVCClose;");
......@@ -73,9 +80,9 @@ void vtkOpenGLSphereMapper::ReplaceShaderValues(std::string &VSSource,
{
replacement += "uniform mat4 VCDCMatrix;\n";
}
FSSource = replace(FSSource,"//VTK::Normal::Dec",replacement);
substitute(FSSource,"//VTK::Normal::Dec",replacement);
FSSource = replace(FSSource,"//VTK::Normal::Impl",
substitute(FSSource,"//VTK::Normal::Impl",
// compute the eye position and unit direction
"vec4 vertexVC = vertexVCClose;\n"
" vec3 EyePos = vec3(0.0,0.0,0.0);\n"
......@@ -114,7 +121,7 @@ void vtkOpenGLSphereMapper::ReplaceShaderValues(std::string &VSSource,
if (ren->GetLastRenderingUsedDepthPeeling())
{
FSSource = vtkgl::replace(FSSource,
substitute(FSSource,
"//VTK::DepthPeeling::Impl",
"float odepth = texture2D(opaqueZTexture, gl_FragCoord.xy/screenSize).r;\n"
" if (gl_FragDepth >= odepth) { discard; }\n"
......@@ -123,7 +130,8 @@ void vtkOpenGLSphereMapper::ReplaceShaderValues(std::string &VSSource,
);
}
this->Superclass::ReplaceShaderValues(VSSource,FSSource,GSSource,lightComplexity,ren,actor);
this->Superclass::ReplaceShaderValues(VSSource,FSSource,GSSource,
lightComplexity,ren,actor);
}
//-----------------------------------------------------------------------------
......@@ -134,14 +142,34 @@ vtkOpenGLSphereMapper::~vtkOpenGLSphereMapper()
//-----------------------------------------------------------------------------
void vtkOpenGLSphereMapper::SetCameraShaderParameters(vtkgl::CellBO &cellBO,
vtkRenderer* ren, vtkActor *actor)
void vtkOpenGLSphereMapper::SetCameraShaderParameters(
vtkgl::CellBO &cellBO,
vtkRenderer* ren, vtkActor *actor)
{
// do the superclass and then reset a couple values
this->Superclass::SetCameraShaderParameters(cellBO,ren,actor);
vtkShaderProgram *program = cellBO.Program;
vtkOpenGLCamera *cam = (vtkOpenGLCamera *)(ren->GetActiveCamera());
vtkMatrix4x4 *wcdc;
vtkMatrix4x4 *wcvc;
vtkMatrix3x3 *norms;
vtkMatrix4x4 *vcdc;
cam->GetKeyMatrices(ren,wcvc,norms,vcdc,wcdc);
program->SetUniformMatrix("VCDCMatrix", vcdc);
if (!actor->GetIsIdentity())
{
vtkMatrix4x4 *mcwc;
vtkMatrix3x3 *anorms;
((vtkOpenGLActor *)actor)->GetKeyMatrices(mcwc,anorms);
vtkMatrix4x4::Multiply4x4(mcwc, wcvc, this->TempMatrix4);
program->SetUniformMatrix("MCVCMatrix", this->TempMatrix4);
}
else
{
program->SetUniformMatrix("MCVCMatrix", wcvc);
}
// add in uniforms for parallel and distance
vtkCamera *cam = ren->GetActiveCamera();
cellBO.Program->SetUniformi("cameraParallel", cam->GetParallelProjection());
}
......
......@@ -15,7 +15,10 @@
#include "vtkglVBOHelper.h"
#include "vtkCamera.h"
#include "vtkMatrix3x3.h"
#include "vtkMatrix4x4.h"
#include "vtkOpenGLActor.h"
#include "vtkOpenGLCamera.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
......@@ -26,7 +29,7 @@
#include "vtkStickMapperVS.h"
using vtkgl::replace;
using vtkgl::substitute;
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkOpenGLStickMapper)
......@@ -57,7 +60,12 @@ void vtkOpenGLStickMapper::ReplaceShaderValues(std::string &VSSource,
vtkRenderer* ren,
vtkActor *actor)
{
FSSource = replace(FSSource,
substitute(VSSource,
"//VTK::Camera::Dec",
"uniform mat4 VCDCMatrix;\n"
"uniform mat4 MCVCMatrix;");
substitute(FSSource,
"//VTK::PositionVC::Dec",
"varying vec4 vertexVCClose;");
......@@ -74,11 +82,11 @@ void vtkOpenGLStickMapper::ReplaceShaderValues(std::string &VSSource,
{
replacement += "uniform mat4 VCDCMatrix;\n";
}
FSSource = replace(FSSource,"//VTK::Normal::Dec",replacement);
substitute(FSSource,"//VTK::Normal::Dec",replacement);
// see https://www.cl.cam.ac.uk/teaching/1999/AGraphHCI/SMAG/node2.html
FSSource = replace(FSSource,"//VTK::Normal::Impl",
substitute(FSSource,"//VTK::Normal::Impl",
// compute the eye position and unit direction
" vec4 vertexVC = vertexVCClose;\n"
" vec3 EyePos = vec3(0.0,0.0,0.0);\n"
......@@ -88,7 +96,8 @@ void vtkOpenGLStickMapper::ReplaceShaderValues(std::string &VSSource,
" vec3 EyeDir = vertexVC.xyz - EyePos;\n"
" float lengthED = length(EyeDir);\n"
" EyeDir = normalize(EyeDir);\n"
" if (lengthED > (radiusVC+lengthVC)*3.0) { EyePos = vertexVC.xyz - EyeDir*3.0*(radiusVC+lengthVC);}\n"
" if (lengthED > (radiusVC+lengthVC)*3.0) \n"
" { EyePos = vertexVC.xyz - EyeDir*3.0*(radiusVC+lengthVC);}\n"
// translate to Cylinder center
" EyePos = EyePos - centerVC;\n"
......@@ -148,18 +157,18 @@ void vtkOpenGLStickMapper::ReplaceShaderValues(std::string &VSSource,
bool picking = (ren->GetRenderWindow()->GetIsPicking() || selector != NULL);
if (picking)
{
VSSource = vtkgl::replace(VSSource,
substitute(VSSource,
"//VTK::Picking::Dec",
"attribute vec4 selectionId;\n"
"varying vec4 selectionIdFrag;");
VSSource = vtkgl::replace(VSSource,
substitute(VSSource,
"//VTK::Picking::Impl",
"selectionIdFrag = selectionId;");
FSSource = vtkgl::replace(FSSource,
substitute(FSSource,
"//VTK::Picking::Dec",
"uniform vec3 mapperIndex;\n"
"varying vec4 selectionIdFrag;");
FSSource = vtkgl::replace(FSSource,
substitute(FSSource,
"//VTK::Picking::Impl",
"if (mapperIndex == vec3(0.0,0.0,0.0))\n"
" {\n"
......@@ -174,7 +183,7 @@ void vtkOpenGLStickMapper::ReplaceShaderValues(std::string &VSSource,
if (ren->GetLastRenderingUsedDepthPeeling())
{
FSSource = vtkgl::replace(FSSource,
substitute(FSSource,
"//VTK::DepthPeeling::Impl",
"float odepth = texture2D(opaqueZTexture, gl_FragCoord.xy/screenSize).r;\n"
" if (gl_FragDepth >= odepth) { discard; }\n"
......@@ -201,11 +210,33 @@ vtkOpenGLStickMapper::~vtkOpenGLStickMapper()
void vtkOpenGLStickMapper::SetCameraShaderParameters(vtkgl::CellBO &cellBO,
vtkRenderer* ren, vtkActor *actor)
{
// do the superclass and then reset a couple values
this->Superclass::SetCameraShaderParameters(cellBO,ren,actor);
vtkShaderProgram *program = cellBO.Program;
vtkOpenGLCamera *cam = (vtkOpenGLCamera *)(ren->GetActiveCamera());
vtkMatrix4x4 *wcdc;
vtkMatrix4x4 *wcvc;
vtkMatrix3x3 *norms;
vtkMatrix4x4 *vcdc;
cam->GetKeyMatrices(ren,wcvc,norms,vcdc,wcdc);
program->SetUniformMatrix("VCDCMatrix", vcdc);
if (!actor->GetIsIdentity())
{
vtkMatrix4x4 *mcwc;
vtkMatrix3x3 *anorms;
((vtkOpenGLActor *)actor)->GetKeyMatrices(mcwc,anorms);
vtkMatrix4x4::Multiply4x4(mcwc, wcvc, this->TempMatrix4);
program->SetUniformMatrix("MCVCMatrix", this->TempMatrix4);
vtkMatrix3x3::Multiply3x3(anorms, norms, this->TempMatrix3);
program->SetUniformMatrix("normalMatrix", this->TempMatrix3);
}
else
{
program->SetUniformMatrix("MCVCMatrix", wcvc);
program->SetUniformMatrix("normalMatrix", norms);
}
// add in uniforms for parallel and distance
vtkCamera *cam = ren->GetActiveCamera();
cellBO.Program->SetUniformi("cameraParallel", cam->GetParallelProjection());
}
......
......@@ -35,8 +35,6 @@ attribute vec2 offsetMC;
// Texture coordinates
//VTK::TCoord::Dec
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
// material property values
//VTK::Color::Dec
......@@ -44,8 +42,7 @@ uniform mat3 normalMatrix; // transform model coordinate directions to view coor
//VTK::Clip::Dec
// camera and actor matrix values
uniform mat4 MCVCMatrix; // combined Model to View transform
uniform mat4 VCDCMatrix; // the camera's projection matrix
//VTK::Camera::Dec
varying vec2 offsetVC;
uniform int cameraParallel;
......
......@@ -37,14 +37,11 @@ attribute vec4 vertexMC;
// Texture coordinates
//VTK::TCoord::Dec
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
// material property values
//VTK::Color::Dec
// camera and actor matrix values
uniform mat4 MCVCMatrix; // combined Model to View transform
uniform mat4 VCDCMatrix; // the camera's projection matrix
//VTK::Camera::Dec
//VTK::Glyph::Dec
......
......@@ -26,10 +26,7 @@
// DC - Display Coordinates
// camera and actor matrix values
uniform mat4 MCVCMatrix; // combined Model to View transform
uniform mat4 VCDCMatrix; // the camera's projection matrix
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
//VTK::Camera::Dec
uniform int numberOfLights; // only allow for up to 6 active lights
uniform vec3 lightColor[6]; // intensity weighted color
......
......@@ -27,10 +27,7 @@
// DC - Display Coordinates
// camera and actor matrix values
uniform mat4 MCVCMatrix; // combined Model to View transform
uniform mat4 VCDCMatrix; // the camera's projection matrix
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
//VTK::Camera::Dec
uniform int numberOfLights; // only allow for up to 6 active lights
uniform vec3 lightColor[6]; // intensity weighted color
......
......@@ -37,8 +37,6 @@ attribute vec4 vertexMC;
// Texture coordinates
//VTK::TCoord::Dec
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
// material property values
//VTK::Color::Dec
......@@ -46,8 +44,7 @@ uniform mat3 normalMatrix; // transform model coordinate directions to view coor
//VTK::Clip::Dec
// camera and actor matrix values
uniform mat4 MCVCMatrix; // combined Model to View transform
uniform mat4 VCDCMatrix; // the camera's projection matrix
//VTK::Camera::Dec
void main()
{
......
......@@ -31,8 +31,7 @@ attribute vec4 vertexMC;
//VTK::Color::Dec
// camera and actor matrix values
uniform mat4 MCVCMatrix; // combined Model to View transform
uniform mat4 VCDCMatrix; // the camera's projection matrix
//VTK::Camera::Dec
// Texture coordinates
//VTK::TCoord::Dec
......
......@@ -28,6 +28,7 @@ vtkStandardNewMacro(vtkOpenGLCamera);
vtkOpenGLCamera::vtkOpenGLCamera()
{
this->WCDCMatrix = vtkMatrix4x4::New();
this->WCVCMatrix = vtkMatrix4x4::New();
this->NormalMatrix = vtkMatrix3x3::New();
this->VCDCMatrix = vtkMatrix4x4::New();
......@@ -36,6 +37,7 @@ vtkOpenGLCamera::vtkOpenGLCamera()
vtkOpenGLCamera::~vtkOpenGLCamera()
{
this->WCDCMatrix->Delete();
this->WCVCMatrix->Delete();
this->NormalMatrix->Delete();
this->VCDCMatrix->Delete();
......@@ -156,7 +158,7 @@ void vtkOpenGLCamera::PrintSelf(ostream& os, vtkIndent indent)
}
void vtkOpenGLCamera::GetKeyMatrices(vtkRenderer *ren, vtkMatrix4x4 *&wcvc,
vtkMatrix3x3 *&normMat, vtkMatrix4x4 *&vcdc)
vtkMatrix3x3 *&normMat, vtkMatrix4x4 *&vcdc, vtkMatrix4x4 *&wcdc)
{
// has the camera changed?
if (ren != this->LastRenderer ||
......@@ -195,6 +197,8 @@ void vtkOpenGLCamera::GetKeyMatrices(vtkRenderer *ren, vtkMatrix4x4 *&wcvc,
this->VCDCMatrix->Transpose();
}
vtkMatrix4x4::Multiply4x4(this->WCVCMatrix, this->VCDCMatrix, this->WCDCMatrix);
this->KeyMatrixTime.Modified();
this->LastRenderer = ren;
}
......@@ -202,4 +206,5 @@ void vtkOpenGLCamera::GetKeyMatrices(vtkRenderer *ren, vtkMatrix4x4 *&wcvc,
wcvc = this->WCVCMatrix;
normMat = this->NormalMatrix;
vcdc = this->VCDCMatrix;
wcdc = this->WCDCMatrix;
}
\ No newline at end of file
......@@ -40,12 +40,13 @@ public:
void UpdateViewport(vtkRenderer *ren);
void GetKeyMatrices(vtkRenderer *ren, vtkMatrix4x4 *&WCVCMatrix,
vtkMatrix3x3 *&normalMatrix, vtkMatrix4x4 *&VCDCMatrix);
vtkMatrix3x3 *&normalMatrix, vtkMatrix4x4 *&VCDCMatrix, vtkMatrix4x4 *&WCDCMatrix);
protected:
vtkOpenGLCamera();
~vtkOpenGLCamera();
vtkMatrix4x4 *WCDCMatrix;
vtkMatrix4x4 *WCVCMatrix;
vtkMatrix3x3 *NormalMatrix;
vtkMatrix4x4 *VCDCMatrix;
......
......@@ -36,7 +36,7 @@
#include "vtkglGlyph3DVSFragmentLit.h"
using vtkgl::replace;
using vtkgl::substitute;
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkOpenGLGlyph3DHelper)
......@@ -77,28 +77,28 @@ void vtkOpenGLGlyph3DHelper::ReplaceShaderValues(std::string &VSSource,
if (lightComplexity > 0)
{
// we use vertex instead of vertexMC
VSSource = replace(VSSource,
substitute(VSSource,
"//VTK::PositionVC::Impl",
"vertexVC = MCVCMatrix * vertex;\n"
" gl_Position = VCDCMatrix * vertexVC;\n");
" gl_Position = MCDCMatrix * vertex;\n");
}
// deal with color
if (this->UsingInstancing)
{
VSSource = replace(VSSource,"//VTK::Color::Dec",
"attribute vec4 glyphColor;\n"
"varying vec4 vertexColor;");
substitute(VSSource,"//VTK::Color::Dec",
"attribute vec4 glyphColor;\n"
"varying vec4 vertexColor;");
}
else
{
VSSource = replace(VSSource,
"//VTK::Color::Dec",
"uniform vec4 glyphColor;\n"
"varying vec4 vertexColor;");
substitute(VSSource,
"//VTK::Color::Dec",
"uniform vec4 glyphColor;\n"
"varying vec4 vertexColor;");
}
VSSource = replace(VSSource,"//VTK::Color::Impl",
"vertexColor = glyphColor;");
substitute(VSSource,"//VTK::Color::Impl",
"vertexColor = glyphColor;");
// crate the material/color property declarations, and VS implementation
......@@ -129,7 +129,7 @@ void vtkOpenGLGlyph3DHelper::ReplaceShaderValues(std::string &VSSource,
}
}
colorDec += "varying vec4 vertexColor;\n";
FSSource = replace(FSSource,"//VTK::Color::Dec", colorDec);
substitute(FSSource,"//VTK::Color::Dec", colorDec);
// now handle the more complex fragment shader implementation
// the following are always defined variables. We start
......@@ -191,40 +191,42 @@ void vtkOpenGLGlyph3DHelper::ReplaceShaderValues(std::string &VSSource,
// now handle scalar coloring
if (this->ScalarMaterialMode == VTK_MATERIALMODE_AMBIENT ||
(this->ScalarMaterialMode == VTK_MATERIALMODE_DEFAULT && actor->GetProperty()->GetAmbient() > actor->GetProperty()->GetDiffuse()))
(this->ScalarMaterialMode == VTK_MATERIALMODE_DEFAULT &&
actor->GetProperty()->GetAmbient() > actor->GetProperty()->GetDiffuse()))
{
FSSource = replace(FSSource,"//VTK::Color::Impl", colorImpl +
" ambientColor = vertexColor.rgb;\n"
" opacity = vertexColor.a;");
substitute(FSSource,"//VTK::Color::Impl", colorImpl +
" ambientColor = vertexColor.rgb;\n"
" opacity = vertexColor.a;");
}
else if (this->ScalarMaterialMode == VTK_MATERIALMODE_DIFFUSE ||
(this->ScalarMaterialMode == VTK_MATERIALMODE_DEFAULT && actor->GetProperty()->GetAmbient() <= actor->GetProperty()->GetDiffuse()))
(this->ScalarMaterialMode == VTK_MATERIALMODE_DEFAULT &&
actor->GetProperty()->GetAmbient() <= actor->GetProperty()->GetDiffuse()))
{
FSSource = replace(FSSource,"//VTK::Color::Impl", colorImpl +
" diffuseColor = vertexColor.rgb;\n"
" opacity = vertexColor.a;");
substitute(FSSource,"//VTK::Color::Impl", colorImpl +
" diffuseColor = vertexColor.rgb;\n"
" opacity = vertexColor.a;");
}
else
{
FSSource = replace(FSSource,"//VTK::Color::Impl", colorImpl +
" diffuseColor = vertexColor.rgb;\n"
" ambientColor = vertexColor.rgb;\n"
" opacity = vertexColor.a;");
substitute(FSSource,"//VTK::Color::Impl", colorImpl +
" diffuseColor = vertexColor.rgb;\n"
" ambientColor = vertexColor.rgb;\n"
" opacity = vertexColor.a;");
}
if (this->UsingInstancing)
{
VSSource = replace(VSSource,
substitute(VSSource,
"//VTK::Glyph::Dec",
"attribute mat4 GCMCMatrix;");
}
else
{
VSSource = replace(VSSource,
substitute(VSSource,
"//VTK::Glyph::Dec",
"uniform mat4 GCMCMatrix;");
}
VSSource = replace(VSSource,
substitute(VSSource,
"//VTK::Glyph::Impl",
"vec4 vertex = GCMCMatrix * vertexMC;\n");
......@@ -233,23 +235,25 @@ void vtkOpenGLGlyph3DHelper::ReplaceShaderValues(std::string &VSSource,
{
if (this->UsingInstancing)
{
VSSource = replace(VSSource,
"//VTK::Normal::Dec",
"attribute vec3 normalMC;\n"
"attribute mat3 glyphNormalMatrix;\n"
"varying vec3 normalVCVarying;");
substitute(VSSource,
"//VTK::Normal::Dec",
"uniform mat3 normalMatrix;\n"
"attribute vec3 normalMC;\n"
"attribute mat3 glyphNormalMatrix;\n"
"varying vec3 normalVCVarying;");
}
else
{
VSSource = replace(VSSource,
"//VTK::Normal::Dec",
"attribute vec3 normalMC;\n"
"uniform mat3 glyphNormalMatrix;\n"
"varying vec3 normalVCVarying;");
substitute(VSSource,
"//VTK::Normal::Dec",
"uniform mat3 normalMatrix;\n"
"attribute vec3 normalMC;\n"
"uniform mat3 glyphNormalMatrix;\n"
"varying vec3 normalVCVarying;");
}
VSSource = replace(VSSource,
"//VTK::Normal::Impl",
"normalVCVarying = normalMatrix * glyphNormalMatrix * normalMC;");
substitute(VSSource, "//VTK::Normal::Impl",
"normalVCVarying = normalMatrix * glyphNormalMatrix * normalMC;");
this->ShaderVariablesUsed.push_back("normalMatrix");
}
// override one part of the clipping code
......@@ -263,16 +267,17 @@ void vtkOpenGLGlyph3DHelper::ReplaceShaderValues(std::string &VSSource,
numClipPlanes = 6;
}
VSSource = vtkgl::replace(VSSource,
"//VTK::Clip::Impl",
"for (int planeNum = 0; planeNum < numClipPlanes; planeNum++)\n"
" {\n"
" clipDistances[planeNum] = dot(clipPlanes[planeNum], vertex);\n"
" }\n");
substitute(VSSource,
"//VTK::Clip::Impl",
"for (int planeNum = 0; planeNum < numClipPlanes; planeNum++)\n"
" {\n"
" clipDistances[planeNum] = dot(clipPlanes[planeNum], vertex);\n"
" }\n");
}
this->Superclass::ReplaceShaderValues(VSSource,FSSource,GSSource,lightComplexity,ren,actor);
this->Superclass::ReplaceShaderValues(VSSource,FSSource,GSSource,
lightComplexity,ren,actor);
}
//-----------------------------------------------------------------------------
......@@ -328,7 +333,8 @@ void vtkOpenGLGlyph3DHelper::GlyphRender(vtkRenderer* ren, vtkActor* actor, vtkI
program->SetUniformMatrix4x4("GCMCMatrix", &(matrices[inPtId*16]));
// for lit shaders set normal matrix
if (this->LastLightComplexity > 0 && this->Layout.NormalOffset)
if (this->LastLightComplexity > 0 && this->Layout.NormalOffset &&
!this->UsingInstancing)
{
program->SetUniformMatrix3x3("glyphNormalMatrix", &(normalMatrices[inPtId*9]));