Base class for rendering a 3D scene to an image. More...
Inherits DD::Image::Iop.
Inherited by DD::Image::DepthMapRender, and DD::Image::RenderScene.
Classes | |
class | Span |
Public Types | |
enum | { SINGLE_SAMPLE, MULTISAMPLE_LOW, MULTISAMPLE_MED, MULTISAMPLE_HIGH } |
Public Member Functions | |
virtual CameraOp * | render_camera (int sample=0) |
virtual GeoOp * | render_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 Filter * | texture_filter () const |
int | multisampling () const |
float | hitThresholdDistance () const |
virtual int | multisamples () const |
virtual Scene * | scene (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 ¢er, 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 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. |
Base class for rendering a 3D scene to an image.
Render::Render | ( | Node * | node, |
bool | enable_mip_filter = false |
||
) | [protected] |
Base class constructor.
References DD::Image::Chan_U, DD::Image::eDisableMotionVector, generate_primitives, input_scenes, jitter, jitter_array(), DD::Image::CameraOp::LENS_RENDER_CAMERA, max_tessellation_, MB_channel, multisampling_, output_motion_vectors, overscanY_, projection_mode_, render_scenes, samples_, spatial_jitter_, and temporal_jitter_.
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().
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] |
Render just texture-maps the geometry with input0(). So the request figures out what uv's will be requested and that is the area needed.
Reimplemented from DD::Image::Iop.
Reimplemented in DD::Image::RenderScene.
References DD::Image::Box3::expand(), fast_floor(), DD::Image::IopInfoOwner::format(), DD::Image::GeoInfo::get_group_attribute(), DD::Image::Box::h(), DD::Image::IopInfoOwner::info(), DD::Image::Iop::input0(), DD::Image::Box3::r(), DD::Image::Iop::request(), DD::Image::Scene::request(), scenes_, DD::Image::GeometryList::size(), DD::Image::Box3::t(), DD::Image::Box::w(), DD::Image::Box::x(), and DD::Image::Box::y().
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] |
Initialize each sample Scene object and generate it's renderable primitives.
Reimplemented in DD::Image::DepthMapRender.
References DD::Image::Op::aborted(), DD::Image::Scene::delete_render_primitives(), DD::Image::Scene::generate_render_primitives(), DD::Image::GeoInfo::matrix, DD::Image::Scene::object_transforms_, scenes_, and DD::Image::Scene::transforms_.
Referenced by initialize().
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] |
Flat renderer used by gridwarp. If bg is non-zero, it is a row containing a background image which is used anywhere there are no primitives (note that it does not do an OVER, instead the alpha channel is replaced by the rendered ones just like all other channels).
References DD::Image::Row::copy(), DD::Image::QuadtreeNode< T >::data, DD::Image::Row::erase(), DD::Image::Render::Span::initialize(), DD::Image::Iop::input0(), DD::Image::Quadtree< T >::intersections(), MAX(), MIN(), DD::Image::Op::node(), DD::Image::IopInfoOwner::r(), DD::Image::Render::Span::r, DD::Image::Box3::r(), DD::Image::Render::Span::rprimitive(), DD::Image::VertexContext::sample(), scenes_, DD::Image::Box3::t(), DD::Image::VertexContext::vdX, DD::Image::Render::Span::vtx, DD::Image::Render::Span::vX, DD::Image::Row::writable(), and DD::Image::IopInfoOwner::x().
Referenced by engine().
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().
const Intersection * Render::jitter_array | ( | int | samples | ) | [static] |
Determine best jitter array to use based on the sample count 'n'.
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::build_handles | ( | ViewerContext * | ctx | ) | [virtual] |
Draw the internal geometry only when the panel's open.
Reimplemented from DD::Image::Iop.
Reimplemented in DD::Image::RenderScene.
References buildGeoInfoHandle(), DD::Image::ViewerContext::connected(), DD::Image::Iop::input0(), DD::Image::Op::panel_visible(), DD::Image::Op::pushed(), DD::Image::Iop::set_texturemap(), DD::Image::SHOW_OBJECT, DD::Image::SHOW_PUSHED_OBJECT, DD::Image::ViewerContext::transform_mode(), DD::Image::Op::validate(), and DD::Image::VIEWER_2D.
void Render::buildGeoInfoHandle | ( | ViewerContext * | ctx, |
DrawHandleCallbackFunc | cb | ||
) |
this sets the objects in the scene to be drawable (textured) and then calls GeoInfo::build_handles()
References DD::Image::ViewerContext::add_draw_handle(), DD::Image::CONNECTED, DD::Image::ViewerContext::connected(), DD::Image::GeoInfo::display3d, DD::Image::IopInfoOwner::info(), DD::Image::Iop::input0(), DD::Image::GeoInfo::material, DD::Image::Op::node(), DD::Image::GeoInfo::render_mode, scenes_, and DD::Image::GeoInfo::selected.
Referenced by build_handles().