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

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

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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_SOFTSHADOWMAP
15#define OSGSHADOW_SOFTSHADOWMAP 1
16
17#include <osg/Camera>
18#include <osg/Material>
19#include <osg/MatrixTransform>
20#include <osg/LightSource>
21
22#include <osgShadow/ShadowMap>
23
24namespace osgShadow {
25
26/** SoftShadowMap provides an implementation of soft shadows with shadow maps.*/
27class OSGSHADOW_EXPORT SoftShadowMap : public ShadowMap
28{
29    public :
30        SoftShadowMap();
31
32        SoftShadowMap(const SoftShadowMap& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
33
34        META_Object(osgShadow, SoftShadowMap);
35
36        /** Set the values for width of the soft penumbra the shader will use.
37         *  Zero is for hard shadow (no penumbra). 0.01 is already very soft penumbra.
38         *  Default is 0.005.*/
39        void setSoftnessWidth(float softnessWidth);
40
41        /** Get the value used for width of the soft penumbra in the shader.*/
42        float getSoftnessWidth() const { return _softnessWidth; }
43
44        /** Set the values for jittering scale the shader will use.
45         *  Zero is no jittering (i.e. see the banding in penumbra)
46         *  High values (>64) cause 'pixelization' of the penumbra.
47         *  Usually but not necessarily power of two number.
48         *  Default is 32. */
49        void setJitteringScale(float jitteringScale);
50
51        /** Get the value used for jittering scale in the shader.*/
52        float getJitteringScale() const { return _jitteringScale; }
53
54        /** Set the texture unit that the jitter texture will be applied on.*/
55        void setJitterTextureUnit(unsigned int jitterTextureUnit);
56
57        /** Get the texture unit that the jitter texture will be applied on.*/
58        unsigned int getJitterTextureUnit() const { return _jitterTextureUnit; }
59
60
61        /** Add a small bias to the z-value, this can reduce
62         *  shadow acne problem.
63         *  This is the same as calling setPolygonOffset(osg::Vec2(bias,0));
64         *  Suitable values are 0-0.005
65         *  Default is 0. */
66        void setBias(float bias) { setPolygonOffset(osg::Vec2(bias,0)); }
67
68        /** Return the bias value */
69        float getBias() const { return getPolygonOffset().x(); }
70
71
72    protected:
73        virtual ~SoftShadowMap(void) {};
74
75        /** Create the managed Uniforms */
76        void createUniforms();
77        void createShaders();
78        void initJittering(osg::StateSet *ss);
79
80        osg::ref_ptr<osg::Uniform>      _softnessWidthUniform;
81        osg::ref_ptr<osg::Uniform>      _jitteringScaleUniform;
82        float                           _softnessWidth;
83        float                           _jitteringScale;
84        unsigned int                    _jitterTextureUnit;
85
86
87
88};
89
90}
91
92#endif
Note: See TracBrowser for help on using the browser.