Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
G3D::MotionBlur Class Reference

Screen-space post-processed motion blur. More...

Inherits G3D::ReferenceCountedObject.

Public Member Functions

virtual void apply (RenderDevice *rd, const shared_ptr< Texture > &color, const shared_ptr< Texture > &velocity, const shared_ptr< Texture > &depth, const shared_ptr< Camera > &camera, Vector2int16 trimBandThickness)
 
bool debugShowTiles () const
 
void setDebugShowTiles (bool b)
 Toggle visualization showing the tile boundaries, which are set by maxBlurRadiusPixels. More...
 

Static Public Member Functions

static shared_ptr< MotionBlurcreate ()
 

Protected Member Functions

 MotionBlur ()
 
void computeNeighborMinMax (RenderDevice *rd, const shared_ptr< Texture > &tileMax)
 Compute m_neighborMax from m_tileMax. More...
 
void computeTileMinMax (RenderDevice *rd, const shared_ptr< Texture > &velocity, int maxBlurRadiusPixels, const Vector2int16 trimBandThickness)
 Compute m_tileMax from sharpVelocity. More...
 
void debugDrawTiles (RenderDevice *rd, const shared_ptr< Texture > &neighborMax, int maxBlurRadiusPixels)
 Debug visualization of the motion blur tiles and directions. More...
 
virtual void gatherBlur (RenderDevice *rd, const shared_ptr< Texture > &color, const shared_ptr< Texture > &neighborMax, const shared_ptr< Texture > &velocity, const shared_ptr< Texture > &depth, int numSamplesOdd, int maxBlurRadiusPixels, float exposureTimeFraction, Vector2int16 trimBandThickness)
 Called from apply() to compute the blurry image to the current frame buffer by gathering. More...
 
void makeRandomBuffer ()
 
void updateBuffers (const shared_ptr< Texture > &velocityTexture, int maxBlurRadiusPixels, Vector2int16 trimBandThickness)
 Allocates tileMax and neighborMax as needed. More...
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 
static int nextOdd (int n)
 Returns n if it is odd, otherwise returns n + 1. More...
 

Protected Attributes

shared_ptr< Texturem_cachedSrc
 The source color is copied into this if needed. More...
 
bool m_debugShowTiles
 
shared_ptr< Framebufferm_neighborMinMaxFramebuffer
 Size ceil(w / maxBlurRadius) x ceil(h / maxBlurRadius). More...
 
shared_ptr< Texturem_randomBuffer
 32x32 buffer of RG values on [0, 1) More...
 
shared_ptr< Framebufferm_tileMinMaxFramebuffer
 Size ceil(w / maxBlurRadius) x ceil(h / maxBlurRadius). More...
 
shared_ptr< Framebufferm_tileMinMaxTempFramebuffer
 Size h x ceil(w / maxBlurRadius). More...
 

Detailed Description

Screen-space post-processed motion blur.

Based on:

A Reconstruction Filter for Plausible Motion Blur. McGuire, Hennessy, Bukowski, and Osman, I3D 2012 http://graphics.cs.williams.edu/papers/MotionBlurI3D12/

Constructor & Destructor Documentation

◆ MotionBlur()

G3D::MotionBlur::MotionBlur ( )
protected

Referenced by create().

Member Function Documentation

◆ apply()

virtual void G3D::MotionBlur::apply ( RenderDevice rd,
const shared_ptr< Texture > &  color,
const shared_ptr< Texture > &  velocity,
const shared_ptr< Texture > &  depth,
const shared_ptr< Camera > &  camera,
Vector2int16  trimBandThickness 
)
virtual
Parameters
trimBandThicknessInput texture coordinates are clamped to a region inset on all sides by this amount. Set this to non-zero if the input color buffer is larger than the desired output region but does not have useful data around the border. Typically m_settings.hdrFramebuffer.depthGuardBandThickness - m_settings.hdrFramebuffer.colorGuardBandThickness.

◆ computeNeighborMinMax()

void G3D::MotionBlur::computeNeighborMinMax ( RenderDevice rd,
const shared_ptr< Texture > &  tileMax 
)
protected

Compute m_neighborMax from m_tileMax.

◆ computeTileMinMax()

void G3D::MotionBlur::computeTileMinMax ( RenderDevice rd,
const shared_ptr< Texture > &  velocity,
int  maxBlurRadiusPixels,
const Vector2int16  trimBandThickness 
)
protected

Compute m_tileMax from sharpVelocity.

◆ create()

static shared_ptr<MotionBlur> G3D::MotionBlur::create ( )
inlinestatic

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ debugDrawTiles()

void G3D::MotionBlur::debugDrawTiles ( RenderDevice rd,
const shared_ptr< Texture > &  neighborMax,
int  maxBlurRadiusPixels 
)
protected

Debug visualization of the motion blur tiles and directions.

Called from apply()

◆ debugShowTiles()

bool G3D::MotionBlur::debugShowTiles ( ) const
inline

◆ gatherBlur()

virtual void G3D::MotionBlur::gatherBlur ( RenderDevice rd,
const shared_ptr< Texture > &  color,
const shared_ptr< Texture > &  neighborMax,
const shared_ptr< Texture > &  velocity,
const shared_ptr< Texture > &  depth,
int  numSamplesOdd,
int  maxBlurRadiusPixels,
float  exposureTimeFraction,
Vector2int16  trimBandThickness 
)
protectedvirtual

Called from apply() to compute the blurry image to the current frame buffer by gathering.

◆ makeRandomBuffer()

void G3D::MotionBlur::makeRandomBuffer ( )
protected

◆ nextOdd()

static int G3D::MotionBlur::nextOdd ( int  n)
inlinestaticprotected

Returns n if it is odd, otherwise returns n + 1.

◆ setDebugShowTiles()

void G3D::MotionBlur::setDebugShowTiles ( bool  b)
inline

Toggle visualization showing the tile boundaries, which are set by maxBlurRadiusPixels.

◆ updateBuffers()

void G3D::MotionBlur::updateBuffers ( const shared_ptr< Texture > &  velocityTexture,
int  maxBlurRadiusPixels,
Vector2int16  trimBandThickness 
)
protected

Allocates tileMax and neighborMax as needed.

Member Data Documentation

◆ m_cachedSrc

shared_ptr<Texture> G3D::MotionBlur::m_cachedSrc
protected

The source color is copied into this if needed.

Saved between invocations to avoid reallocating the texture.

◆ m_debugShowTiles

bool G3D::MotionBlur::m_debugShowTiles
protected

◆ m_neighborMinMaxFramebuffer

shared_ptr<Framebuffer> G3D::MotionBlur::m_neighborMinMaxFramebuffer
protected

Size ceil(w / maxBlurRadius) x ceil(h / maxBlurRadius).

RG = max velocity in neighborhood, B = min speed in neighborhood

◆ m_randomBuffer

shared_ptr<Texture> G3D::MotionBlur::m_randomBuffer
protected

32x32 buffer of RG values on [0, 1)

◆ m_tileMinMaxFramebuffer

shared_ptr<Framebuffer> G3D::MotionBlur::m_tileMinMaxFramebuffer
protected

Size ceil(w / maxBlurRadius) x ceil(h / maxBlurRadius).

RG = max velocity in tile, B = min speed in tile

◆ m_tileMinMaxTempFramebuffer

shared_ptr<Framebuffer> G3D::MotionBlur::m_tileMinMaxTempFramebuffer
protected

Size h x ceil(w / maxBlurRadius).

RG = max velocity in tile, B = min speed in tile


documentation generated on Wed Nov 24 2021 08:01:58 using doxygen 1.8.15