2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-08-27 06:09:15 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2003-08-27 06:09:15 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2003-08-27 06:09:15 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-08-27 06:09:15 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
//osgFX - Copyright (C) 2003 Marco Jez
|
|
|
|
|
|
|
|
#ifndef OSGFX_SPECULARHIGHLIGHTS_
|
|
|
|
#define OSGFX_SPECULARHIGHLIGHTS_
|
|
|
|
|
|
|
|
#include <osgFX/Export>
|
|
|
|
#include <osgFX/Effect>
|
|
|
|
|
|
|
|
namespace osgFX
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2012-03-22 01:36:20 +08:00
|
|
|
This effect applies additive specular highlights at fragment level (instead
|
|
|
|
of OpenGL's vertex-level lighting) by using a cube map and reflective texgen.
|
|
|
|
A texture matrix is computed to rotate the cube map automatically; this makes
|
|
|
|
the specular effect consistent with respect to view direction and light position.
|
2003-08-27 06:09:15 +08:00
|
|
|
The user can choose which light should be used to compute the texture matrix.
|
2012-03-22 01:36:20 +08:00
|
|
|
This effect requires the GL_ARB_texture_env_add extension and one of the cube map
|
2003-08-27 06:09:15 +08:00
|
|
|
extensions (GL_EXT_texture_cube_map, GL_ARB_texture_cube_map or OpenGL v1.3).
|
|
|
|
*/
|
|
|
|
class OSGFX_EXPORT SpecularHighlights: public Effect {
|
|
|
|
public:
|
|
|
|
SpecularHighlights();
|
2005-04-29 14:32:13 +08:00
|
|
|
SpecularHighlights(const SpecularHighlights& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
2003-08-27 06:09:15 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
META_Effect(osgFX, SpecularHighlights,
|
|
|
|
|
|
|
|
"Specular Highlights",
|
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
"This effect applies additive specular highlights at fragment level (instead "
|
|
|
|
"of OpenGL's vertex-level lighting) by using a cube map and reflective texgen. "
|
|
|
|
"A texture matrix is computed to rotate the cube map automatically; this makes "
|
|
|
|
"the specular effect consistent with respect to view direction and light position. "
|
|
|
|
"The user can choose which light should be used to compute the texture matrix.\n"
|
|
|
|
"This effect requires the GL_ARB_texture_env_add extension and one of the cube map "
|
2012-03-22 01:36:20 +08:00
|
|
|
"extensions (GL_EXT_texture_cube_map, GL_ARB_texture_cube_map or OpenGL v1.3).",
|
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
"Marco Jez");
|
2012-03-22 01:36:20 +08:00
|
|
|
|
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** get the OpenGL light number */
|
|
|
|
inline int getLightNumber() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** set the OpenGL light number that will be used in lighting computations */
|
|
|
|
inline void setLightNumber(int n);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** get the texture unit number */
|
|
|
|
inline int getTextureUnit() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** set the texture unit that will be used to apply the cube map */
|
|
|
|
inline void setTextureUnit(int n);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** get the specular color */
|
2005-04-29 14:32:13 +08:00
|
|
|
inline const osg::Vec4& getSpecularColor() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** set the specular color */
|
2005-04-29 14:32:13 +08:00
|
|
|
inline void setSpecularColor(const osg::Vec4& color);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** get the specular exponent */
|
|
|
|
inline float getSpecularExponent() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
/** set the specular exponent */
|
|
|
|
inline void setSpecularExponent(float e);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~SpecularHighlights() {}
|
2005-04-29 14:32:13 +08:00
|
|
|
SpecularHighlights& operator=(const SpecularHighlights&) { return *this; }
|
2003-08-27 06:09:15 +08:00
|
|
|
|
|
|
|
bool define_techniques();
|
|
|
|
|
|
|
|
private:
|
2005-04-29 14:32:13 +08:00
|
|
|
int _lightnum;
|
|
|
|
int _unit;
|
|
|
|
osg::Vec4 _color;
|
|
|
|
float _sexp;
|
2003-08-27 06:09:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// INLINE METHODS
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
inline int SpecularHighlights::getLightNumber() const
|
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
return _lightnum;
|
2003-08-27 06:09:15 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
inline void SpecularHighlights::setLightNumber(int n)
|
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
_lightnum = n;
|
2003-08-27 06:09:15 +08:00
|
|
|
dirtyTechniques();
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
inline int SpecularHighlights::getTextureUnit() const
|
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
return _unit;
|
2003-08-27 06:09:15 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
inline void SpecularHighlights::setTextureUnit(int n)
|
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
_unit = n;
|
2003-08-27 06:09:15 +08:00
|
|
|
dirtyTechniques();
|
|
|
|
}
|
|
|
|
|
2005-04-29 14:32:13 +08:00
|
|
|
inline const osg::Vec4& SpecularHighlights::getSpecularColor() const
|
2003-08-27 06:09:15 +08:00
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
return _color;
|
2003-08-27 06:09:15 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-04-29 14:32:13 +08:00
|
|
|
inline void SpecularHighlights::setSpecularColor(const osg::Vec4& color)
|
2003-08-27 06:09:15 +08:00
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
_color = color;
|
2003-08-27 06:09:15 +08:00
|
|
|
dirtyTechniques();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float SpecularHighlights::getSpecularExponent() const
|
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
return _sexp;
|
2003-08-27 06:09:15 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-08-27 06:09:15 +08:00
|
|
|
inline void SpecularHighlights::setSpecularExponent(float e)
|
|
|
|
{
|
2005-04-29 14:32:13 +08:00
|
|
|
_sexp = e;
|
2003-08-27 06:09:15 +08:00
|
|
|
dirtyTechniques();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|