DD::Image::Render Class Reference

Base class for rendering a 3D scene to an image. More...

Inherits DD::Image::Iop.

Inherited by DD::Image::DepthMapRender, and DD::Image::RenderScene.

List of all members.

Classes

class  Span

Public Types

enum  { SINGLE_SAMPLE, MULTISAMPLE_LOW, MULTISAMPLE_MED, MULTISAMPLE_HIGH }

Public Member Functions

virtual CameraOprender_camera (int sample=0)
virtual GeoOprender_geo (int sample=0)=0
virtual Matrix4 camera_matrix (int sample=0)
virtual Matrix4 projection_matrix (int sample=0)
virtual void format_matrix (int sample=0)
Matrix4 get_format_matrix (float cx, float cy)
void knobs (Knob_Callback)
void display_knobs (Knob_Callback)
void texture_knobs (Knob_Callback)
void sampling_knobs (Knob_Callback)
void jitter_knobs (Knob_Callback)
void render_knobs (Knob_Callback)
 All of the above.
unsigned node_color () const
double overscanX ()
double overscanY ()
int projection_mode () const
int blend_operation () const
const Filtertexture_filter () const
int multisampling () const
float hitThresholdDistance () const
virtual int multisamples () const
virtual Scenescene (int n=0) const
virtual double shutter () const
virtual double offset () const
virtual unsigned samples () const
HandlesMode doAnyHandles (ViewerContext *ctx)
void build_handles (ViewerContext *)
void buildGeoInfoHandle (ViewerContext *ctx, DrawHandleCallbackFunc cb)
virtual void probe (const Vector3 &center, const VertexContext &vtx, Pixel &out)
 Sample the frame buffer.

Static Public Member Functions

static Matrix4 get_format_matrix (const Format &format, float cx, float cy)
static const Intersection * multisample_array (int n)
static unsigned int jitter_array_size (int samples)
static const Intersection * jitter_array (int samples)

Static Public Attributes

static const char * multisampling_table []
 Output sampling modes:

Protected Member Functions

 Render (Node *node, bool enable_mip_filter=false)
void _validate (bool)
virtual void overrideBBox (Box &f) const
void _request (int x, int y, int r, int t, ChannelMask, int)
void engine (int y, int x, int r, ChannelMask, Row &)
virtual bool generate_render_primitives ()
virtual bool evaluate_lights (Scene *scene)
virtual void initialize ()
void draw_primitives (int y, int x, int r, ChannelMask, Row &, const Row *bg)
void _close ()

Protected Attributes

TextureFilter texture_filter_
 Default filter to use in texture filtering.
int projection_mode_
 Point projection mode.
int max_tessellation_
 Threshold to limit recursive subdivision.
int blend_operation_
 Default blending operation for textures.
int multisampling_
 Output sampling modes.
int samples_
 User set number of samples to render.
ShutterControls shutter_
 shutter controls
double spatial_jitter_
 User set jittering of sample in raster.
double temporal_jitter_
 User set jittering of sample in time.
const Intersection * jitter
 XY jitter array to use - based on total samples.
unsigned input_scenes
 Number of scenes renderer gets from it's input.
unsigned render_scenes
 Number of scenes to render.
const Intersection * multisample_array_
 Multisampling array to use.
double overscanX_
double overscanY_
 overscan size of the frame buffer
Format overscanFormat_
 overscan format
int junk
Box3 world_bbox
 Intersected world-space bbox of all scenes.
Box screen_bbox
 Intersected screen-space bbox of all scenes.
int output_motion_vectors
 Whether renderer outputs motion vector channels.
Channel MB_channel [3]
 Motion vector channels to output.
bool generate_primitives
 Threading lock to keep other threads waiting.
std::vector< Scene * > scenes_
 List of Scenes, one per sample.

Detailed Description

Base class for rendering a 3D scene to an image.


Constructor & Destructor Documentation


Member Function Documentation

CameraOp * Render::render_camera ( int  sample = 0) [virtual]

Return a CameraOp for 'sample'. The base class returns null.

Reimplemented in DD::Image::RenderScene.

Referenced by _validate().

GeoOp * DD::Image::Render::render_geo ( int  sample = 0) [pure virtual]

Return a GeoOp for 'sample'. This GeoOp will have it's cache enabled which will be created during _validate(). The base class returns 0.

Implemented in DD::Image::RenderScene.

Referenced by _validate().

Matrix4 Render::camera_matrix ( int  sample = 0) [virtual]

Calculate the camera's inverse local matrix for 'sample'. Base class pulls the camera away in Z by the format's width, and XY centered. Remember, this is the camera's *inverse* matrix, so translations are reversed.

Reimplemented in DD::Image::DepthMapRender, and DD::Image::RenderScene.

References DD::Image::IopInfoOwner::format(), DD::Image::Format::height(), DD::Image::Matrix4::makeIdentity(), DD::Image::Matrix4::translate(), and DD::Image::Format::width().

Referenced by _validate().

Matrix4 Render::projection_matrix ( int  sample = 0) [virtual]

Calculate the camera projection matrix for 'sample'. Base class implementation sets up a simple projection with a lens of 1.

Reimplemented in DD::Image::RenderScene.

References DD::Image::IopInfoOwner::format(), DD::Image::IopInfoOwner::h(), DD::Image::Format::height(), DD::Image::Matrix4::projection(), DD::Image::Matrix4::scaling(), DD::Image::IopInfoOwner::w(), and DD::Image::Format::width().

