root/OpenSceneGraph/trunk/include/osgShadow/ShadowSettings @ 13041

Revision 13041, 5.5 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-20 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGSHADOW_SHADOWSETTINGS
15#define OSGSHADOW_SHADOWSETTINGS 1
16
17#include <osg/Uniform>
18#include <osgShadow/Export>
19
20namespace osgShadow {
21
22/** ShadowSettings provides the parameters that the ShadowTechnique should use as a guide for setting up shadowing.*/
23class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
24{
25    public:
26        ShadowSettings();
27        ShadowSettings(const ShadowSettings& ss, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
28
29        META_Object(osgShadow, ShadowSettings);
30
31        /** Set the LightNum of the light in the scene to assign a shadow for.
32          * Default value is -1, which signifies that shadow technique should automatically select an active light
33          * to assign a shadow, typically this will be the first active light found. */
34        void setLightNum(int lightNum) { _lightNum = lightNum; }
35        int getLightNum() const { return _lightNum; }
36
37        void setBaseShadowTextureUnit(unsigned int unit) { _baseShadowTextureUnit = unit; }
38        unsigned int getBaseShadowTextureUnit() const { return _baseShadowTextureUnit; }
39
40        /** Set whether to use osg::StateAttribute::OVERRIDE for the shadow map texture.
41         * Enabling override will force the shadow map texture to override any texture set on the shadow maps texture unit.*/
42        void setUseOverrideForShadowMapTexture(bool useOverride) { _useShadowMapTextureOverride = useOverride; }
43
44        /** Get whether to use osg::StateAttribute::OVERRIDE for the shadow map texture. */
45        bool getUseOverrideForShadowMapTexture() const { return _useShadowMapTextureOverride; }
46
47
48        /** Set the size of the shadow map textures.*/
49        void setTextureSize(const osg::Vec2s& textureSize) { _textureSize = textureSize; }
50
51        /** Get the size of the shadow map textures.*/
52        const osg::Vec2s& getTextureSize() const { return _textureSize; }
53
54        void setMinimumShadowMapNearFarRatio(double ratio) { _minimumShadowMapNearFarRatio = ratio; }
55        double getMinimumShadowMapNearFarRatio() const { return _minimumShadowMapNearFarRatio; }
56
57        enum ShadowMapProjectionHint
58        {
59            ORTHOGRAPHIC_SHADOW_MAP,
60            PERSPECTIVE_SHADOW_MAP
61        };
62
63        void setShadowMapProjectionHint(ShadowMapProjectionHint hint) { _shadowMapProjectionHint = hint; }
64        ShadowMapProjectionHint getShadowMapProjectionHint() const { return _shadowMapProjectionHint; }
65
66        /** Set the cut off angle, in degrees, between the light direction and the view direction
67         * that determines whether perspective shadow mapping is appropriate, or thar orthographic shadow
68         * map should be used instead.  Default is 2 degrees so that for any angle greater than 2 degrees
69         * perspective shadow map will be used, and any angle less than 2 degrees orthographic shadow map
70         * will be used.  Note, if ShadowMapProjectionHint is set to ORTHOGRAPHIC_SHADOW_MAP then an
71         * orthographic shadow map will always be used.*/
72        void setPerspectiveShadowMapCutOffAngle(double angle) { _perspectiveShadowMapCutOffAngle = angle; }
73        double getPerspectiveShadowMapCutOffAngle() const { return _perspectiveShadowMapCutOffAngle; }
74
75
76        void setNumShadowMapsPerLight(unsigned int numShadowMaps) { _numShadowMapsPerLight = numShadowMaps; }
77        unsigned int getNumShadowMapsPerLight() const { return _numShadowMapsPerLight; }
78
79        enum MultipleShadowMapHint
80        {
81            PARALLEL_SPLIT,
82            CASCADED
83        };
84
85        void setMultipleShadowMapHint(MultipleShadowMapHint hint) { _multipleShadowMapHint = hint; }
86        MultipleShadowMapHint getMultipleShadowMapHint() const { return _multipleShadowMapHint; }
87
88
89        enum ShaderHint
90        {
91            NO_SHADERS,
92            PROVIDE_FRAGMENT_SHADER,
93            PROVIDE_VERTEX_AND_FRAGMENT_SHADER
94        };
95
96        void setShaderHint(ShaderHint shaderHint) { _shaderHint = shaderHint; }
97        ShaderHint getShaderHint() const { return _shaderHint; }
98
99        void setDebugDraw(bool debugDraw) { _debugDraw = debugDraw; }
100        bool getDebugDraw() const { return _debugDraw; }
101
102    protected:
103
104        virtual ~ShadowSettings();
105
106        int                                     _lightNum;
107        unsigned int                            _baseShadowTextureUnit;
108        bool                                    _useShadowMapTextureOverride;
109        osg::Vec2s                              _textureSize;
110
111        double                                  _minimumShadowMapNearFarRatio;
112        ShadowMapProjectionHint                 _shadowMapProjectionHint;
113        double                                  _perspectiveShadowMapCutOffAngle;
114
115        unsigned int                            _numShadowMapsPerLight;
116        MultipleShadowMapHint                   _multipleShadowMapHint;
117
118        ShaderHint                              _shaderHint;
119        bool                                    _debugDraw;
120
121};
122
123}
124
125#endif
Note: See TracBrowser for help on using the browser.