openscenegraph
BumpMapping
Go to the documentation of this file.
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//osgFX - Copyright (C) 2003 Marco Jez
14
15#ifndef OSGFX_BUMPMAPPING_
16#define OSGFX_BUMPMAPPING_
17
18#include <osgFX/Export>
19#include <osgFX/Effect>
20
21#include <osg/ref_ptr>
22#include <osg/Texture2D>
23
24namespace osgFX
25{
26
41 public:
44
46
47 "Bump Mapping",
48
49 "This effect makes surfaces appear bumpy. Children nodes must use two textures, "
50 "one for diffuse color and one for the normal map (which can be created "
51 "from a height map with tools like nVIDIA's normal map generator). Furthermore, "
52 "tangent-space basis vectors must be created and assigned to each Geometry; this "
53 "can be done quickly by calling BumpMapping::prepareChildren(). Note that both "
54 "diffuse and normal map textures must have corresponding UV maps defined in "
55 "Geometry objects.\n"
56 "This effect defines a preferred technique which uses ARB vertex & fragment "
57 "programs, and a fallback technique which doesn't use fragment programs. The "
58 "latter is more limited though since it can't handle ambient and specular "
59 "components.",
60
61 "Marco Jez");
62
63
65 inline int getLightNumber() const;
66
68 inline void setLightNumber(int n);
69
71 inline int getDiffuseTextureUnit() const;
72
74 inline void setDiffuseTextureUnit(int n);
75
77 inline int getNormalMapTextureUnit() const;
78
80 inline void setNormalMapTextureUnit(int n);
81
83 inline osg::Texture2D* getOverrideDiffuseTexture();
84
86 inline const osg::Texture2D* getOverrideDiffuseTexture() const;
87
89 inline void setOverrideDiffuseTexture(osg::Texture2D* texture);
90
92 inline osg::Texture2D* getOverrideNormalMapTexture();
93
95 inline const osg::Texture2D* getOverrideNormalMapTexture() const;
96
98 inline void setOverrideNormalMapTexture(osg::Texture2D* texture);
99
105
108
111
113 void setUpDemo();
114
115 protected:
116 virtual ~BumpMapping() {}
117 BumpMapping &operator=(const BumpMapping &) { return *this; }
118
120
121 private:
122 int _lightnum;
123 int _diffuse_unit;
124 int _normal_unit;
125 osg::ref_ptr<osg::Texture2D> _diffuse_tex;
127 };
128
129 // INLINE METHODS
130
132 {
133 return _lightnum;
134 }
135
137 {
138 _lightnum = n;
140 }
141
143 {
144 return _diffuse_unit;
145 }
146
148 {
149 _diffuse_unit = n;
151 }
152
154 {
155 return _normal_unit;
156 }
157
159 {
160 _normal_unit = n;
162 }
163
165 {
166 return _diffuse_tex.get();
167 }
168
170 {
171 return _diffuse_tex.get();
172 }
173
175 {
176 _diffuse_tex = texture;
178 }
179
181 {
182 return _normal_tex.get();
183 }
184
186 {
187 return _normal_tex.get();
188 }
189
191 {
192 _normal_tex = texture;
194 }
195
196}
197
198#endif
Definition BumpMapping:40
void setDiffuseTextureUnit(int n)
Definition BumpMapping:147
BumpMapping(const BumpMapping &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
void setLightNumber(int n)
Definition BumpMapping:136
int getDiffuseTextureUnit() const
Definition BumpMapping:142
BumpMapping & operator=(const BumpMapping &)
Definition BumpMapping:117
META_Effect(osgFX, BumpMapping, "Bump Mapping", "This effect makes surfaces appear bumpy. Children nodes must use two textures, " "one for diffuse color and one for the normal map (which can be created " "from a height map with tools like nVIDIA's normal map generator). Furthermore, " "tangent-space basis vectors must be created and assigned to each Geometry; this " "can be done quickly by calling BumpMapping::prepareChildren(). Note that both " "diffuse and normal map textures must have corresponding UV maps defined in " "Geometry objects.\n" "This effect defines a preferred technique which uses ARB vertex & fragment " "programs, and a fallback technique which doesn't use fragment programs. The " "latter is more limited though since it can't handle ambient and specular " "components.", "Marco Jez")
osg::Texture2D * getOverrideNormalMapTexture()
Definition BumpMapping:180
void setOverrideNormalMapTexture(osg::Texture2D *texture)
Definition BumpMapping:190
osg::Texture2D * getOverrideDiffuseTexture()
Definition BumpMapping:164
void setOverrideDiffuseTexture(osg::Texture2D *texture)
Definition BumpMapping:174
int getLightNumber() const
Definition BumpMapping:131
virtual ~BumpMapping()
Definition BumpMapping:116
void setNormalMapTextureUnit(int n)
Definition BumpMapping:158
void prepareNode(osg::Node *node)
void prepareGeometry(osg::Geometry *geo)
int getNormalMapTextureUnit() const
Definition BumpMapping:153
Definition Effect:66
void dirtyTechniques()
Definition Effect:207
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition Geometry:31
Definition Node:72
Definition Texture2D:25
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Definition AnisotropicLighting:25
#define OSGFX_EXPORT
Definition osgFX/Export:27