/src/ogre/OgreMain/include/OgreShadowCameraSetupPlaneOptimal.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 __ShadowCameraSetupPlaneOptimal_H__ |
29 | | #define __ShadowCameraSetupPlaneOptimal_H__ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | #include "OgreShadowCameraSetup.h" |
33 | | #include "OgreHeaderPrefix.h" |
34 | | |
35 | | namespace Ogre { |
36 | | |
37 | | |
38 | | /** \addtogroup Core |
39 | | * @{ |
40 | | */ |
41 | | /** \addtogroup Scene |
42 | | * @{ |
43 | | */ |
44 | | /** Implements the plane optimal shadow camera algorithm. |
45 | | |
46 | | Given a plane of interest, it is possible to set up the shadow camera |
47 | | matrix such that the mapping between screen and shadow map is the identity |
48 | | (when restricted to pixels that view the plane of interest). Therefore, |
49 | | if the shadow map resolution matches the screen space resolution (of the |
50 | | seen planar receiver), we can get pixel perfect shadowing on the plane. |
51 | | Off the plane, the shadowing is not guaranteed to be perfect and will |
52 | | likely exhibit the usual sampling artifacts associated with shadow mapping. |
53 | | @attention this routine requires double-precision calculations. When you |
54 | | are running under Direct3D, you must ensure that you set the floating |
55 | | point mode to 'Consistent' rather than 'Fastest' to ensure this precision. |
56 | | This does allegedly come with some performance cost but when measuring |
57 | | it appears to be negligible in modern systems for normal usage. |
58 | | @note this projection also only works for lights with |
59 | | a finite position. Therefore you cannot use it for directional lights |
60 | | at this time. |
61 | | */ |
62 | | class _OgreExport PlaneOptimalShadowCameraSetup : public ShadowCameraSetup |
63 | | { |
64 | | private: |
65 | | const MovablePlane* mPlane; ///< pointer to plane of interest |
66 | | private: |
67 | | /// helper function computing projection matrix given constraints |
68 | | Matrix4 computeConstrainedProjection( const Vector4& pinhole, |
69 | | const std::vector<Vector4>& fpoint, |
70 | | const std::vector<Vector2>& constraint) const; |
71 | | |
72 | | public: |
73 | | /// @deprecated use create() |
74 | | PlaneOptimalShadowCameraSetup(const MovablePlane *plane); |
75 | | |
76 | | virtual ~PlaneOptimalShadowCameraSetup(); |
77 | | |
78 | | /// Constructor -- requires a plane of interest |
79 | | static ShadowCameraSetupPtr create(const MovablePlane *plane) |
80 | 0 | { |
81 | 0 | return std::make_shared<PlaneOptimalShadowCameraSetup>(plane); |
82 | 0 | } |
83 | | |
84 | | /// Returns shadow camera configured to get 1-1 homography between screen and shadow map when restricted to plane |
85 | | void getShadowCamera (const SceneManager *sm, const Camera *cam, |
86 | | const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const override; |
87 | | }; |
88 | | /** @} */ |
89 | | /** @} */ |
90 | | |
91 | | } |
92 | | |
93 | | #include "OgreHeaderSuffix.h" |
94 | | |
95 | | #endif |