RenderPipeline. More...
#include "shadowSource.h"
Public Member Functions | |
ShadowSource () | |
RenderPipeline. More... | |
void | clear_region () |
Clears the assigned region of the source. More... | |
const BoundingSphere & | get_bounds () const |
Returns the shadow sources bounds. More... | |
const LMatrix4 & | get_mvp () const |
Returns the View-Projection matrix of the source. More... | |
bool | get_needs_update () const |
RenderPipeline. More... | |
const LVecBase4i & | get_region () const |
Returns the assigned region of the source in atlas space. More... | |
size_t | get_resolution () const |
Returns the resolution of the source. More... | |
int | get_slot () const |
Returns the slot of the shadow source. More... | |
const LVecBase4 & | get_uv_region () const |
Returns the assigned region of the source in UV space. More... | |
bool | has_region () const |
Returns whether the source has a valid region. More... | |
bool | has_slot () const |
Returns whether the source has a slot. More... | |
void | set_matrix_lens (const LMatrix4 &mvp) |
Sets a custom matrix for the source. More... | |
void | set_needs_update (bool flag) |
Sets the update flag of the source. More... | |
void | set_perspective_lens (PN_stdfloat fov, PN_stdfloat near_plane, PN_stdfloat far_plane, LVecBase3 pos, LVecBase3 direction) |
Setups a perspective lens for the source. More... | |
void | set_region (const LVecBase4i ®ion, const LVecBase4 ®ion_uv) |
Sets the assigned region of the source in atlas and uv space. More... | |
void | set_resolution (size_t resolution) |
Sets the resolution of the source. More... | |
void | set_slot (int slot) |
Assigns the source a slot. More... | |
void | write_to_command (GPUCommand &cmd) const |
Writes the source to a GPUCommand. More... | |
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. This class represents a single shadow source.
The ShadowSource can be seen as a Camera. It is used by the Lights to render their shadows. Each ShadowSource has a position in the atlas, and a view-projection matrix. The shadow manager regenerates the shadow maps using the data from the shadow sources.
Definition at line 51 of file shadowSource.h.
ShadowSource::ShadowSource | ( | ) |
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 shadow source
This constructs a new shadow source, with no projection setup, and no slot assigned.
Definition at line 34 of file shadowSource.cxx.
|
inline |
Clears the assigned region of the source.
This unassigns any shadow atlas region from the source, previously set with set_region
Definition at line 259 of file shadowSource.I.
|
inline |
Returns the shadow sources bounds.
This returns the bounds of the shadow source, approximated as a sphere
Definition at line 250 of file shadowSource.I.
|
inline |
Returns the View-Projection matrix of the source.
This returns the current view-projection matrix of the ShadowSource. If no matrix was set yet, returns a matrix with all components zero. If a matrix was set with ShadowSource::set_matrix_lens, returns the matrix set by that function call.
If a matrix was set with ShadowSource::set_perspective_lens, returns a perspective view-projection matrix setup by those parameters.
The matrix returned is the matrix used for rendering the shadow map, and includes the camera transform as well as the projection matrix.
Definition at line 214 of file shadowSource.I.
|
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 whether the shadow source needs an update.
This returns the update flag, which was previously set with ShadowSource::set_needs_update. If the value is true, it means that the ShadowSource is invalid and should be regenerated. This can either be the case because the scene changed and affected the shadow source, or the light moved.
Definition at line 38 of file shadowSource.I.
References has_region().
|
inline |
Returns the assigned region of the source in atlas space.
This returns the region of the source, in atlas space. This is the region set by ShadowSource::set_region. If no region was set yet, returns a 4-component integer vector with all components set to -1. To check this, you should call ShadowSource::has_region() first.
Definition at line 165 of file shadowSource.I.
|
inline |
Returns the resolution of the source.
Returns the shadow map resolution of source, in pixels. This is the space the source takes in the shadow atlas, in pixels.
Definition at line 152 of file shadowSource.I.
|
inline |
Returns the slot of the shadow source.
This returns the assigned slot of the ShadowSource, or -1 if no slot was assigned yet. You can check if a slot exists with ShadowSource::has_slot. The slot is the index of the ShadowSource in the global source buffer.
Definition at line 49 of file shadowSource.I.
|
inline |
Returns the assigned region of the source in UV space.
This returns the region of the source, in UV space. This is the region set by ShadowSource::set_region. If no region was set yet, returns a 4-component integer vector with all components set to -1. To check this, you should call ShadowSource::has_region() first.
Definition at line 178 of file shadowSource.I.
|
inline |
Returns whether the source has a valid region.
This returns whether the ShadowSource has a valid shadow atlas region assigned. This might be not the case when the source never was rendered yet, or is about to get updated.
Definition at line 142 of file shadowSource.I.
Referenced by get_needs_update().
|
inline |
Returns whether the source has a slot.
This returns whether the ShadowSource currently has an assigned slot. If the source has a slot assigned, this returns true, otherwise false. Cases where the source has no slot might be when the source just got attached, but never got rendered yet.
Definition at line 61 of file shadowSource.I.
|
inline |
Sets a custom matrix for the source.
This tells the source to use a custom matrix for rendering, just like the matrix lens. The matrix should include all transformations, rotations and scales. No other matrices will be used for rendering this shadow source (not even a coordinate system conversion).
mvp | Custom View-Projection matrix |
Definition at line 117 of file shadowSource.I.
References set_needs_update().
Referenced by set_perspective_lens().
|
inline |
Sets the update flag of the source.
Sets whether the source is still valid, or needs to get regenerated. Usually you only want to flag the shadow source as invalid, by passing true as the flag. However, the ShadowManager will set the flag to false after updating the source.
flag | The update flag |
Definition at line 131 of file shadowSource.I.
Referenced by set_matrix_lens().
|
inline |
Setups a perspective lens for the source.
This makes the shadow source behave like a perspective lens. The parameters are similar to the ones of a PerspectiveLens.
fov | FoV of the lens |
near_plane | The near plane of the lens, to avoid artifacts at low distance |
far_plane | The far plane of the lens |
pos | Position of the lens, in world space |
direction | Direction (Orientation) of the lens |
Definition at line 89 of file shadowSource.I.
References Lens::get_projection_mat(), Lens::set_film_offset, set_matrix_lens(), Lens::set_near_far(), and Lens::set_view_vector().
|
inline |
Sets the assigned region of the source in atlas and uv space.
This sets the assigned region of the ShadowSource. The region in atlas space should be the region returned from the ShadowAtlas::find_and_reserve_region. The uv-region should be the same region, but in the 0 .. 1 range (can be converted with ShadowAtlas::region_to_uv). This is required for the shaders, because they expect coordinates in the 0 .. 1 range for sampling.
region | Atlas-Space region |
region_uv | UV-Space region |
Definition at line 194 of file shadowSource.I.
|
inline |
Sets the resolution of the source.
This sets the resolution of the ShadowSource, in pixels. It should be a multiple of the tile size of the ShadowAtlas, and greater than zero.
resolution | [description] |
Definition at line 239 of file shadowSource.I.
|
inline |
Assigns the source a slot.
This assigns a slot to the ShadowSource. This is called from the ShadowManager, when the source gets attached first time. This should not get called by the user.
slot | Slot of the source, or -1 to indicate no slot. |
Definition at line 73 of file shadowSource.I.
|
inline |
Writes the source to a GPUCommand.
This writes the ShadowSource to a GPUCommand. This stores the mvp and the uv-region in the command.
cmd | GPUCommand to write to. |
Definition at line 225 of file shadowSource.I.