Inherits DD::Image::CameraOp.
Public Types | |
enum | { eNoFalloff, eLinearFalloff, eQuadraticFalloff, eCubicFalloff } |
enum | LightType { ePointLight, eDirectionalLight, eSpotLight, eOtherLight } |
Public Member Functions | |
LightOp (Node *node) | |
int | samples () const |
void | set_samples (int n) |
float | sample_width () const |
void | set_sample_width (float width) |
const Pixel & | color () const |
void | color (const Pixel &v) |
float | intensity () const |
void | set_intensity (float v) |
bool | falloff () const |
void | set_falloff (bool b) |
int | falloffType () const |
void | set_falloffType (int b) |
bool | cast_shadows () const |
void | set_cast_shadows (bool b) |
float | depthmap_bias () const |
void | set_depthmap_bias (float v) |
float | shadow_jitter_scale () const |
void | set_shadow_jitter_scale (float v) |
int | depthmap_width () const |
void | set_depthmap_width (int n) |
void | setShadowMaskChannel (Channel &channel) |
Channel | getShadowMaskChannel () |
virtual bool | is_delta_light () const |
virtual void | get_L_vector (LightContext <x, const Vector3 &P, const Vector3 &N, Vector3 &L, float &D) const |
virtual float | get_shadowing (const LightContext <x, const Vector3 &P, Pixel &out) |
virtual void | get_color (LightContext <x, const Vector3 &P, const Vector3 &N, const Vector3 &L, float D, Pixel &out) |
virtual double | hfov () const |
virtual double | vfov () const |
virtual double | aspect () const |
virtual int | lightType () const |
void | _validate (bool for_real) |
virtual void | request (ChannelMask, int count) |
void | knobs (Knob_Callback) |
void | color_knobs (Knob_Callback) |
void | attenuation_knobs (Knob_Callback) |
void | shadow_knobs (Knob_Callback) |
unsigned | node_color () const |
void | build_handles (ViewerContext *) |
void | draw_handle (ViewerContext *) |
virtual void | shade_GL (ViewerContext *, int light_num) |
const char * | node_help () const |
This is the light node help. | |
const char * | displayName () const |
This is the node display name. | |
const char * | Class () const |
Static Public Attributes | |
static const Description | description |
Protected Attributes | |
Pixel | color_ |
Color of the light (can be >3 channels!). | |
float | intensity_ |
Global intensity. | |
bool | falloff_ |
Whether to factor in physical falloff. | |
int | falloffType_ |
falloff type | |
int | samples_ |
The number of samples (for area testing). | |
float | sample_width_ |
sample width (for shadowing) | |
bool | cast_shadows_ |
Whether light casts shadows. | |
float | depthmap_bias_ |
Offset in Z of shadow buffer. | |
float | shadow_jitter_scale_ |
Size of shadow jitter. | |
int | depthmap_width_ |
Size in pixels of shadow buffer. | |
Channel | _shadowMaskChannel |
Output the shadow mask to this channel. |
Light base class which defaults to point source lighting with falloff.
bool LightOp::is_delta_light | ( | ) | const [virtual] |
Whether the light has a delta distribution (point/spot/direct lights)
Whether the light has a delta distribution (point/spot/direct lights).
Referenced by DD::Image::Iop::fragment_shader().
void LightOp::get_L_vector | ( | LightContext & | ltx, | |
const Vector3 & | P, | |||
const Vector3 & | N, | |||
Vector3 & | L, | |||
float & | D | |||
) | const [virtual] |
Calculate direction vector and distance from this light to P.
Calculate a normalized direction vector L and distance D to surface point P. Surface normal N is passed to allow lights like area lights to simulate a large emission surface.
References DD::Image::Vector3::fast_normalize(), DD::Image::Vector3::normalize(), and DD::Image::LightContext::p().
Referenced by DD::Image::Iop::fragment_shader().
float LightOp::get_shadowing | ( | const LightContext & | ltx, | |
const Vector3 & | P, | |||
Pixel & | out | |||
) | [virtual] |
Return the amount of shadowing the light creates at surface point P. and optionally copies the shadow mask to the output pixel
Project surface point P into light's view aperture and test if it's further in Z than the shadow buffer sample. Jittered multi- sampling of the shadow buffer is supported when samples is greater than 1 which produces soft edged shadows.
References _shadowMaskChannel, DD::Image::Op::aborted(), cast_shadows_, clamp(), DD::Image::LightContext::depthmap(), depthmap_bias_, fast_floor(), DD::Image::LightContext::matrix(), shadow_jitter_scale_, DD::Image::Matrix4::transform(), DD::Image::Vector4::w, DD::Image::Vector4::x, DD::Image::Vector4::y, and DD::Image::Vector4::z.
Referenced by DD::Image::Iop::fragment_shader().
void LightOp::get_color | ( | LightContext & | ltx, | |
const Vector3 & | P, | |||
const Vector3 & | N, | |||
const Vector3 & | L, | |||
float | D, | |||
Pixel & | out | |||
) | [virtual] |
Return the color of this light. The light vector and distance are passed.
Returns the color of the light (possibly) using the current surface point and normal to calculate attenuation and penumbra. The base class returns a point source attenuated by the inverse squared distance.
References DD::Image::Pixel::channels, color_, falloffType_, and intensity_.
Referenced by DD::Image::Iop::fragment_shader().
virtual double DD::Image::LightOp::hfov | ( | ) | const [inline, virtual] |
field-of-view methods.
Referenced by _validate().
void LightOp::_validate | ( | bool | for_real | ) | [virtual] |
Reimplemented from DD::Image::CameraOp.
References depthmap_width_, hfov(), DD::Image::CameraOp::LENS_ORTHOGRAPHIC, DD::Image::CameraOp::LENS_PERSPECTIVE, MAX(), MIN(), and samples_.
void LightOp::request | ( | ChannelMask | channels, | |
int | count | |||
) | [virtual] |
Handle channel requests. Base class does nothing, but Lights that read imagery such as environment maps will need to implement this.
Referenced by DD::Image::Scene::request().
void LightOp::knobs | ( | Knob_Callback | f | ) | [virtual] |
Reimplemented from DD::Image::CameraOp.
References DD::Image::Divider(), DD::Image::Newline(), and DD::Image::Tab_knob().
void LightOp::draw_handle | ( | ViewerContext * | ctx | ) | [virtual] |
Draws a picture of a point light.
Reimplemented from DD::Image::CameraOp.
References DD::Image::Matrix4::array(), color_, DD::Image::ViewerContext::draw_knobs(), DD::Image::ViewerContext::fg_color(), DD::Image::gl_sphere(), DD::Image::gl_text(), DD::Image::glColor(), DD::Image::ViewerContext::icon_size(), DD::Image::ViewerContext::modelmatrix, DD::Image::ViewerContext::node_color(), DD::Image::Op::node_disabled(), DD::Image::Op::node_selected(), and DD::Image::Op::print_name().
void LightOp::shade_GL | ( | ViewerContext * | ctx, | |
int | light_num | |||
) | [virtual] |
Point light OpenGL settings.
References DD::Image::Matrix4::a03, DD::Image::Matrix4::a13, DD::Image::Matrix4::a23, DD::Image::Vector4::array(), color_, falloffType_, intensity_, DD::Image::Op::node_disabled(), DD::Image::Vector4::set(), and DD::Image::Vector4::w.
const char * LightOp::node_help | ( | ) | const [virtual] |
const char * LightOp::displayName | ( | ) | const [virtual] |
This is the node display name.
This is the node display name
Reimplemented from DD::Image::Op.
References Class(), and DD::Image::Op::Description::name.
const char * LightOp::Class | ( | ) | const [virtual] |
Reimplemented from DD::Image::CameraOp.
References DD::Image::Op::Description::name.
Referenced by displayName().
©2009 The Foundry Visionmongers, Ltd. All Rights Reserved. |