HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BRAY_PixelFilter Class Referenceabstract

#include <BRAY_PixelFilter.h>

Classes

class  Factory
 

Public Types

using FactoryPtr = UT_UniquePtr< Factory >
 
using SampleData = BRAY_SampleFilter::SampleData
 

Public Member Functions

 BRAY_PixelFilter (const UT_Options *options)
 
virtual ~BRAY_PixelFilter ()
 
virtual const char * className () const =0
 Class name for the pixel filter. More...
 
virtual void filter (BRAY_PixelState &pstate, const SampleData &data, const UT_Vector4 *sample_locations, const UT_BitArray &ray_hits, size_t nsamples)=0
 
virtual bool checkpoint (UT_JSONWriter &w) const =0
 
virtual bool loadCheckpoint (UT_JSONParser &p)
 
void writePixel (BRAY_PixelState &ps, const SampleData &data, const UT_Vector4 *sample_locations, int sidx)
 
void overwritePixel (BRAY_PixelState &ps, const SampleData &data, const UT_Vector4 *sample_locations, int sidx)
 
void accumulatePixel (BRAY_PixelState &ps, const SampleData &data, const UT_Vector4 *sample_locations, int sidx)
 Add to existing data without any filtering. More...
 
void missPixel (BRAY_PixelState &ps, const SampleData &data, const UT_Vector4 *sample_locations, int sidx)
 
bool hasWrittenPixel (const BRAY_PixelState &ps, const UT_Vector4 *sample_locations, int sidx) const
 Test to see if data has been written to a given sample. More...
 
const UT_IntArrayaovs () const
 
virtual int aovLimit () const
 
bool saveState (UT_JSONWriter &w) const
 
bool loadState (UT_JSONParser &p)
 

Static Public Member Functions

static void listFactories (UT_StringArray &result, bool include_deprecated=false)
 
static void registerPlugin (const UT_StringHolder &name, FactoryPtr factory)
 
static UT_UniquePtr
< BRAY_PixelFilter
instancePlugin (const UT_StringRef &style, const UT_Options *options=nullptr)
 
static void releasePlugin (UT_UniquePtr< BRAY_PixelFilter > p)
 
static void freePluginCache ()
 

Protected Member Functions

virtual void setResolution (BRAY_FilterInit &init, int xres, int yres, const UT_StringArray &aovnames)
 
int addAOV (BRAY_FilterInit &init, const UT_StringHolder &name, const UT_StringHolder &var, int tuple_size, const BRAY::OptionSet &options)
 
BRAY::OptionSet planeProperties (BRAY_FilterInit &init) const
 Create an option set before adding creating an extra AOV. More...
 
void setAOVs (const UT_IntArray &aovs)
 
SYS_HashType optionsHash () const
 

Detailed Description

Pixel filters take raw samples as generated by the renderer and can adjust the sample data values prior to sending it to pixel filtering. A pixel filter might average all the samples for a given pixel, or it might just select a single sample for the pixel value.

Definition at line 35 of file BRAY_PixelFilter.h.

Member Typedef Documentation

Sample data passed to the pixel filter is the same as the data processed by sample filters.

Definition at line 76 of file BRAY_PixelFilter.h.

Constructor & Destructor Documentation

BRAY_PixelFilter::BRAY_PixelFilter ( const UT_Options options)
virtual BRAY_PixelFilter::~BRAY_PixelFilter ( )
virtual

Member Function Documentation

void BRAY_PixelFilter::accumulatePixel ( BRAY_PixelState &  ps,
const SampleData data,
const UT_Vector4 sample_locations,
int  sidx 
)

Add to existing data without any filtering.

int BRAY_PixelFilter::addAOV ( BRAY_FilterInit &  init,
const UT_StringHolder name,
const UT_StringHolder var,
int  tuple_size,
const BRAY::OptionSet options 
)
protected

If the filter needs an additional AOV, you can call this method during setResolution(). The function returns the index of the new AOV (or -1 on failure). If there are errors, the messages will be printed out to UT_ErrorLog.

Data from this AOV will be available in the SampleData at the returned index.

If options are required, they can be initialized by planeProperties() Passing in an empty OptionSet is legal.

virtual int BRAY_PixelFilter::aovLimit ( ) const
inlinevirtual

By default(0) one pixel filter instance can be applied to any number of AOVs. Some filters (e.g. minmax under "min" or "max" mode) shouldn't be shared between multiple AOVs, in which case this may return 1.

Definition at line 170 of file BRAY_PixelFilter.h.

const UT_IntArray& BRAY_PixelFilter::aovs ( ) const
inline

