Commit fc0908f9 authored by Ken Martin's avatar Ken Martin

some cleanup and fixes

parent 16bbf3f4
......@@ -82,7 +82,6 @@ int TestTilingCxx(int argc, char* argv[])
VTK_CREATE(vtkActor, sphereActor);
sphereActor->SetMapper(mapper);
#if 0
// Create a scalar bar
VTK_CREATE(vtkScalarBarActor, scalarBar);
scalarBar->SetLookupTable(mapper->GetLookupTable());
......@@ -96,33 +95,32 @@ int TestTilingCxx(int argc, char* argv[])
// Test the Get/Set Position
scalarBar->SetPosition(scalarBar->GetPosition());
#endif
// Create graphics stuff
// Create the RenderWindow, Renderer and both Actors
VTK_CREATE(vtkRenderer, ren1);
//VTK_CREATE(vtkRenderer, ren2);
VTK_CREATE(vtkRenderer, ren2);
VTK_CREATE(vtkRenderWindow, renWin);
renWin->SetMultiSamples(0);
renWin->AddRenderer(ren1);
//renWin->AddRenderer(ren2);
renWin->AddRenderer(ren2);
VTK_CREATE(vtkRenderWindowInteractor, iren);
iren->SetRenderWindow(renWin);
ren1->AddActor(sphereActor);
//ren2->AddActor2D(scalarBar);
ren2->AddActor2D(scalarBar);
renWin->SetSize(160, 160);
ren1->SetViewport(0, 0, 0.75, 1.0);
//ren2->SetViewport(0.75, 0, 1.0, 1.0);
//ren2->SetBackground(0.3, 0.3, 0.3);
ren2->SetViewport(0.75, 0, 1.0, 1.0);
ren2->SetBackground(0.3, 0.3, 0.3);
// render the image
//scalarBar->SetNumberOfLabels(8);
scalarBar->SetNumberOfLabels(8);
renWin->Render();
renWin->Render(); // perform an extra render before capturing window
vtksys::SystemTools::Delay(1000);
/*
VTK_CREATE(vtkWindowToImageFilter, w2i);
w2i->SetInput(renWin);
w2i->SetMagnification(2);
......@@ -155,13 +153,13 @@ int TestTilingCxx(int argc, char* argv[])
renWin->Render();
vtksys::SystemTools::Delay(1000);
*/
int retVal = vtkRegressionTestImage( renWin );
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
//outputData->Delete();
outputData->Delete();
return !retVal;
}
......@@ -50,14 +50,12 @@ int TestVBOPLYMapper(int argc, char *argv[])
reader->SetFileName(fileName);
reader->Update();
vtkNew<vtkPolyDataNormals> norms;
norms->SetInputConnection(reader->GetOutputPort());
norms->Update();
// vtkNew<vtkPolyDataNormals> norms;
// norms->SetInputConnection(reader->GetOutputPort());
// norms->Update();
//mapper->SetInputConnection(reader->GetOutputPort());
mapper->SetInputConnection(norms->GetOutputPort());
mapper->SetInputConnection(reader->GetOutputPort());
//mapper->SetInputConnection(norms->GetOutputPort());
actor->SetMapper(mapper.Get());
actor->GetProperty()->SetAmbientColor(0.2, 0.2, 1.0);
actor->GetProperty()->SetDiffuseColor(1.0, 0.65, 0.7);
......
......@@ -29,13 +29,15 @@ uniform float specularPower;
// passed from the vertex shader
varying vec4 vertexVC;
varying vec4 vertexWC;
varying vec4 vertexColor;
varying vec3 normalVC;
varying vec3 vertexColor;
// optional normal declaration
//VTK::Normal::Dec
void main()
{
// now compute the vertex color
vec3 normalVC = normalize(cross(dFdx(vertexVC.xyz), dFdy(vertexVC.xyz)));
// Generate the normal if we are not passed in one
//VTK::Normal::Impl
// diffuse and specular lighting
float df = max(0.0, dot(normalVC, vec3(0, 0, 1)));
......
......@@ -41,12 +41,15 @@ uniform vec3 lightDirectionVC[6]; // normalized
// passed from the vertex shader
varying vec4 vertexVC;
varying vec4 vertexWC;
varying vec4 vertexColor;
varying vec3 vertexColor;
// optional normal declaration
//VTK::Normal::Dec
void main()
{
// now compute the vertex color
vec3 normalVC = normalize(cross(dFdx(vertexVC.xyz), dFdy(vertexVC.xyz)));
// Generate the normal if we are not passed in one
//VTK::Normal::Impl
// now compute the vertex color
vec3 viewDirectionVC = normalize(vec3(0.0, 0.0, 1.0) - vertexVC.xyz);
......
......@@ -47,12 +47,16 @@ uniform int lightPositional[6];
// passed from the vertex shader
varying vec4 vertexVC;
varying vec4 vertexWC;
varying vec4 vertexColor;
varying vec3 vertexColor;
// optional normal declaration
//VTK::Normal::Dec
void main()
{
// now compute the vertex color
vec3 normalVC = normalize(cross(dFdx(vertexVC.xyz), dFdy(vertexVC.xyz)));
// Generate the normal if we are not passed in one
//VTK::Normal::Impl
vec3 viewDirectionVC = normalize(vec3(0.0, 0.0, 1.0) - vertexVC.xyz);
vec3 diffuse = vec3(0,0,0);
......
......@@ -22,7 +22,9 @@
// DC - Display Coordinates
attribute vec4 vertexMC;
attribute vec3 zinger;
// optional normal declaration
//VTK::Normal::Dec
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
......@@ -37,11 +39,10 @@ uniform mat4 VCDCMatrix; // the camera's projection matrix
varying vec4 vertexVC;
varying vec4 vertexWC;
varying vec3 vertexColor;
//varying vec3 normalVC;
void main()
{
//vec3 normalVC = normalMatrix * normalMC;
//VTK::Normal::Impl
// compute the projected vertex position
vertexWC = MCWCMatrix * vertexMC;
......
......@@ -211,6 +211,7 @@ void vtkVBOPolyDataMapper::UpdateShader(vtkRenderer* ren, vtkActor *vtkNotUsed(a
{
// Build our shader if necessary.
std::string VSSource = tris.vsFile;
std::string FSSource = tris.fsFile;
if (this->Internal->colorAttributes)
{
VSSource = replace(VSSource,
......@@ -224,24 +225,34 @@ void vtkVBOPolyDataMapper::UpdateShader(vtkRenderer* ren, vtkActor *vtkNotUsed(a
"uniform vec3 diffuseColor;");
}
// normals?
/* if (this->GetInput()->GetPointData()->GetNormals())
if (this->GetInput()->GetPointData()->GetNormals())
{
VSSource = replace(VSSource,
"//VTK::Normal::Dec",
"attribute vec3 normalMC;");
"attribute vec3 normalMC; varying vec3 normalVC;");
VSSource = replace(VSSource,
"//VTK::Normal::Impl",
"normalVC = normalMatrix * normalMC;");
FSSource = replace(FSSource,
"//VTK::Normal::Dec",
"varying vec3 normalVC;");
FSSource = replace(FSSource,
"//VTK::Normal::Impl","");
}
else
{
VSSource = replace(VSSource,
"//VTK::Normal::Dec",
"uniform vec3 normalMC;");
VSSource = replace(VSSource,"//VTK::Normal::Dec","");
VSSource = replace(VSSource,"//VTK::Normal::Impl","");
FSSource = replace(FSSource,"//VTK::Normal::Dec","");
FSSource = replace(FSSource,"//VTK::Normal::Impl",
"vec3 normalVC = normalize(cross(dFdx(vertexVC.xyz), dFdy(vertexVC.xyz)));");
}
*/
cout << "VS: " << VSSource << endl;
cout << "FS: " << FSSource << endl;
tris.vs.SetSource(VSSource);
tris.vs.SetType(vtkgl::Shader::Vertex);
tris.fs.SetSource(tris.fsFile);
tris.fs.SetSource(FSSource);
tris.fs.SetType(vtkgl::Shader::Fragment);
if (!tris.vs.Compile())
{
......@@ -271,21 +282,21 @@ void vtkVBOPolyDataMapper::UpdateShader(vtkRenderer* ren, vtkActor *vtkNotUsed(a
{
tris.program.Bind();
tris.vao.Bind();
if (!tris.vao.AddAttributeArray(tris.program, this->Internal->vbo,
"vertexMC", layout.VertexOffset,
layout.Stride, VTK_FLOAT, 3, false))
{
vtkErrorMacro(<< "Error setting 'vertexMC' in triangle VAO.");
}
if (this->GetInput()->GetPointData()->GetNormals())
{
if (!tris.vao.AddAttributeArray(tris.program, this->Internal->vbo,
"zinger", layout.NormalOffset,
"normalMC", layout.NormalOffset,
layout.Stride, VTK_FLOAT, 3, false))
{
vtkErrorMacro(<< "Error setting 'zinger' in triangle VAO.");
vtkErrorMacro(<< "Error setting 'normalMC' in triangle VAO.");
}
}
if (!tris.vao.AddAttributeArray(tris.program, this->Internal->vbo,
"vertexMC", layout.VertexOffset,
layout.Stride, VTK_FLOAT, 3, false))
{
vtkErrorMacro(<< "Error setting 'vertexMC' in triangle VAO.");
}
if (layout.ColorComponents != 0)
{
if (!tris.vao.AddAttributeArray(tris.program, this->Internal->vbo,
......@@ -935,8 +946,6 @@ void vtkVBOPolyDataMapper::UpdateVBO(vtkActor *act)
// Mark our properties as updated.
this->Internal->propertiesTime.Modified();
cout << "Normals: " << (poly->GetPointData()->GetNormals() ? " have them " : " don't ") << endl;
// Iterate through all of the different types in the polydata, building VBOs
// and IBOs as appropriate for each type.
this->Internal->layout =
......
......@@ -44,7 +44,7 @@ VBOLayout TemplatedCreateVBO2(T* points, T2* normals, vtkIdType numPts,
{
++blockSize;
layout.ColorComponents = colorComponents;
layout.ColorOffset = sizeof(float) * 6;
layout.ColorOffset = layout.NormalOffset + sizeof(float) * 3;
}
else
{
......
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