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

#include <BRAY_PixelOracle.h>

Classes

class  Factory
 

Public Types

using FactoryPtr = UT_UniquePtr< Factory >
 

Public Member Functions

 BRAY_PixelOracle (const UT_Options *args)
 
virtual ~BRAY_PixelOracle ()
 
virtual const char * className () const =0
 Class name of the oracle. More...
 
virtual size_t fillPixels (BRAY_PixelState *pstate, const UT_DimRect &rect, UT_Vector2i *pixels)
 
virtual bool initializeOracle (BRAY_FilterInit &init, int xres, int yres, int spp, const UT_StringArray &aov_names, const UT_IntArray &aov_sizes)=0
 
SYS_HashType optionsHash () const
 Return the hash of the arguments for this filter. More...
 
virtual BRAY_SampleFilterPtr sampleFilter (BRAY_FilterInit &init, const UT_StringArray &all_aovs)
 
virtual bool checkpoint (UT_JSONWriter &w) const =0
 
virtual bool loadCheckpoint (UT_JSONParser &p)
 

Static Public Member Functions

static void listFactories (UT_StringArray &result)
 
static void registerPlugin (const UT_StringHolder &name, FactoryPtr factory)
 
static UT_UniquePtr
< BRAY_PixelOracle
instancePlugin (const UT_StringRef &style, const UT_Options *options)
 
static void releasePlugin (UT_UniquePtr< BRAY_PixelOracle > p)
 
static void freePluginCache ()
 

Protected Member Functions

const floatreadPixel (const BRAY_PixelState &pstate, int aov_index, int px, int py) const
 
float randomF (BRAY_PixelState &pstate) const
 
uint randomI (BRAY_PixelState &pstate) const
 
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...
 

Detailed Description

A Pixel Oracle is responsible for detemining which pixels should be sampled within a tile.

Definition at line 32 of file BRAY_PixelOracle.h.

Member Typedef Documentation

Constructor & Destructor Documentation

BRAY_PixelOracle::BRAY_PixelOracle ( const UT_Options args)
virtual BRAY_PixelOracle::~BRAY_PixelOracle ( )
virtual

Member Function Documentation

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

If the oracle needs an additional AOV, you can call this method during initializeOracle(). 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.

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

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

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

The default method prints a warning that checkpointing isn't supported and fails.

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

Class name of the oracle.

virtual size_t BRAY_PixelOracle::fillPixels ( BRAY_PixelState *  pstate,
const UT_DimRect rect,
UT_Vector2i pixels 
)
virtual

Fill out the pixels which need to be sampled, returning the number of pixels filled out. The pixels buffer is guaranteed to have at least rect.width()*rect.height() entries. The function should return the number of samples filled out. Each pixel should be inside the bounding rectangle.

The oracle is free to return a smaller number of rays. It's also possible to send multiple rays for a single pixel.

The default method will send one ray per pixel and is somewhat similar to

for (int y = rect.y(), ye = rect.y2e(); y < ye; ++y)
for (int x = rect.x(), xe = rect.x2e(); x < xe; ++x, ++pixels)
return rect.width()*rect.height();
static void BRAY_PixelOracle::freePluginCache ( )
static

Factory access

virtual bool BRAY_PixelOracle::initializeOracle ( BRAY_FilterInit &  init,
int  xres,
int  yres,
int  spp,
const UT_StringArray aov_names,
const UT_IntArray aov_sizes 
)
pure virtual

Method used to initialize the oracle. This will be called prior to each render (oracles should clear any buffers on subsequent renders).

Note that sample filters are not cleared between subsequent renders, so if the oracle creates a sample filter, it should be persistent between runs.

static UT_UniquePtr<BRAY_PixelOracle> BRAY_PixelOracle::instancePlugin ( const UT_StringRef style,
const UT_Options options 
)
static

Factory access

static void BRAY_PixelOracle::listFactories ( UT_StringArray result)
static

Factory access

virtual bool BRAY_PixelOracle::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.

SYS_HashType BRAY_PixelOracle::optionsHash ( ) const
inline

Return the hash of the arguments for this filter.

Definition at line 94 of file BRAY_PixelOracle.h.

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

Create an option set before adding creating an extra AOV.

float BRAY_PixelOracle::randomF ( BRAY_PixelState &  pstate) const
protected

Return a random number. The sequence of random numbers will be consistent for every render, regardless of threading order.

The random functions use the same internal state so they should be called consistently.

uint BRAY_PixelOracle::randomI ( BRAY_PixelState &  pstate) const
protected

Return an integer random number. This can be used as a seed if multiple random numbers need to be generated. The sequence of random numbers will be conssitent for every render, regardless of threading order.

The random functions use the same internal state so they should be called consistently.

const float* BRAY_PixelOracle::readPixel ( const BRAY_PixelState &  pstate,
int  aov_index,
int  px,
int  py 
) const
protected

Read a pixel from a given AOV. The aov_index should be the index into the aovnames that was passed into initializeOracle() (or the index returned by addAOV());

For greater efficiency, consider creating a paired SampleFilter.

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

Factory access

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

Factory access

virtual BRAY_SampleFilterPtr BRAY_PixelOracle::sampleFilter ( BRAY_FilterInit &  init,
const UT_StringArray all_aovs 
)
inlinevirtual

Sometimes an oracle can be more efficient when tied to a sampling filter. This method allows an oracle to create a sampling filter to keep track of samples written to the image. This method is called after initializeOracle().

If the oracle creates a sample filter, it should make sure to call BRAY_SampleFilter::initialize() on the created sample filter.

Definition at line 103 of file BRAY_PixelOracle.h.


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