Return the AOVs that this pixel filter is applied to. This may not be a subset of all the AOVs. The filter should only write to these planes and no others.

Definition at line 156 of file BRAY_PixelFilter.h.

virtual bool BRAY_PixelFilter::checkpoint ( UT_JSONWriter w) const
pure virtual

The checkpoint function is called to save the state of the pixel filter to a checkpoint file.

virtual const char* BRAY_PixelFilter::className ( ) const
pure virtual

Class name for the pixel filter.

virtual void BRAY_PixelFilter::filter ( BRAY_PixelState &  pstate,
const SampleData data,
const UT_Vector4 sample_locations,
const UT_BitArray ray_hits,
size_t  nsamples 
)
pure virtual

Process the sample data. Each AOV plane of the data will point to a contiguous array of sample data which contains at least npixels of data. The filter should be applied to each pixel in the sample data.

The sample_locations are stored as:

v[0] := pixel_x location
v[1] := pixel_y location
v[2] := jitter_x location (0 to 1 in pixel)
v[3] := jitter_y location (0 to 1 in pixel)

Note that with Filtered Importance Sampling, the jitter values may be outside the given pixel.

The BRAY_PixelState object is an opaque object that should be passed to writePixel()

The typical filtering code looks like:

for (size_t sample = 0; sample < nsamples; ++sample)
{
if (ray_hits.getBit(sample))
writePixel(pstate, data, sample_locations, i);
else
missPixel(pstate, sample_locations, i);
}
static void BRAY_PixelFilter::freePluginCache ( )
static

Access to factory

bool BRAY_PixelFilter::hasWrittenPixel ( const BRAY_PixelState &  ps,
const UT_Vector4 sample_locations,
int  sidx 
) const

Test to see if data has been written to a given sample.

static UT_UniquePtr<BRAY_PixelFilter> BRAY_PixelFilter::instancePlugin ( const UT_StringRef style,
const UT_Options options = nullptr 
)
static

Access to factory

static void BRAY_PixelFilter::listFactories ( UT_StringArray result,
bool  include_deprecated = false 
)
static

Access to factory

virtual bool BRAY_PixelFilter::loadCheckpoint ( UT_JSONParser p)
virtual

loadCheckpoint is called to restore the state of the pixel filter. In theory, all the settings for the pixel filter should match. Only per-pixel data should be different.

bool BRAY_PixelFilter::loadState ( UT_JSONParser p)

Save and restore state

void BRAY_PixelFilter::missPixel ( BRAY_PixelState &  ps,
const SampleData data,
const UT_Vector4 sample_locations,
int  sidx 
)

If the sample missed, this method can be called to write data more efficiently (writing zero to the AOVs).

SYS_HashType BRAY_PixelFilter::optionsHash ( ) const
inline

This method is used to create the weight buffer.

Definition at line 164 of file BRAY_PixelFilter.h.

void BRAY_PixelFilter::overwritePixel ( BRAY_PixelState &  ps,
const SampleData data,
const UT_Vector4 sample_locations,
int  sidx 
)

Overwrite the color in the pixel with the given sample data. This doesn't filter data, but writes the data directly to the AOVs, overwriting the data that was there previously.

BRAY::OptionSet BRAY_PixelFilter::planeProperties ( BRAY_FilterInit &  init) const
protected

Create an option set before adding creating an extra AOV.

static void BRAY_PixelFilter::registerPlugin ( const UT_StringHolder name,
FactoryPtr  factory 
)
static

Access to factory

static void BRAY_PixelFilter::releasePlugin ( UT_UniquePtr< BRAY_PixelFilter p)
static

Access to factory

bool BRAY_PixelFilter::saveState ( UT_JSONWriter w) const

Save and restore state

void BRAY_PixelFilter::setAOVs ( const UT_IntArray aovs)
inline

This method is used to create the weight buffer.

Definition at line 163 of file BRAY_PixelFilter.h.

virtual void BRAY_PixelFilter::setResolution ( BRAY_FilterInit &  init,
int  xres,
int  yres,
const UT_StringArray aovnames 
)
protectedvirtual

This method can be used to perform any setup required prior to filtering. This method may be called when re-rendering. That is, this method may be called on an existing object.

The AOV names passed in will be in the same order as the sample data passed in.

void BRAY_PixelFilter::writePixel ( BRAY_PixelState &  ps,
const SampleData data,
const UT_Vector4 sample_locations,
int  sidx 
)

Write sample data to a pixel. The weight is the filter weight for the given sample. The sample data is passed directly from the BRAY_SampleFilters.


The documentation for this class was generated from the following file: