Commit d62e0743 authored by Ken Martin's avatar Ken Martin

Some more code cleanups, this time shader related

Add an option to Ready a shader program based on a vector of shaders

Rename some functions to match what they do

Cleanup some memory leaks in the LIC code
parent 046584f7
......@@ -46,24 +46,21 @@ vtkOpenGLSphereMapper::vtkOpenGLSphereMapper()
}
//-----------------------------------------------------------------------------
void vtkOpenGLSphereMapper::GetShaderTemplate(std::string &VSSource,
std::string &FSSource,
std::string &GSSource,
int lightComplexity, vtkRenderer* ren, vtkActor *actor)
void vtkOpenGLSphereMapper::GetShaderTemplate(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *actor)
{
this->Superclass::GetShaderTemplate(VSSource,FSSource,GSSource,
lightComplexity,ren,actor);
VSSource = vtkSphereMapperVS;
this->Superclass::GetShaderTemplate(shaders,ren,actor);
shaders[vtkShader::Vertex]->SetSource(vtkSphereMapperVS);
}
void vtkOpenGLSphereMapper::ReplaceShaderValues(std::string &VSSource,
std::string &FSSource,
std::string &GSSource,
int lightComplexity,
vtkRenderer* ren,
vtkActor *actor)
void vtkOpenGLSphereMapper::ReplaceShaderValues(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *actor)
{
std::string VSSource = shaders[vtkShader::Vertex]->GetSource();
std::string FSSource = shaders[vtkShader::Fragment]->GetSource();
vtkShaderProgram::Substitute(VSSource,
"//VTK::Camera::Dec",
"uniform mat4 VCDCMatrix;\n"
......@@ -138,8 +135,10 @@ void vtkOpenGLSphereMapper::ReplaceShaderValues(std::string &VSSource,
);
}
this->Superclass::ReplaceShaderValues(VSSource,FSSource,GSSource,
lightComplexity,ren,actor);
shaders[vtkShader::Vertex]->SetSource(VSSource);
shaders[vtkShader::Fragment]->SetSource(FSSource);
this->Superclass::ReplaceShaderValues(shaders,ren,actor);
}
//-----------------------------------------------------------------------------
......@@ -350,7 +349,7 @@ void vtkOpenGLSphereMapper::RenderPieceDraw(vtkRenderer* ren, vtkActor *actor)
if (this->Tris.IBO->IndexCount)
{
// First we do the triangles, update the shader, set uniforms, etc.
this->UpdateShader(this->Tris, ren, actor);
this->UpdateShaders(this->Tris, ren, actor);
glDrawArrays(GL_TRIANGLES, 0,
static_cast<GLuint>(this->VBO->VertexCount));
}
......
......@@ -43,19 +43,15 @@ protected:
// Description:
// Create the basic shaders before replacement
virtual void GetShaderTemplate(std::string &VertexCode,
std::string &fragmentCode,
std::string &geometryCode,
int lightComplexity,
vtkRenderer *ren, vtkActor *act);
virtual void GetShaderTemplate(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *act);
// Description:
// Perform string replacments on the shader templates
virtual void ReplaceShaderValues(std::string &VertexCode,
std::string &fragmentCode,
std::string &geometryCode,
int lightComplexity,
vtkRenderer *ren, vtkActor *act);
virtual void ReplaceShaderValues(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *act);
// Description:
// Set the shader parameters related to the Camera
......
......@@ -48,23 +48,21 @@ vtkOpenGLStickMapper::vtkOpenGLStickMapper()
}
//-----------------------------------------------------------------------------
void vtkOpenGLStickMapper::GetShaderTemplate(std::string &VSSource,
std::string &FSSource,
std::string &GSSource,
int lightComplexity, vtkRenderer* ren, vtkActor *actor)
void vtkOpenGLStickMapper::GetShaderTemplate(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *actor)
{
this->Superclass::GetShaderTemplate(VSSource,FSSource,GSSource,lightComplexity,ren,actor);
VSSource = vtkStickMapperVS;
this->Superclass::GetShaderTemplate(shaders,ren,actor);
shaders[vtkShader::Vertex]->SetSource(vtkStickMapperVS);
}
void vtkOpenGLStickMapper::ReplaceShaderValues(std::string &VSSource,
std::string &FSSource,
std::string &GSSource,
int lightComplexity,
vtkRenderer* ren,
vtkActor *actor)
void vtkOpenGLStickMapper::ReplaceShaderValues(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *actor)
{
std::string VSSource = shaders[vtkShader::Vertex]->GetSource();
std::string FSSource = shaders[vtkShader::Fragment]->GetSource();
vtkShaderProgram::Substitute(VSSource,
"//VTK::Camera::Dec",
"uniform mat4 VCDCMatrix;\n"
......@@ -199,9 +197,10 @@ void vtkOpenGLStickMapper::ReplaceShaderValues(std::string &VSSource,
);
}
shaders[vtkShader::Vertex]->SetSource(VSSource);
shaders[vtkShader::Fragment]->SetSource(FSSource);
this->Superclass::ReplaceShaderValues(VSSource,FSSource,GSSource,lightComplexity,ren,actor);
this->Superclass::ReplaceShaderValues(shaders,ren,actor);
}
//-----------------------------------------------------------------------------
......@@ -565,7 +564,7 @@ void vtkOpenGLStickMapper::RenderPieceDraw(vtkRenderer* ren, vtkActor *actor)
if (this->Tris.IBO->IndexCount)
{
// First we do the triangles, update the shader, set uniforms, etc.
this->UpdateShader(this->Tris, ren, actor);
this->UpdateShaders(this->Tris, ren, actor);
this->Tris.IBO->Bind();
glDrawRangeElements(GL_TRIANGLES, 0,
static_cast<GLuint>(this->VBO->VertexCount - 1),
......
......@@ -47,19 +47,15 @@ protected:
// Description:
// Create the basic shaders before replacement
virtual void GetShaderTemplate(std::string &VertexCode,
std::string &fragmentCode,
std::string &geometryCode,
int lightComplexity,
vtkRenderer *ren, vtkActor *act);
virtual void GetShaderTemplate(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *act);
// Description:
// Perform string replacments on the shader templates
virtual void ReplaceShaderValues(std::string &VertexCode,
std::string &fragmentCode,
std::string &geometryCode,
int lightComplexity,
vtkRenderer *ren, vtkActor *act);
virtual void ReplaceShaderValues(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *act);
// Description:
// Set the shader parameters related to the Camera
......
......@@ -384,7 +384,7 @@ void vtkOpenGLContextDevice2D::ReadyVBOProgram()
if (!this->VBO->Program)
{
this->VBO->Program =
this->RenderWindow->GetShaderCache()->ReadyShader(
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(
// vertex shader
"//VTK::System::Dec\n"
"attribute vec2 vertexMC;\n"
......@@ -403,7 +403,7 @@ void vtkOpenGLContextDevice2D::ReadyVBOProgram()
}
else
{
this->RenderWindow->GetShaderCache()->ReadyShader(this->VBO->Program);
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(this->VBO->Program);
}
}
......@@ -412,7 +412,7 @@ void vtkOpenGLContextDevice2D::ReadyVCBOProgram()
if (!this->VCBO->Program)
{
this->VCBO->Program =
this->RenderWindow->GetShaderCache()->ReadyShader(
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(
// vertex shader
"//VTK::System::Dec\n"
"attribute vec2 vertexMC;\n"
......@@ -434,7 +434,7 @@ void vtkOpenGLContextDevice2D::ReadyVCBOProgram()
}
else
{
this->RenderWindow->GetShaderCache()->ReadyShader(this->VCBO->Program);
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(this->VCBO->Program);
}
}
......@@ -443,7 +443,7 @@ void vtkOpenGLContextDevice2D::ReadyVTBOProgram()
if (!this->VTBO->Program)
{
this->VTBO->Program =
this->RenderWindow->GetShaderCache()->ReadyShader(
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(
// vertex shader
"//VTK::System::Dec\n"
"attribute vec2 vertexMC;\n"
......@@ -466,7 +466,7 @@ void vtkOpenGLContextDevice2D::ReadyVTBOProgram()
}
else
{
this->RenderWindow->GetShaderCache()->ReadyShader(this->VTBO->Program);
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(this->VTBO->Program);
}
}
......@@ -475,7 +475,7 @@ void vtkOpenGLContextDevice2D::ReadySBOProgram()
if (!this->SBO->Program)
{
this->SBO->Program =
this->RenderWindow->GetShaderCache()->ReadyShader(
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(
// vertex shader
"//VTK::System::Dec\n"
"attribute vec2 vertexMC;\n"
......@@ -495,7 +495,7 @@ void vtkOpenGLContextDevice2D::ReadySBOProgram()
}
else
{
this->RenderWindow->GetShaderCache()->ReadyShader(this->SBO->Program);
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(this->SBO->Program);
}
}
......@@ -504,7 +504,7 @@ void vtkOpenGLContextDevice2D::ReadySCBOProgram()
if (!this->SCBO->Program)
{
this->SCBO->Program =
this->RenderWindow->GetShaderCache()->ReadyShader(
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(
// vertex shader
"//VTK::System::Dec\n"
"attribute vec2 vertexMC;\n"
......@@ -527,7 +527,7 @@ void vtkOpenGLContextDevice2D::ReadySCBOProgram()
}
else
{
this->RenderWindow->GetShaderCache()->ReadyShader(this->SCBO->Program);
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(this->SCBO->Program);
}
}
......
......@@ -277,7 +277,7 @@ void vtkOpenGLContextDevice3D::ReadyVBOProgram()
if (!this->VBO->Program)
{
this->VBO->Program =
this->RenderWindow->GetShaderCache()->ReadyShader(
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(
// vertex shader
"//VTK::System::Dec\n"
"attribute vec3 vertexMC;\n"
......@@ -310,7 +310,7 @@ void vtkOpenGLContextDevice3D::ReadyVBOProgram()
}
else
{
this->RenderWindow->GetShaderCache()->ReadyShader(this->VBO->Program);
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(this->VBO->Program);
}
}
......@@ -319,7 +319,7 @@ void vtkOpenGLContextDevice3D::ReadyVCBOProgram()
if (!this->VCBO->Program)
{
this->VCBO->Program =
this->RenderWindow->GetShaderCache()->ReadyShader(
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(
// vertex shader
"//VTK::System::Dec\n"
"attribute vec3 vertexMC;\n"
......@@ -355,7 +355,7 @@ void vtkOpenGLContextDevice3D::ReadyVCBOProgram()
}
else
{
this->RenderWindow->GetShaderCache()->ReadyShader(this->VCBO->Program);
this->RenderWindow->GetShaderCache()->ReadyShaderProgram(this->VCBO->Program);
}
}
......
......@@ -1024,6 +1024,40 @@ vtkLineIntegralConvolution2D::~vtkLineIntegralConvolution2D()
this->SetCEShader(NULL);
this->SetAAHShader(NULL);
this->SetAAVShader(NULL);
if (this->VTShader)
{
delete this->VTShader;
}
if (this->LIC0Shader)
{
delete this->LIC0Shader;
}
if (this->LICIShader)
{
delete this->LICIShader;
}
if (this->LICNShader)
{
delete this->LICNShader;
}
if (this->EEShader)
{
delete this->EEShader;
}
if (this->CEShader)
{
delete this->CEShader;
}
if (this->AAHShader)
{
delete this->AAHShader;
}
if (this->AAVShader)
{
delete this->AAVShader;
}
this->FBO->Delete();
}
......@@ -1195,13 +1229,13 @@ namespace {
std::string VSSource = vtkTextureObjectVS;
std::string GSSource;
(*cbor)->Program =
renWin->GetShaderCache()->ReadyShader(VSSource.c_str(),
renWin->GetShaderCache()->ReadyShaderProgram(VSSource.c_str(),
frag,
GSSource.c_str());
}
else
{
renWin->GetShaderCache()->ReadyShader((*cbor)->Program);
renWin->GetShaderCache()->ReadyShaderProgram((*cbor)->Program);
}
}
}
......@@ -1448,7 +1482,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
this->StartTimerEvent("vtkLineIntegralConvolution::TransformVectors");
#endif
renWin->GetShaderCache()->ReadyShader(this->VTShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->VTShader->Program);
bufs.AttachImageVectorBuffer(this->FBO);
float fTexSize[2];
......@@ -1495,7 +1529,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
bufs.AttachNoiseTexture(0);
bufs.AttachLICBuffers(this->FBO);
renWin->GetShaderCache()->ReadyShader(this->LIC0Shader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LIC0Shader->Program);
this->LIC0Shader->Program->SetUniformi("uStepNo", 0);
this->LIC0Shader->Program->SetUniformi("uPassNo", 0);
this->LIC0Shader->Program->SetUniformf("uMaskThreshold", this->MaskThreshold);
......@@ -1523,7 +1557,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
//
// backward LIC
//
renWin->GetShaderCache()->ReadyShader(this->LICIShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LICIShader->Program);
this->LICIShader->Program->SetUniformi("uPassNo", 0);
this->LICIShader->Program->SetUniformf("uStepSize", -this->StepSize);
this->LICIShader->Program->SetUniform2f("uNoiseBoundsPt1", noiseBoundsPt1);
......@@ -1552,7 +1586,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
// initialize seeds
//
renWin->GetShaderCache()->ReadyShader(this->LIC0Shader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LIC0Shader->Program);
this->LIC0Shader->Program->SetUniformi("uStepNo", 1);
bufs.AttachLICBuffers(this->FBO);
......@@ -1571,7 +1605,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
//
// forward LIC
//
renWin->GetShaderCache()->ReadyShader(this->LICIShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LICIShader->Program);
this->LICIShader->Program->SetUniformf("uStepSize", this->StepSize);
for (int stepIdx=0; stepIdx<this->NumberOfSteps; ++stepIdx, ++stepNum)
......@@ -1599,7 +1633,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
//
// finalize LIC
//
renWin->GetShaderCache()->ReadyShader(this->LICNShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LICNShader->Program);
this->LICNShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
bufs.AttachLICBuffers(this->FBO);
......@@ -1665,7 +1699,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
// we don't do a halo exchange
grayMaxMinDiff = grayMax-grayMin;
renWin->GetShaderCache()->ReadyShader(this->CEShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->CEShader->Program);
this->CEShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
this->CEShader->Program->SetUniformf("uMin", grayMin );
this->CEShader->Program->SetUniformf("uMaxMinDiff", grayMaxMinDiff);
......@@ -1698,7 +1732,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
bufs.AttachEEBuffer(this->FBO);
#endif
renWin->GetShaderCache()->ReadyShader(this->EEShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->EEShader->Program);
this->EEShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
this->EEShader->Program->SetUniformf("uDx", dx);
this->EEShader->Program->SetUniformf("uDy", dy);
......@@ -1740,7 +1774,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
//
// initialize convolution and seeds
//
renWin->GetShaderCache()->ReadyShader(this->LIC0Shader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LIC0Shader->Program);
this->LIC0Shader->Program->SetUniformi("uStepNo", 0);
this->LIC0Shader->Program->SetUniformi("uPassNo", 1);
......@@ -1763,7 +1797,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
//
// backward LIC
//
renWin->GetShaderCache()->ReadyShader(this->LICIShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LICIShader->Program);
this->LICIShader->Program->SetUniformi("uPassNo", 1);
this->LICIShader->Program->SetUniformf("uStepSize", -this->StepSize);
this->LICIShader->Program->SetUniformi("texNoise", bufs.GetNoiseTextureUnit(1));
......@@ -1791,7 +1825,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
//
// initialize seeds
//
renWin->GetShaderCache()->ReadyShader(this->LIC0Shader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LIC0Shader->Program);
this->LIC0Shader->Program->SetUniformi("uStepNo", 1);
bufs.AttachLICBuffers(this->FBO);
......@@ -1812,7 +1846,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
//
// forward LIC
//
renWin->GetShaderCache()->ReadyShader(this->LICIShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LICIShader->Program);
this->LICIShader->Program->SetUniformf("uStepSize", this->StepSize);
for (int stepIdx=0; stepIdx<nSteps; ++stepIdx, ++stepNum)
......@@ -1840,7 +1874,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
//
// finalize LIC
//
renWin->GetShaderCache()->ReadyShader(this->LICNShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->LICNShader->Program);
this->LICNShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
bufs.AttachLICBuffers(this->FBO);
......@@ -1872,11 +1906,11 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
this->StartTimerEvent("vtkLineIntegralConvolution::AntiAlias");
#endif
renWin->GetShaderCache()->ReadyShader(this->AAHShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->AAHShader->Program);
this->AAHShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
this->AAHShader->Program->SetUniformf("uDx", dx);
renWin->GetShaderCache()->ReadyShader(this->AAVShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->AAVShader->Program);
this->AAVShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
this->AAVShader->Program->SetUniformf("uDy", dy);
......@@ -1888,7 +1922,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
for (int i=0; i<this->AntiAlias; ++i)
{
// horizontal pass
renWin->GetShaderCache()->ReadyShader(this->AAHShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->AAHShader->Program);
bufs.AttachLICBuffers(this->FBO);
this->AAHShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
this->AAHShader->Program->SetUniformi("texSeedPts", bufs.GetSeedTextureUnit());
......@@ -1901,7 +1935,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
bufs.Swap();
// vertical pass
renWin->GetShaderCache()->ReadyShader(this->AAVShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->AAVShader->Program);
bufs.AttachLICBuffers(this->FBO);
this->AAVShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
this->AAVShader->Program->SetUniformi("texSeedPts", bufs.GetSeedTextureUnit());
......@@ -1967,7 +2001,7 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
grayMax -= grayMaxMinDiff*this->HighContrastEnhancementFactor;
grayMaxMinDiff = grayMax-grayMin;
renWin->GetShaderCache()->ReadyShader(this->CEShader->Program);
renWin->GetShaderCache()->ReadyShaderProgram(this->CEShader->Program);
this->CEShader->Program->SetUniformi("texLIC", bufs.GetLICTextureUnit());
this->CEShader->Program->SetUniformf("uMin", grayMin );
this->CEShader->Program->SetUniformf("uMaxMinDiff", grayMaxMinDiff);
......
......@@ -551,9 +551,10 @@ int vtkStructuredGridLIC2D::RequestData(
std::string FSSource = vtkStructuredGridLIC2D_fs;
std::string GSSource;
this->LICProgram->Program =
renWin->GetShaderCache()->ReadyShader(VSSource.c_str(),
FSSource.c_str(),
GSSource.c_str());
renWin->GetShaderCache()->ReadyShaderProgram(
VSSource.c_str(),
FSSource.c_str(),
GSSource.c_str());
vtkShaderProgram *pgm = this->LICProgram->Program;
float fvalues[3];
......
......@@ -903,6 +903,23 @@ public:
{
this->ClearGraphicsResources();
if (this->ColorPass)
{
delete this->ColorPass;
}
if (this->ColorEnhancePass)
{
delete this->ColorEnhancePass;
}
if (this->CopyPass)
{
delete this->CopyPass;
}
this->ColorPass = NULL;
this->ColorEnhancePass = NULL;
this->CopyPass = NULL;
delete this->Communicator;
}
......@@ -947,10 +964,6 @@ public:
{
this->ClearTextures();
this->ColorPass = NULL;
this->ColorEnhancePass = NULL;
this->CopyPass = NULL;
this->Compositor = NULL;
this->LICer = NULL;
this->FBO = NULL;
......@@ -2075,13 +2088,13 @@ namespace {
*cbor = new vtkOpenGLHelper;
std::string GSSource;
(*cbor)->Program =
renWin->GetShaderCache()->ReadyShader(vert,
renWin->GetShaderCache()->ReadyShaderProgram(vert,
frag,
GSSource.c_str());
}
else
{
renWin->GetShaderCache()->ReadyShader((*cbor)->Program);
renWin->GetShaderCache()->ReadyShaderProgram((*cbor)->Program);
}
}
}
......@@ -2447,13 +2460,13 @@ void vtkSurfaceLICMapper::SetUpdateAll()
this->Internals->UpdateAll();
}
void vtkSurfaceLICMapper::ReplaceShaderValues(std::string &VSSource,
std::string &FSSource,
std::string &GSSource,
int lightComplexity,
vtkRenderer* ren,
vtkActor *actor)
void vtkSurfaceLICMapper::ReplaceShaderValues(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *actor)
{
std::string VSSource = shaders[vtkShader::Vertex]->GetSource();
std::string FSSource = shaders[vtkShader::Fragment]->GetSource();
// add some code to handle the LIC vectors and mask
vtkShaderProgram::Substitute(VSSource,
"//VTK::TCoord::Dec",
......@@ -2496,8 +2509,10 @@ void vtkSurfaceLICMapper::ReplaceShaderValues(std::string &VSSource,
this->ShaderVariablesUsed.push_back("normalMatrix");
this->Superclass::ReplaceShaderValues(VSSource,FSSource,GSSource,
lightComplexity, ren, actor);
shaders[vtkShader::Vertex]->SetSource(VSSource);
shaders[vtkShader::Fragment]->SetSource(FSSource);
this->Superclass::ReplaceShaderValues(shaders,ren,actor);
}
void vtkSurfaceLICMapper::SetMapperShaderParameters(
......@@ -2956,7 +2971,7 @@ void vtkSurfaceLICMapper::RenderPiece(
this->Internals->LICImage->Activate();
vtkShaderProgram *colorPass = this->Internals->ColorPass->Program;
renWin->GetShaderCache()->ReadyShader(colorPass);
renWin->GetShaderCache()->ReadyShaderProgram(colorPass);
colorPass->SetUniformi("texVectors",
this->Internals->VectorImage->GetTextureUnit());
colorPass->SetUniformi("texGeomColors",
......@@ -3052,7 +3067,7 @@ void vtkSurfaceLICMapper::RenderPiece(
vtkShaderProgram *colorEnhancePass =
this->Internals->ColorEnhancePass->Program;
renWin->GetShaderCache()->ReadyShader(colorEnhancePass);
renWin->GetShaderCache()->ReadyShaderProgram(colorEnhancePass);
colorEnhancePass->SetUniformi("texGeomColors",
this->Internals->GeometryImage->GetTextureUnit());
colorEnhancePass->SetUniformi("texHSLColors",
......@@ -3112,7 +3127,7 @@ void vtkSurfaceLICMapper::RenderPiece(
vtkShaderProgram *copyPass =
this->Internals->CopyPass->Program;
renWin->GetShaderCache()->ReadyShader(copyPass);
renWin->GetShaderCache()->ReadyShaderProgram(copyPass);
copyPass->SetUniformi("texDepth",
this->Internals->DepthImage->GetTextureUnit());
copyPass->SetUniformi("texRGBColors",
......
......@@ -512,11 +512,9 @@ protected:
// Description:
// Perform string replacments on the shader templates
virtual void ReplaceShaderValues(std::string &VertexCode,
std::string &fragmentCode,
std::string &geometryCode,
int lightComplexity,
vtkRenderer *ren, vtkActor *act);
virtual void ReplaceShaderValues(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *act);
private:
vtkSurfaceLICMapper(const vtkSurfaceLICMapper&); // Not implemented.
......
......@@ -361,7 +361,7 @@ void vtkCompositePolyDataMapper2::RenderPieceDraw(
if (this->Tris.IBO->IndexCount)
{
// First we do the triangles, update the shader, set uniforms, etc.
this->UpdateShader(this->Tris, ren, actor);
this->UpdateShaders(this->Tris, ren, actor);
this->Tris.IBO->Bind();
GLenum mode = (representation == VTK_POINTS) ? GL_POINTS :
(representation == VTK_WIREFRAME) ? GL_LINES : GL_TRIANGLES;
......@@ -436,7 +436,7 @@ void vtkCompositePolyDataMapper2::RenderEdges(
if (this->TrisEdges.IBO->IndexCount)
{
// First we do the triangles, update the shader, set uniforms, etc.
this->UpdateShader(this->TrisEdges, ren, actor);
this->UpdateShaders(this->TrisEdges, ren, actor);
this->TrisEdges.IBO->Bind();
std::vector<
vtkCompositePolyDataMapper2::RenderValue>::iterator it;
......
......@@ -225,13 +225,15 @@ void vtkDepthPeelingPass::BlendIntermediatePeels(
std::string FSSource = vtkDepthPeelingPassIntermediateFS;
std::string GSSource;
this->IntermediateBlendProgram->Program =
renWin->GetShaderCache()->ReadyShader(VSSource.c_str(),
FSSource.c_str(),
GSSource.c_str());
renWin->GetShaderCache()->ReadyShaderProgram(
VSSource.c_str(),
FSSource.c_str(),
GSSource.c_str());
}
else
{
renWin->GetShaderCache()->ReadyShader(this->IntermediateBlendProgram->Program);
renWin->GetShaderCache()->ReadyShaderProgram(
this->IntermediateBlendProgram->Program);
}
this->IntermediateBlendProgram->Program->SetUniformi(
"translucentRGBATexture", this->TranslucentRGBATexture->GetTextureUnit());
......@@ -258,13 +260,15 @@ void vtkDepthPeelingPass::BlendFinalPeel(vtkOpenGLRenderWindow *renWin)
std::string FSSource = vtkDepthPeelingPassFinalFS;
std::string GSSource;