Commit 1b26ec3c authored by David C. Lonie's avatar David C. Lonie

Add depth peeling benchmark.

This 10M triangle scene stresses depth peeling implementations to see
how well they perform.

Results (nVidia Quadro 2000M, Release build):

vtkDepthPeelingPass: 1.2 FPS (0.77s first frame, 0.83s subsequent)
vtkDualDepthPeelingPass: 2.5 FPS (0.56s first frame, 0.40s subsequent)

We see a roughly 50% improvement with the new dual algorithm, since
the dual algorithm peels 2 layers per geometry pass.

For reference, simple alpha blending results in 49 FPS, 0.18s first frame,
0.020s subsequent.
parent 19d945f7
......@@ -509,6 +509,8 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
}
}
// std::cout << "Number of peels: " << peelCount << "\n";
// unload the textures we are done with
this->CurrentRGBATexture->Deactivate();
this->TranslucentZTexture->UnRegister(this);
......
......@@ -47,6 +47,9 @@ int main( int argc, char *argv[] )
a.TestsToRun.push_back(new volumeTest("Volume", false));
a.TestsToRun.push_back(new volumeTest("VolumeWithShading", true));
a.TestsToRun.push_back(new depthPeelingTest("DepthPeeling", false));
a.TestsToRun.push_back(new depthPeelingTest("DepthPeelingWithNormals", true));
// process them
return a.ParseCommandLineArguments(argc, argv);
}
......@@ -513,4 +513,133 @@ class volumeTest : public vtkRTTest
bool WithShading;
};
/*=========================================================================
Define a test for depth peeling transluscent geometry.
=========================================================================*/
#include "vtkParametricTorus.h"
#include "vtkParametricFunctionSource.h"
#include "vtkProperty.h"
#include "vtkTransform.h"
class depthPeelingTest : public vtkRTTest
{
public:
depthPeelingTest(const char *name, bool withNormals)
: vtkRTTest(name),
WithNormals(withNormals)
{
}
const char *GetSummaryResultName() { return "subsequent frame time"; }
const char *GetSecondSummaryResultName() { return "first frame time"; }
virtual vtkRTTestResult Run(vtkRTTestSequence *ats,
int /*argc*/, char * /* argv */[])
{
int ures, vres;
ats->GetSequenceNumbers(ures,vres);
// ------------------------------------------------------------
// Create surface
// ------------------------------------------------------------
vtkNew<vtkParametricTorus> PB;
vtkNew<vtkParametricFunctionSource> PFS;
PFS->SetParametricFunction(PB.Get());
if (this->WithNormals == false)
{
PFS->GenerateNormalsOff();
}
PFS->SetUResolution(ures * 50);
PFS->SetVResolution(vres * 100);
PFS->Update();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(PFS->GetOutputPort());
mapper->SetScalarRange(0.0, 360.0);
// create a rendering window and renderer
vtkNew<vtkRenderer> ren1;
vtkNew<vtkRenderWindow> renWindow;
renWindow->SetMultiSamples(0);
renWindow->SetAlphaBitPlanes(1);
renWindow->AddRenderer(ren1.Get());
// Setup depth peeling to render an exact scene:
ren1->UseDepthPeelingOn();
ren1->SetMaximumNumberOfPeels(100);
ren1->SetOcclusionRatio(0.);
// Create a set of 10 colored translucent actors at slight offsets:
const int NUM_ACTORS = 10;
const unsigned char colors[NUM_ACTORS][4] = { { 255, 0, 0, 32 },
{ 0, 255, 0, 32 },
{ 0, 0, 255, 32 },
{ 128, 128, 0, 32 },
{ 0, 128, 128, 32 },
{ 128, 0, 128, 32 },
{ 128, 64, 64, 32 },
{ 64, 128, 64, 32 },
{ 64, 64, 128, 32 },
{ 64, 64, 64, 32 } };
for (int i = 0; i < NUM_ACTORS; ++i)
{
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.Get());
actor->GetProperty()->SetColor(colors[i][0] / 255.,
colors[i][1] / 255.,
colors[i][2] / 255.);
actor->GetProperty()->SetOpacity(colors[i][3] / 255.);
vtkNew<vtkTransform> xform;
xform->Identity();
xform->RotateX(i * (180. / static_cast<double>(NUM_ACTORS)));
actor->SetUserTransform(xform.Get());
ren1->AddActor(actor.Get());
}
// set the size/color of our window
renWindow->SetSize(500, 500);
ren1->SetBackground(0.2, 0.3, 0.5);
// draw the resulting scene
double startTime = vtkTimerLog::GetUniversalTime();
renWindow->Render();
double firstFrameTime = vtkTimerLog::GetUniversalTime() - startTime;
ren1->GetActiveCamera()->Azimuth(90);
ren1->ResetCameraClippingRange();
int frameCount = 80;
for (int i = 0; i < frameCount; i++)
{
renWindow->Render();
ren1->GetActiveCamera()->Azimuth(1);
ren1->GetActiveCamera()->Elevation(1);
if ((vtkTimerLog::GetUniversalTime() - startTime - firstFrameTime) >
this->TargetTime * 1.5)
{
frameCount = i + 1;
break;
}
}
double subsequentFrameTime = (vtkTimerLog::GetUniversalTime() - startTime -
firstFrameTime) / frameCount;
double numTris = PFS->GetOutput()->GetPolys()->GetNumberOfCells();
numTris *= NUM_ACTORS;
vtkRTTestResult result;
result.Results["first frame time"] = firstFrameTime;
result.Results["subsequent frame time"] = subsequentFrameTime;
result.Results["FPS"] = 1. / subsequentFrameTime;
result.Results["triangles"] = numTris;
return result;
}
protected:
bool WithNormals;
};
#endif
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