Referenced by _validate().

void Render::format_matrix ( int  sample = 0) [virtual]

obsolete virtual function, do not use. Call get_format_matrix() instead

Matrix4 Render::get_format_matrix ( float  cx,
float  cy 
)

Calculate the transformation from post-projection NDC to pixel space. cx,cy are where in the pixel the -1,-1 corner should be.

References DD::Image::IopInfoOwner::info_.

Referenced by _validate(), and DD::Image::RenderScene::build_handles().

Matrix4 Render::get_format_matrix ( const Format format,
float  cx,
float  cy 
) [static]

Calculate the transformation from post-projection NDC to pixel space. cx,cy are where in the pixel the -1,-1 corner should be.

References DD::Image::IopInfoOwner::h(), DD::Image::Format::height(), DD::Image::Matrix4::makeIdentity(), DD::Image::Matrix4::scale(), DD::Image::Matrix4::translate(), DD::Image::IopInfoOwner::w(), and DD::Image::Format::width().

void Render::_validate ( bool  for_real) [protected, virtual]

Base-class implementation allocates a Scene structure for each time sample and enables the generation of primitives in the first engine() call.

Reimplemented from DD::Image::Iop.

Reimplemented in DD::Image::RenderScene.

References DD::Image::Scene::_id, DD::Image::Scene::_time, DD::Image::Op::aborted(), DD::Image::GeoOp::build_scene(), DD::Image::Scene::camera, camera_matrix(), DD::Image::IopInfoOwner::channels(), DD::Image::Box::clear(), DD::Image::Iop::copy_info(), DD::Image::CameraOp::default_camera(), DD::Image::eClassicMotionVector, DD::Image::eDisableMotionVector, evaluate_lights(), DD::Image::Box3::expand(), DD::Image::Scene::format_, generate_primitives, get_format_matrix(), DD::Image::Format::height(), DD::Image::IopInfoOwner::info_, DD::Image::Iop::input0(), input_scenes, DD::Image::Op::inputContext(), DD::Image::Box::intersect(), jitter, jitter_array(), DD::Image::Scene::lens_func, DD::Image::CameraOp::LENS_PERSPECTIVE, DD::Image::CameraOp::LENS_RENDER_CAMERA, DD::Image::CameraOp::lensNfunction(), MAX(), max_tessellation_, DD::Image::Scene::max_tessellation_, DD::Image::Scene::mb_scene_, DD::Image::Scene::mb_type_, DD::Image::Box::merge(), multisample_array(), multisample_array_, multisampling_, output_motion_vectors, overrideBBox(), overscanFormat_, overscanY_, DD::Image::Box::pad(), projection_matrix(), DD::Image::Scene::projection_mode_, projection_mode_, render_camera(), render_geo(), render_scenes, scenes_, screen_bbox, DD::Image::Box::set(), DD::Image::MatrixArray::set_camera_matrix(), DD::Image::MatrixArray::set_format_matrix(), DD::Image::Iop::set_out_channels(), DD::Image::MatrixArray::set_projection_matrix(), DD::Image::Op::slowness(), spatial_jitter_, texture_filter_, DD::Image::Scene::validate(), DD::Image::Op::validate(), DD::Image::Format::width(), and world_bbox.

virtual void DD::Image::Render::overrideBBox ( Box f) const [inline, protected, virtual]

called in Render::_validate, to allow the deriving class to override the bbox.

Referenced by _validate().

void Render::_request ( int  x,
int  y,
int  r,
int  t,
ChannelMask  out_channels,
int  count 
) [protected, virtual]
void Render::engine ( int  y,
int  x,
int  r,
ChannelMask  channels,
Row out 
) [protected, virtual]

Default engine calls initialize() (which calls generate_render_primitives()) and then calls draw_primitives() with bg=0.

Implements DD::Image::Iop.

References draw_primitives(), and initialize().

bool Render::generate_render_primitives ( ) [protected, virtual]
bool Render::evaluate_lights ( Scene scene) [protected, virtual]

Evaluate all the scene lights.

References DD::Image::Scene::evaluate_lights().

Referenced by _validate().

void Render::initialize ( ) [protected, virtual]

engine() must call this before it can look at the primitives

References DD::Image::Op::aborted(), generate_primitives, generate_render_primitives(), and texture_filter_.

Referenced by engine().

void Render::draw_primitives ( int  y,
int  x,
int  r,
ChannelMask  channels,
Row out_row,
const Row bg 
) [protected]
float Render::hitThresholdDistance ( ) const

Return the distance away that a span/pixel cannot intersect

References multisampling_.

const Intersection * Render::multisample_array ( int  n) [static]

Return multisample array for the current output sampling mode.

Referenced by _validate().

unsigned int Render::jitter_array_size ( int  samples) [static]

Determine the size of jitter array to use based on the sample count 'samples'.

const Intersection * Render::jitter_array ( int  samples) [static]

Determine best jitter array to use based on the sample count 'samples'.

Referenced by _validate(), DD::Image::LightOp::get_shadowing(), and Render().

int Render::multisamples ( ) const [virtual]

Return the number of samples in the current output sampling mode.

References multisampling_.

void Render::buildGeoInfoHandle ( ViewerContext ctx,
DrawHandleCallbackFunc  cb 
)