DD::Image::LightOp Class Reference

LightOp defines a 3D light. More...

Inherits DD::Image::CameraOp.

Inherited by DD::Image::ComplexLightOp.

List of all members.

Public Types

enum  { eNoFalloff, eLinearFalloff, eQuadraticFalloff, eCubicFalloff }
enum  LightType { ePointLight, eDirectionalLight, eSpotLight, eOtherLight }
enum  ShadowMode { eSolidShadow, eTransparentShadow, eSemiTransparentShadow }

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 Pixelcolor () 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)
int shadows_mode () const
float alpha_threshold () const
TextureFiltershadow_filter ()
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 () const
virtual bool is_delta_light () const
virtual void get_L_vector (LightContext &ltx, const Vector3 &P, const Vector3 &N, Vector3 &L, float &D) const
 Calculate direction vector and distance from this light to P.
virtual float get_shadowing (const LightContext &ltx, const VertexContext &vtx, const Vector3 &P, Pixel &out)
 Return the amount of shadowing the light creates at surface point P. and optionally copies the shadow mask to the output pixel.
virtual void get_color (LightContext &ltx, const Vector3 &P, const Vector3 &N, const Vector3 &L, float D, Pixel &out)
 Return the color of this light. The light vector and distance are passed.
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)
int knob_changed (Knob *k)
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.
int shadows_mode_
 Shadow casting mode.
TextureFilter shadow_filter_
 Default filter to use in shadow texture sampling.
float scene_epsilon_
 Scene epsilon for shadow comparison.
float depthmap_bias_
 Offset in Z of shadow buffer.
float depthmap_slope_bias_
 Offset in Z to be scale in proportion of the local gradient.
float alpha_threshold_
 Alpha threshold for transparent shadow map mode.
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.

Detailed Description

LightOp defines a 3D light.

Light base class which defaults to point source lighting with falloff.


Member Enumeration Documentation

Enumerator:
eSolidShadow 

the light cast shadow considering every geometry fully solid

eTransparentShadow 

the light cast shadow considering the alpha channel of the texture mapped on the geometry

eSemiTransparentShadow 

the light cast shadow in semi transparent mode


Member Function Documentation

bool LightOp::is_delta_light ( ) const [virtual]

Whether the light has a delta distribution (point/spot/direct lights)

Reimplemented in DD::Image::ComplexLightOp.

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.

Reimplemented in DD::Image::ComplexLightOp.

References DD::Image::Vector3::fast_normalize(), and DD::Image::Vector3::normalize().

float LightOp::get_shadowing ( const LightContext ltx,
const VertexContext vtx,
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(), DD::Image::Iop::at(), cast_shadows_, clamp(), depthmap_bias_, depthmap_slope_bias_, DD::Image::Vector3::dot(), eSemiTransparentShadow, fast_floor(), DD::Image::Render::jitter_array(), DD::Image::Vector3::lengthSquared(), DD::Image::Vector3::normalize(), DD::Image::Render::probe(), DD::Image::IopInfoOwner::r(), scene_epsilon_, shadow_jitter_scale_, DD::Image::IopInfoOwner::t(), DD::Image::IopInfoOwner::x(), and DD::Image::IopInfoOwner::y().

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.

Reimplemented in DD::Image::ComplexLightOp.

References color_, falloffType_, and intensity_.

virtual double DD::Image::LightOp::hfov ( ) const [inline, virtual]

field-of-view methods.

Reimplemented in DD::Image::ComplexLightOp.

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::shade_GL ( ViewerContext ctx,
int  light_num 
) [virtual]