RenderPipeline. More...
#include "rpLight.h"
Public Types | |
enum | LightType { LT_empty = 0, LT_point_light = 1, LT_spot_light = 2 } |
Different types of light. More... | |
Public Member Functions | |
RPLight (LightType light_type) | |
RenderPipeline. More... | |
virtual | ~RPLight () |
Light destructor. More... | |
void | assign_slot (int slot) |
Assigns a slot to the light. More... | |
void | clear_ies_profile () |
void | clear_shadow_sources () |
Clears all shadow source. More... | |
bool | get_casts_shadows () const |
const LVecBase3 & | get_color () const |
float | get_energy () const |
int | get_ies_profile () const |
LightType | get_light_type () const |
float | get_near_plane () const |
bool | get_needs_update () const |
Returns whether the light needs an update. More... | |
size_t | get_num_shadow_sources () const |
RenderPipeline. More... | |
const LVecBase3 & | get_pos () const |
size_t | get_shadow_map_resolution () const |
ShadowSource * | get_shadow_source (size_t index) const |
Returns the n-th shadow source. More... | |
int | get_slot () const |
Returns the slot of the light. More... | |
bool | has_ies_profile () const |
bool | has_slot () const |
Returns whether the light has a slot. More... | |
virtual void | init_shadow_sources ()=0 |
void | invalidate_shadows () |
Invalidates the shadows. More... | |
void | remove_slot () |
Removes the light slot. More... | |
void | set_casts_shadows (bool flag=true) |
void | set_color (const LVecBase3 &color) |
void | set_color (float r, float g, float b) |
void | set_color_from_temperature (float temperature) |
Sets the lights color from a given color temperature. More... | |
void | set_energy (float energy) |
void | set_ies_profile (int profile) |
void | set_near_plane (float near_plane) |
void | set_needs_update (bool flag) |
Sets whether the light needs an update. More... | |
void | set_pos (const LVecBase3 &pos) |
void | set_pos (float x, float y, float z) |
void | set_shadow_map_resolution (size_t resolution) |
virtual void | update_shadow_sources ()=0 |
virtual void | write_to_command (GPUCommand &cmd) |
Writes the light to a GPUCommand. More... | |
Public Member Functions inherited from ReferenceCount | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Public Attributes | |
clear_ies_profile | |
Clears the ies profile. More... | |
get_casts_shadows | |
Returns whether the light casts shadows. More... | |
get_color | |
Returns the lights color. More... | |
get_energy | |
Returns the energy of the light. More... | |
get_ies_profile | |
Returns the lights ies profile. More... | |
get_light_type | |
Returns the type of the light. More... | |
get_near_plane | |
Returns the near plane of the light. More... | |
get_pos | |
Returns the position of the light. More... | |
get_shadow_map_resolution | |
Returns the shadow map resolution. More... | |
has_ies_profile | |
Returns whether the light has an ies profile assigned. More... | |
set_casts_shadows | |
Controls whether the light casts shadows. More... | |
set_color | |
Sets the lights color. More... | |
set_energy | |
Sets the energy of the light. More... | |
set_ies_profile | |
Sets the ies profile. More... | |
set_near_plane | |
Sets the near plane of the light. More... | |
set_pos | |
Sets the position of the light. More... | |
set_shadow_map_resolution | |
Sets the lights shadow map resolution. More... | |
Public Attributes inherited from ReferenceCount | |
get_ref_count | |
Returns the current reference count. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from ReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
RenderPipeline.
Copyright (c) 2014-2016 tobspr tobia s.sp ringe r1@g mail. com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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 RPLight::LightType |
RPLight::RPLight | ( | LightType | light_type | ) |
RenderPipeline.
Copyright (c) 2014-2016 tobspr tobia s.sp ringe r1@g mail. com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Constructs a new light with the given type
This constructs a new base light with the given light type. Sub-Classes should call this to initialize all properties.
light_type | Type of the light |
Definition at line 38 of file rpLight.cxx.
|
virtual |
Light destructor.
This destructs the light, cleaning up all resourced used. The light should be detached at this point, because while the Light is attached, the InternalLightManager holds a reference to prevent it from being destructed.
Definition at line 90 of file rpLight.cxx.
|
inline |
Assigns a slot to the light.
This assigns a slot to the light, marking it as attached. The slot relates to the index in the GPU's storage of lights. This is an internal method called by the InternalLightManager when the light got attached.
slot | Slot of the light |
|
inline |
|
inline |
Returns whether the light needs an update.
This returns whether the light needs an update. This might be the case when a property of the light was changed, e.g. position or color. It does not affect the shadows, you have to query the update flag of each individual source for that. The return value is the value previously set with RPLight::set_needs_update.
|
inline |
RenderPipeline.
Copyright (c) 2014-2016 tobspr tobia s.sp ringe r1@g mail. com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Returns the amount of shadow sources
This returns the amount of shadow sources attached to this light. In case the light has no shadows enabled, or the light was not attached yet, this returns 0.
|
inline |
Returns the n-th shadow source.
This returns the n-th attached shadow source. This ranges from 0 .. RPLight::get_num_shadow_sources(). If an invalid index is passed, an assertion is thrown.
index | Index of the source |
|
inline |
|
inline |
Returns whether the light has a slot.
This returns wheter the light currently is attached, and thus has a slot in the InternalLightManagers light list. When the light is attached, this returns true, otherwise it will return false.
|
inline |
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).
|
inline |
Removes the light slot.
This is an internal method to remove the slot of the light. It gets called by the InternalLightManager when a light gets detached. It internally sets the slot to -1 to indicate the light is no longer attached.
void RPLight::set_color_from_temperature | ( | 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 |
Definition at line 103 of file rpLight.cxx.
References set_color.
|
inline |
Sets whether the light needs an update.
This controls whether the light needs to get an update. This is the case when a property of the light changed, e.g. position or color. It does not affect the shadows (For that use RPLight::invalidate_shadows()). When this flag is set to true, the light will get resubmitted to the GPU in the next update cycle.
You should usually never set the flag to false manually. The InternalLightManager will do this when the data got sucessfully updated.
flag | Update-Flag |
|
virtual |
Writes the light to a GPUCommand.
This writes all of the lights data to the given GPUCommand handle. Subclasses should first call this method, and then append their own data. This makes sure that for unpacking a light, no information about the type of the light is required.
cmd | The GPUCommand to write to |
Reimplemented in RPSpotLight, and RPPointLight.
Definition at line 60 of file rpLight.cxx.
References GPUCommand::push_int().
Referenced by RPPointLight::write_to_command(), and RPSpotLight::write_to_command().
|
inline |
|
inline |
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.
|
inline |
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.
|
inline |
Returns the energy of the light.
This returns the energy of the light, previously set with RPLight::set_energy.
|
inline |
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.
|
inline |
|
inline |
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.
|
inline |
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.
|
inline |
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.
Definition at line 100 of file rpLight.h.
Referenced by RPSpotLight::update_shadow_sources().
|
inline |
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.
|
inline |
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 |
|
inline |
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 |
r | Red-component of the color |
g | Green-component of the color |
b | Blue-component of the color |
Definition at line 83 of file rpLight.h.
Referenced by set_color_from_temperature().
|
inline |
|
inline |
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 |
|
inline |
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 |
|
inline |
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 |
x | X-component of the position |
y | Y-component of the position |
z | Z-component of the position |
|
inline |
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 |