Panda3D
|
Base class for Lights. More...
Public Types | |
enum | LightType { LT_empty = 0, LT_point_light = 1, LT_spot_light = 2 } |
Different types of light. More... | |
Public Member Functions | |
clearIesProfile () | |
Clears the ies profile. More... | |
bool | getCastsShadows () |
Returns whether the light casts shadows. More... | |
const LVecBase3 | getColor () |
Returns the lights color. More... | |
float | getEnergy () |
Returns the energy of the light. More... | |
int | getIesProfile () |
Returns the lights ies profile. More... | |
RPLight::LightType | getLightType () |
Returns the type of the light. More... | |
float | getNearPlane () |
Returns the near plane of the light. More... | |
const LVecBase3 | getPos () |
Returns the position of the light. More... | |
int | getShadowMapResolution () |
Returns the shadow map resolution. More... | |
bool | hasIesProfile () |
Returns whether the light has an ies profile assigned. More... | |
invalidateShadows () | |
Invalidates the shadows. More... | |
setCastsShadows (bool flag) | |
Controls whether the light casts shadows. More... | |
setColor (const LVecBase3 color) | |
Sets the lights color. More... | |
setColor (float r, float g, float b) | |
Sets the lights color. More... | |
setColorFromTemperature (float temperature) | |
Sets the lights color from a given color temperature. More... | |
setEnergy (float energy) | |
Sets the energy of the light. More... | |
setIesProfile (int profile) | |
Sets the ies profile. More... | |
setNearPlane (float near_plane) | |
Sets the near plane of the light. More... | |
setPos (const LVecBase3 pos) | |
Sets the position of the light. More... | |
setPos (float x, float y, float z) | |
Sets the position of the light. More... | |
setShadowMapResolution (int resolution) | |
Sets the lights shadow map resolution. More... | |
![]() | |
int | getRefCount () |
Returns the current reference count. More... | |
ref () | |
Explicitly increments the reference count. More... | |
bool | testRefCountIntegrity () |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | testRefCountNonzero () |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
bool | unref () |
Explicitly decrements the reference count. More... | |
Public Attributes | |
bool | casts_shadows |
Returns whether the light casts shadows. More... | |
const LVecBase3 | color |
Returns the lights color. More... | |
float | energy |
Returns the energy of the light. More... | |
int | ies_profile |
Returns the lights ies profile. More... | |
RPLight::LightType | light_type |
Returns the type of the light. More... | |
float | near_plane |
Returns the near plane of the light. More... | |
const LVecBase3 | pos |
Returns the position of the light. More... | |
int | shadow_map_resolution |
Returns the shadow map resolution. More... | |
![]() | |
int | ref_count |
The current reference count. More... | |
Additional Inherited Members | |
![]() | |
static TypeHandle | getClassType () |
Base class for Lights.
This is the base class for all lights in the render pipeline. It stores common properties, and provides methods to modify these. It also defines some interface functions which subclasses have to implement.
enum LightType |
clearIesProfile | ( | ) |
Clears the ies profile.
This clears the ies profile of the light, telling it to no longer use an ies profile, and instead use the default attenuation.
bool getCastsShadows | ( | ) |
Returns whether the light casts shadows.
This returns whether the light casts shadows, the returned value is the one previously set with RPLight::set_casts_shadows.
const LVecBase3 getColor | ( | ) |
Returns the lights color.
This returns the light color, previously set with RPLight::set_color. This does not include the energy of the light. It might differ from what was set with set_color, because the color is normalized by dividing it by its luminance.
float getEnergy | ( | ) |
Returns the energy of the light.
This returns the energy of the light, previously set with RPLight::set_energy.
int getIesProfile | ( | ) |
Returns the lights ies profile.
This returns the ies profile of a light, previously set with RPLight::set_ies_profile. In case no ies profile was set, returns -1.
RPLight::LightType getLightType | ( | ) |
Returns the type of the light.
This returns the internal type of the light, which was specified in the lights constructor. This can be used to distinguish between light types.
float getNearPlane | ( | ) |
Returns the near plane of the light.
This returns the lights near plane, previously set with RPLight::set_near_plane. If the light does not cast shadows, this value is meaningless.
const LVecBase3 getPos | ( | ) |
Returns the position of the light.
This returns the position of the light previously set with RPLight::set_pos(). The returned position is in world space.
int getShadowMapResolution | ( | ) |
Returns the shadow map resolution.
This returns the shadow map resolution of each source of the light. If the light is not setup to cast shadows, this value is meaningless. The returned value is the one previously set with RPLight::set_shadow_map_resolution.
bool hasIesProfile | ( | ) |
Returns whether the light has an ies profile assigned.
This returns whether the light has an ies profile assigned, previously done with RPLight::set_ies_profile.
invalidateShadows | ( | ) |
Invalidates the shadows.
This invalidates all shadows of the light, causing them to get regenerated. This might be the case when the lights position or similar changed. This will cause all shadow sources to be updated, emitting a shadow update. Be careful when calling this method if you don't want all sources to get updated. If you only have to invalidate a single shadow source, use get_shadow_source(n)->set_needs_update(true).
setCastsShadows | ( | bool | flag | ) |
Controls whether the light casts shadows.
This sets whether the light casts shadows. You can not change this while the light is attached. When flag is set to true, the light will be setup to cast shadows, spawning shadow sources based on the lights type. If the flag is set to false, the light will be inddicated to cast no shadows.
flag | Whether the light casts shadows |
setColor | ( | const LVecBase3 | color | ) |
Sets the lights color.
This sets the lights color. The color should not include the brightness of the light, you should control that with the energy. The color specifies the lights "tint" and will get multiplied with its specular and diffuse contribution.
The color will be normalized by dividing by the colors luminance. Setting higher values than 1.0 will have no effect.
color | Light color |
setColor | ( | float | r, |
float | g, | ||
float | b | ||
) |
Sets the lights color.
r | Red-component of the color |
g | Green-component of the color |
b | Blue-component of the color |
setColorFromTemperature | ( | float | temperature | ) |
Sets the lights color from a given color temperature.
This sets the lights color, given a temperature. This is more physically based than setting a user defined color. The color will be computed from the given temperature.
temperature | Light temperature |
setEnergy | ( | float | energy | ) |
Sets the energy of the light.
This sets the energy of the light, which can be seen as the brightness of the light. It will get multiplied with the normalized color.
energy | energy of the light |
setIesProfile | ( | int | profile | ) |
Sets the ies profile.
This sets the ies profile of the light. The parameter should be a handle previously returned by RenderPipeline.load_ies_profile. Using a value of -1 indicates no ies profile.
Notice that for ies profiles which cover a whole range, you should use PointLights, whereas for ies profiles which only cover the lower hemisphere you should use SpotLights for the best performance.
profile | IES Profile handle |
setNearPlane | ( | float | near_plane | ) |
Sets the near plane of the light.
This sets the near plane of all shadow sources of the light. It has no effects if the light does not cast shadows. This prevents artifacts from objects near to the light. It behaves like Lens::set_near_plane.
It can also help increasing shadow map precision, low near planes will cause the precision to suffer. Try setting the near plane as big as possible.
If a negative or zero near plane is passed, an assertion is thrown.
near_plane | Near-plane |
setPos | ( | const LVecBase3 | pos | ) |
Sets the position of the light.
This sets the position of the light in world space. It will cause the light to get invalidated, and resubmitted to the GPU.
pos | Position in world space |
setPos | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets the position of the light.
x | X-component of the position |
y | Y-component of the position |
z | Z-component of the position |
setShadowMapResolution | ( | int | resolution | ) |
Sets the lights shadow map resolution.
This sets the lights shadow map resolution. This has no effect when the light is not told to cast shadows (Use RPLight::set_casts_shadows).
When calling this on a light with multiple shadow sources (e.g. PointLight), this controls the resolution of each source. If the light has 6 shadow sources, and you use a resolution of 512x512, the lights shadow map will occur a space of 6 * 512x512 maps in the shadow atlas.
resolution | Resolution of the shadow map in pixels |
bool casts_shadows |
Returns whether the light casts shadows.
This returns whether the light casts shadows, the returned value is the one previously set with RPLight::set_casts_shadows.
const LVecBase3 color |
Returns the lights color.
This returns the light color, previously set with RPLight::set_color. This does not include the energy of the light. It might differ from what was set with set_color, because the color is normalized by dividing it by its luminance.
float energy |
Returns the energy of the light.
This returns the energy of the light, previously set with RPLight::set_energy.
int ies_profile |
Returns the lights ies profile.
This returns the ies profile of a light, previously set with RPLight::set_ies_profile. In case no ies profile was set, returns -1.
RPLight::LightType light_type |
Returns the type of the light.
This returns the internal type of the light, which was specified in the lights constructor. This can be used to distinguish between light types.
float near_plane |
Returns the near plane of the light.
This returns the lights near plane, previously set with RPLight::set_near_plane. If the light does not cast shadows, this value is meaningless.
const LVecBase3 pos |
Returns the position of the light.
This returns the position of the light previously set with RPLight::set_pos(). The returned position is in world space.
int shadow_map_resolution |
Returns the shadow map resolution.
This returns the shadow map resolution of each source of the light. If the light is not setup to cast shadows, this value is meaningless. The returned value is the one previously set with RPLight::set_shadow_map_resolution.