Changeset 13041 for OpenSceneGraph/trunk/include/osgFX/BumpMapping
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgFX/BumpMapping (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgFX/BumpMapping
r5328 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 26 26 27 27 /** 28 This effect makes surfaces appear bumpy. Children nodes must use two textures, 29 one for diffuse color and one for the normal map (which can be created 30 from a height map with tools like nVIDIA's normal map generator). Furthermore, 31 tangent-space basis vectors must be created and assigned to each Geometry; this 32 can be done quickly by calling BumpMapping::prepareChildren(). Note that both 33 diffuse and normal map textures must have corresponding UV maps defined in 28 This effect makes surfaces appear bumpy. Children nodes must use two textures, 29 one for diffuse color and one for the normal map (which can be created 30 from a height map with tools like nVIDIA's normal map generator). Furthermore, 31 tangent-space basis vectors must be created and assigned to each Geometry; this 32 can be done quickly by calling BumpMapping::prepareChildren(). Note that both 33 diffuse and normal map textures must have corresponding UV maps defined in 34 34 Geometry objects. 35 This effect defines a preferred technique which uses ARB vertex & fragment 36 programs, and a fallback technique which doesn't use fragment programs. The 37 latter is more limited though since it can't handle ambient and specular 35 This effect defines a preferred technique which uses ARB vertex & fragment 36 programs, and a fallback technique which doesn't use fragment programs. The 37 latter is more limited though since it can't handle ambient and specular 38 38 components. 39 39 */ … … 43 43 BumpMapping(const BumpMapping& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); 44 44 45 META_Effect(osgFX, BumpMapping, 46 47 "Bump Mapping", 48 45 META_Effect(osgFX, BumpMapping, 46 47 "Bump Mapping", 48 49 49 "This effect makes surfaces appear bumpy. Children nodes must use two textures, " 50 50 "one for diffuse color and one for the normal map (which can be created " … … 58 58 "latter is more limited though since it can't handle ambient and specular " 59 59 "components.", 60 60 61 61 "Marco Jez"); 62 63 62 63 64 64 /** get the OpenGL light number */ 65 65 inline int getLightNumber() const; 66 66 67 67 /** set the OpenGL light number that will be used in lighting computations */ 68 68 inline void setLightNumber(int n); 69 69 70 70 /** get the texture unit that contains diffuse color texture. Default is 1 */ 71 71 inline int getDiffuseTextureUnit() const; 72 72 73 73 /** set the texture unit that contains diffuse color texture. Default is 1 */ 74 74 inline void setDiffuseTextureUnit(int n); … … 76 76 /** get the texture unit that contains normal map texture. Default is 0 */ 77 77 inline int getNormalMapTextureUnit() const; 78 78 79 79 /** set the texture unit that contains normal map texture. Default is 0 */ 80 80 inline void setNormalMapTextureUnit(int n); 81 81 82 82 /** get the diffuse color texture that overrides children's texture */ 83 83 inline osg::Texture2D* getOverrideDiffuseTexture(); 84 84 85 85 /** get the const diffuse color texture that overrides children's texture */ 86 86 inline const osg::Texture2D* getOverrideDiffuseTexture() const; 87 87 88 88 /** set the diffuse color texture that overrides children's texture */ 89 89 inline void setOverrideDiffuseTexture(osg::Texture2D* texture); 90 90 91 91 /** get the normal map texture that overrides children's texture */ 92 92 inline osg::Texture2D* getOverrideNormalMapTexture(); 93 93 94 94 /** get the const normal map texture that overrides children's texture */ 95 95 inline const osg::Texture2D* getOverrideNormalMapTexture() const; … … 97 97 /** set the normal map texture that overrides children's texture */ 98 98 inline void setOverrideNormalMapTexture(osg::Texture2D* texture); 99 99 100 100 /** 101 101 prepare a Geometry for bump lighting. Tangent-space basis vectors are … … 103 103 */ 104 104 void prepareGeometry(osg::Geometry* geo); 105 105 106 106 /** prepare a Node for bump lighting, calling prepareGeometry() for each Geometry */ 107 107 void prepareNode(osg::Node* node); 108 108 109 109 /** prepare children for bump lighting. Actually calls prepareNode() for each child */ 110 110 void prepareChildren(); 111 111 112 112 /** set up a demo environment with predefined diffuse and normal maps, as well as texture coordinates */ 113 113 void setUpDemo(); … … 127 127 }; 128 128 129 // INLINE METHODS 130 129 // INLINE METHODS 130 131 131 inline int BumpMapping::getLightNumber() const 132 132 { 133 133 return _lightnum; 134 134 } 135 135 136 136 inline void BumpMapping::setLightNumber(int n) 137 137 { … … 139 139 dirtyTechniques(); 140 140 } 141 141 142 142 inline int BumpMapping::getDiffuseTextureUnit() const 143 143 { 144 144 return _diffuse_unit; 145 145 } 146 146 147 147 inline void BumpMapping::setDiffuseTextureUnit(int n) 148 148 { … … 150 150 dirtyTechniques(); 151 151 } 152 152 153 153 inline int BumpMapping::getNormalMapTextureUnit() const 154 154 { 155 155 return _normal_unit; 156 156 } 157 157 158 158 inline void BumpMapping::setNormalMapTextureUnit(int n) 159 159 { … … 161 161 dirtyTechniques(); 162 162 } 163 163 164 164 inline osg::Texture2D* BumpMapping::getOverrideDiffuseTexture() 165 165 { … … 171 171 return _diffuse_tex.get(); 172 172 } 173 173 174 174 inline void BumpMapping::setOverrideDiffuseTexture(osg::Texture2D* texture) 175 175 { … … 187 187 return _normal_tex.get(); 188 188 } 189 189 190 190 inline void BumpMapping::setOverrideNormalMapTexture(osg::Texture2D* texture) 191 191 {
