/src/ogre/OgreMain/include/OgreShadowCameraSetup.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | #ifndef __ShadowCameraSetup_H__ |
29 | | #define __ShadowCameraSetup_H__ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | #include "OgreHeaderPrefix.h" |
33 | | |
34 | | namespace Ogre { |
35 | | |
36 | | /** \addtogroup Core |
37 | | * @{ |
38 | | */ |
39 | | /** \addtogroup Scene |
40 | | * @{ |
41 | | */ |
42 | | /** This class allows you to plug in new ways to define the camera setup when |
43 | | rendering and projecting shadow textures. |
44 | | |
45 | | The default projection used when rendering shadow textures is a uniform |
46 | | frustum. This is pretty straight forward but doesn't make the best use of |
47 | | the space in the shadow map since texels closer to the camera will be larger, |
48 | | resulting in 'jaggies'. There are several ways to distribute the texels |
49 | | in the shadow texture differently, and this class allows you to override |
50 | | that. |
51 | | @par |
52 | | Ogre is provided with several alternative shadow camera setups, including |
53 | | LiSPSM (LiSPSMShadowCameraSetup) and Plane Optimal (PlaneOptimalShadowCameraSetup). |
54 | | Others can of course be written to incorporate other algorithms. All you |
55 | | have to do is instantiate one of these classes and enable it using |
56 | | SceneManager::setShadowCameraSetup (global) or Light::setCustomShadowCameraSetup |
57 | | (per light). In both cases the instance is wrapped in a SharedPtr which means |
58 | | it will be deleted automatically when no more references to it exist. |
59 | | @note |
60 | | Shadow map matrices, being projective matrices, have 15 degrees of freedom. |
61 | | 3 of these degrees of freedom are fixed by the light's position. 4 are used to |
62 | | affinely affect z values. 6 affinely affect u,v sampling. 2 are projective |
63 | | degrees of freedom. This class is meant to allow custom methods for |
64 | | handling optimization. |
65 | | */ |
66 | | class _OgreExport ShadowCameraSetup : public ShadowDataAlloc |
67 | | { |
68 | | public: |
69 | | /// Function to implement -- must set the shadow camera properties |
70 | | virtual void getShadowCamera (const SceneManager *sm, const Camera *cam, |
71 | | const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const = 0; |
72 | | /// Need virtual destructor in case subclasses use it |
73 | 0 | virtual ~ShadowCameraSetup() {} |
74 | | |
75 | | }; |
76 | | |
77 | | |
78 | | |
79 | | /** Implements default shadow camera setup |
80 | | |
81 | | This implements the default shadow camera setup algorithm. This is what might |
82 | | be referred to as "normal" shadow mapping. |
83 | | */ |
84 | | class _OgreExport DefaultShadowCameraSetup : public ShadowCameraSetup |
85 | | { |
86 | | public: |
87 | | DefaultShadowCameraSetup(); |
88 | | virtual ~DefaultShadowCameraSetup(); |
89 | | |
90 | | static ShadowCameraSetupPtr create() |
91 | 0 | { |
92 | 0 | return std::make_shared<DefaultShadowCameraSetup>(); |
93 | 0 | } |
94 | | |
95 | | /// Default shadow camera setup |
96 | | void getShadowCamera (const SceneManager *sm, const Camera *cam, |
97 | | const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const override; |
98 | | }; |
99 | | |
100 | | /** @} */ |
101 | | /** @} */ |
102 | | |
103 | | } |
104 | | |
105 | | #include "OgreHeaderSuffix.h" |
106 | | |
107 | | #endif |