Commit 582ada60 authored by Alvaro Sanchez's avatar Alvaro Sanchez

vtkValuePass::FLOATING_POINT supports cell data.

Added support for cell data arrays (Dave DeMarle).
parent 9bbf0457
Pipeline #26785 passed with stage
c482c9a67076037525ea716826d91077
98596e51d1cd4844e528adc75f96d193
......@@ -6,7 +6,6 @@ vtk_module(vtkRenderingCore
vtkIOLegacy
vtkIOParallel
vtkIOXML
vtkIOPLY
vtkTestingCore
vtkTestingRendering
vtkRendering${VTK_RENDERING_BACKEND}
......
......@@ -211,6 +211,9 @@ void vtkOpenGLPolyDataMapper::ReleaseGraphicsResources(vtkWindow* win)
{
this->CellNormalBuffer->ReleaseGraphicsResources();
}
this->ValuePassHelper->ReleaseGraphicsResources(win);
if (this->AppleBugPrimIDBuffer)
{
this->AppleBugPrimIDBuffer->ReleaseGraphicsResources();
......@@ -1487,16 +1490,6 @@ void vtkOpenGLPolyDataMapper::ReplaceShaderValues(
//cout << "VS: " << shaders[vtkShader::Vertex]->GetSource() << endl;
//cout << "GS: " << shaders[vtkShader::Geometry]->GetSource() << endl;
//cout << "FS: " << shaders[vtkShader::Fragment]->GetSource() << endl;
// std::string vertexShader = shaders[vtkShader::Vertex]->GetSource();
// std::string fragmentShader = shaders[vtkShader::Fragment]->GetSource();
// std::ofstream file("/home/alvaro/testShaders/PolyData_valuePass.frag");
// file << fragmentShader;
// file.close();
//
// file.open("/home/alvaro/testShaders/PolyData_valuePass.vert");
// file << vertexShader;
// file.close();
}
//-----------------------------------------------------------------------------
......@@ -1582,7 +1575,8 @@ bool vtkOpenGLPolyDataMapper::GetNeedToRebuildShaders(
cellBO.ShaderSourceTime < this->CurrentInput->GetMTime() ||
cellBO.ShaderSourceTime < this->SelectionStateChanged ||
cellBO.ShaderSourceTime < renderPassMTime ||
cellBO.ShaderSourceTime < this->LightComplexityChanged[&cellBO])
cellBO.ShaderSourceTime < this->LightComplexityChanged[&cellBO] ||
this->ValuePassHelper->RequiresShaderRebuild(actor))
{
return true;
}
......@@ -1616,32 +1610,6 @@ void vtkOpenGLPolyDataMapper::UpdateShaders(
this->BuildShaders(shaders, ren, actor);
// vtkInformation *info = actor->GetPropertyKeys();
// if (info && info->Has(vtkValuePass::RENDER_VALUES()))
// {
// // Load shaders
// //---------------
// std::string path = "/home/alvaro/testShaders/";
// std::string filename = "pv_values";
//
// std::string vfilepath = path + filename + ".vert";
// std::ifstream file(vfilepath.c_str());
// std::string vert = std::string(std::istreambuf_iterator<char>(file),
// std::istreambuf_iterator<char>());
// file.close();
//
// std::string ffilepath = path + filename + ".frag";
// file.open(ffilepath.c_str());
// std::string frag = std::string(std::istreambuf_iterator<char>(file),
// std::istreambuf_iterator<char>());
// file.close();
//
// shaders[vtkShader::Vertex]->SetSource(vert);
// shaders[vtkShader::Fragment]->SetSource(frag);
// }
// compile and bind the program if needed
vtkShaderProgram *newShader =
renWin->GetShaderCache()->ReadyShaderProgram(shaders);
......@@ -1742,7 +1710,7 @@ void vtkOpenGLPolyDataMapper::SetMapperShaderParameters(vtkOpenGLHelper &cellBO,
if (this->ValuePassHelper->GetRenderingMode() == vtkValuePass::FLOATING_POINT)
{
this->ValuePassHelper->BindValueBuffer(cellBO);
this->ValuePassHelper->BindAttributes(cellBO);
}
cellBO.AttributeUpdateTime.Modified();
......@@ -1796,6 +1764,11 @@ void vtkOpenGLPolyDataMapper::SetMapperShaderParameters(vtkOpenGLHelper &cellBO,
cellBO.Program->SetUniformi("textureN", tunit);
}
if (this->ValuePassHelper->GetRenderingMode() == vtkValuePass::FLOATING_POINT)
{
this->ValuePassHelper->BindUniforms(cellBO);
}
// Handle render pass setup:
vtkInformation *info = actor->GetPropertyKeys();
if (info && info->Has(vtkOpenGLRenderPass::RenderPasses()))
......@@ -2344,7 +2317,7 @@ void vtkOpenGLPolyDataMapper::RenderPieceStart(vtkRenderer* ren, vtkActor *actor
if (this->ValuePassHelper->GetRenderingMode() == vtkValuePass::FLOATING_POINT)
{
this->ValuePassHelper->UploadValueData(actor, this->CurrentInput);
this->ValuePassHelper->RenderPieceStart(actor, this->CurrentInput);
}
// If we are coloring by texture, then load the texture map.
......@@ -2578,6 +2551,11 @@ void vtkOpenGLPolyDataMapper::RenderPieceFinish(vtkRenderer* ren,
this->CellNormalTexture->Deactivate();
}
if (this->ValuePassHelper->GetRenderingMode() == vtkValuePass::FLOATING_POINT)
{
this->ValuePassHelper->RenderPieceFinish();
}
this->UpdateProgress(1.0);
}
......
......@@ -44,6 +44,7 @@ vtkInformationKeyMacro(vtkValuePass, ARRAY_ID, Integer);
vtkInformationKeyMacro(vtkValuePass, ARRAY_NAME, String);
vtkInformationKeyMacro(vtkValuePass, ARRAY_COMPONENT, Integer);
vtkInformationKeyMacro(vtkValuePass, SCALAR_RANGE, DoubleVector);
vtkInformationKeyMacro(vtkValuePass, RELOAD_DATA, Integer);
class vtkValuePass::vtkInternals
{
......@@ -55,6 +56,7 @@ public:
int Component;
double ScalarRange[2];
bool ScalarRangeSet;
bool ReloadData;
// Array holder for FLOATING_POINT mode. The result pixels are downloaded
// into this array.
......@@ -74,6 +76,7 @@ public:
this->ScalarRange[0] = 0.0;
this->ScalarRange[1] = -1.0;
this->ScalarRangeSet = false;
this->ReloadData = true;
}
};
......@@ -111,6 +114,7 @@ void vtkValuePass::SetInputArrayToProcess(int fieldAssociation,
this->Internals->FieldAssociation = fieldAssociation;
this->Internals->FieldName = name;
this->Internals->FieldNameSet = true;
this->Internals->ReloadData = true;
this->Modified();
}
}
......@@ -126,6 +130,7 @@ void vtkValuePass::SetInputArrayToProcess(int fieldAssociation,
this->Internals->FieldAssociation = fieldAssociation;
this->Internals->FieldAttributeType = fieldAttributeType;
this->Internals->FieldNameSet = false;
this->Internals->ReloadData = true;
this->Modified();
}
}
......@@ -136,6 +141,7 @@ void vtkValuePass::SetInputComponentToProcess(int component)
if (this->Internals->Component != component)
{
this->Internals->Component = component;
this->Internals->ReloadData = true;
this->Modified();
}
}
......@@ -153,7 +159,6 @@ void vtkValuePass::SetScalarRange(double min, double max)
}
}
// ----------------------------------------------------------------------------
// Description:
// Perform rendering according to a render state \p s.
......@@ -199,6 +204,7 @@ void vtkValuePass::RenderOpaqueGeometry(const vtkRenderState *s)
{
keys.TakeReference(vtkInformation::New());
}
keys->Set(vtkValuePass::RENDER_VALUES(), this->RenderingMode);
keys->Set(vtkValuePass::SCALAR_MODE(), this->Internals->FieldAssociation);
keys->Set(vtkValuePass::ARRAY_MODE(), this->Internals->FieldNameSet);
......@@ -206,6 +212,11 @@ void vtkValuePass::RenderOpaqueGeometry(const vtkRenderState *s)
keys->Set(vtkValuePass::ARRAY_NAME(), this->Internals->FieldName.c_str());
keys->Set(vtkValuePass::ARRAY_COMPONENT(), this->Internals->Component);
keys->Set(vtkValuePass::SCALAR_RANGE(), this->Internals->ScalarRange, 2);
if (this->Internals->ReloadData)
{
keys->Set(vtkValuePass::RELOAD_DATA(), 1);
}
p->SetPropertyKeys(keys);
int rendered =
......@@ -235,6 +246,12 @@ void vtkValuePass::RenderOpaqueGeometry(const vtkRenderState *s)
keys->Remove(vtkValuePass::ARRAY_NAME());
keys->Remove(vtkValuePass::ARRAY_COMPONENT());
keys->Remove(vtkValuePass::SCALAR_RANGE());
if (this->Internals->ReloadData)
{
keys->Remove(vtkValuePass::RELOAD_DATA());
this->Internals->ReloadData = false;
}
p->SetPropertyKeys(keys);
++i;
}
......
......@@ -65,6 +65,7 @@ public:
static vtkInformationStringKey *ARRAY_NAME();
static vtkInformationIntegerKey *ARRAY_COMPONENT();
static vtkInformationDoubleVectorKey *SCALAR_RANGE();
static vtkInformationIntegerKey *RELOAD_DATA();
// Description:
// Perform rendering according to a render state \p s.
......
This diff is collapsed.
......@@ -4,16 +4,17 @@
#include "vtkRenderingOpenGL2Module.h"
class vtkOpenGLBufferObject;
//class vtkTimeStamp;
class vtkDataArray;
class vtkRenderer;
class vtkActor;
class vtkDataArray;
class vtkDataSet;
class vtkOpenGLHelper;
class vtkFloatArray;
class vtkMapper;
class vtkOpenGLBufferObject;
class vtkOpenGLHelper;
class vtkRenderer;
class vtkTextureObject;
class vtkWindow;
class vtkValuePass;
class VTKRENDERINGOPENGL2_EXPORT vtkValuePassHelper : public vtkObject
{
......@@ -31,24 +32,32 @@ protected:
vtkGetMacro(RenderingMode, int);
void UpdateConfiguration(vtkRenderer* ren, vtkActor* act, vtkMapper* mapper);
void UploadValueData(vtkActor* actor, vtkDataSet* input);
void RenderPieceStart(vtkActor* actor, vtkDataSet* input);
void UpdateShaders(std::string & VSSource, std::string & FSSource,
std::string & required);
void BindValueBuffer(vtkOpenGLHelper& cellBO);
void BindAttributes(vtkOpenGLHelper& cellBO);
void BindUniforms(vtkOpenGLHelper& cellBO);
void ReleaseGraphicsResources(vtkWindow* win);
void RenderPieceFinish();
bool RequiresShaderRebuild(vtkActor* actor);
private:
void AllocateGraphicsResources(vtkRenderer* ren);
vtkValuePassHelper(const vtkValuePassHelper &); // Not implemented.
void operator=(const vtkValuePassHelper &); // Not implemented.
void AllocateBuffer(vtkRenderer* ren);
void ReleaseBuffer(vtkRenderer* ren);
////////////////////////////////////////////////////////////////////////////////
//vtkTimeStamp ValueBufferTime;
vtkOpenGLBufferObject* ValueBuffer;
vtkDataArray* ValuePassArray;
std::vector<float> Buffer;
int CurrentDataArrayMode;
int LastDataArrayMode;
int RenderingMode;
bool ResourcesAllocated;
vtkTextureObject* CellFloatTexture;
vtkOpenGLBufferObject* CellFloatBuffer;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment