Commit 3e454924 authored by David C. Lonie's avatar David C. Lonie

Add FXAA to vtkSynchronizedRenderers.

parent 548990af
Pipeline #27028 passed with stage
......@@ -18,6 +18,7 @@
#include "vtkCamera.h"
#include "vtkCommand.h"
#include "vtkCommunicator.h"
#include "vtkFXAAOptions.h"
#include "vtkImageData.h"
#include "vtkMatrix4x4.h"
#include "vtkMultiProcessController.h"
......@@ -32,10 +33,14 @@
#ifndef VTK_OPENGL2
# include "vtkgl.h"
#else // VTK_OPENGL2
#include "vtkOpenGLFXAAFilter.h"
#endif
#include <cassert>
vtkCxxSetObjectMacro(vtkSynchronizedRenderers, FXAAOptions, vtkFXAAOptions)
//----------------------------------------------------------------------------
class vtkSynchronizedRenderers::vtkObserver : public vtkCommand
{
......@@ -82,6 +87,10 @@ vtkSynchronizedRenderers::vtkSynchronizedRenderers()
this->Observer = vtkSynchronizedRenderers::vtkObserver::New();
this->Observer->Target = this;
this->UseFXAA = false;
this->FXAAOptions = vtkFXAAOptions::New();
this->FXAAFilter = NULL;
this->Renderer = 0;
this->ParallelController = 0;
this->ParallelRendering = true;
......@@ -105,6 +114,21 @@ vtkSynchronizedRenderers::~vtkSynchronizedRenderers()
this->SetParallelController(0);
this->Observer->Delete();
this->Observer = 0;
if (this->FXAAOptions)
{
this->FXAAOptions->Delete();
this->FXAAOptions = NULL;
}
// vtkOpenGLFXAAFilter is only available on opengl2:
#ifdef VTK_OPENGL2
if (this->FXAAFilter)
{
this->FXAAFilter->Delete();
this->FXAAFilter = NULL;
}
#endif // VTK_OPENGL2
}
//----------------------------------------------------------------------------
......@@ -286,6 +310,22 @@ void vtkSynchronizedRenderers::PushImageToScreen()
}
rawImage.PushToViewport(this->Renderer);
#ifdef VTK_OPENGL2
if (this->UseFXAA)
{
if (!this->FXAAFilter)
{
this->FXAAFilter = vtkOpenGLFXAAFilter::New();
}
if (this->FXAAOptions)
{
this->FXAAFilter->UpdateConfiguration(this->FXAAOptions);
}
this->FXAAFilter->Execute(this->Renderer);
}
#endif // VTK_OPENGL2
}
////----------------------------------------------------------------------------
......
......@@ -31,9 +31,11 @@
#include "vtkUnsignedCharArray.h" // needed for vtkUnsignedCharArray.
#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
class vtkFXAAOptions;
class vtkRenderer;
class vtkMultiProcessController;
class vtkMultiProcessStream;
class vtkOpenGLFXAAFilter;
class vtkOpenGLRenderer;
class VTKRENDERINGPARALLEL_EXPORT vtkSynchronizedRenderers : public vtkObject
......@@ -77,6 +79,18 @@ public:
vtkGetMacro(WriteBackImages, bool);
vtkBooleanMacro(WriteBackImages, bool);
// Description:
// Enable FXAA antialiasing. FXAA is applied after all rendering results are
// composited into the final image.
vtkSetMacro(UseFXAA, bool)
vtkGetMacro(UseFXAA, bool)
vtkBooleanMacro(UseFXAA, bool)
// Description:
// The configuration options for FXAA antialiasing.
vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
virtual void SetFXAAOptions(vtkFXAAOptions*);
// Description:
// Get/Set the root-process id. This is required when the ParallelController
// is a vtkSocketController. Set to 0 by default (which will not work when
......@@ -198,6 +212,10 @@ protected:
void CopyTo(vtkRenderer*);
};
bool UseFXAA;
vtkFXAAOptions *FXAAOptions;
vtkOpenGLFXAAFilter *FXAAFilter;
// These methods are called on all processes as a consequence of corresponding
// events being called on the renderer.
virtual void HandleStartRender();
......
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