From Pavel Moloshtan, add support to osg::Texture files for GL_ARB_shadow_ambinet support
This commit is contained in:
parent
7a94ab3903
commit
475c583975
@ -11,7 +11,7 @@ Robert Osfield <robert@openscenegraph.com>
|
|||||||
- 2nd iteration of shadow occlusion culling.
|
- 2nd iteration of shadow occlusion culling.
|
||||||
- documentation?!
|
- documentation?!
|
||||||
- visual studio workspace files/unix makefiles.
|
- visual studio workspace files/unix makefiles.
|
||||||
- project adim & lead.
|
- project admin & lead.
|
||||||
|
|
||||||
Don Burns <don@andesengineering.com>
|
Don Burns <don@andesengineering.com>
|
||||||
- Open Producer
|
- Open Producer
|
||||||
@ -124,7 +124,11 @@ Ruben Lopez <ryu@gpul.org>
|
|||||||
- Inventor ascii/VRML 1.0 loader.
|
- Inventor ascii/VRML 1.0 loader.
|
||||||
|
|
||||||
Pavel Moloshtan <pasha@moloshtan.com>
|
Pavel Moloshtan <pasha@moloshtan.com>
|
||||||
- Support for LWO2 format in the LightWave loader.
|
- First version of LightWave LWO2 format in lwo plugin.
|
||||||
|
- Support of GL_ARB_occlusion_query in osg::Drawable.
|
||||||
|
- Support of GL_ARB_shadow in osg::Texture, osgdepthtexture example.
|
||||||
|
- Support of GL_ARB_shadow_ambient in osg::Texture.
|
||||||
|
- Improvement to the ive plugin.
|
||||||
|
|
||||||
Daniel Sjölie <deepone@acc.umu.se>
|
Daniel Sjölie <deepone@acc.umu.se>
|
||||||
- Support for multitextured flt files.
|
- Support for multitextured flt files.
|
||||||
|
@ -82,6 +82,9 @@
|
|||||||
#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
|
#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TEXTURE_COMPARE_FAIL_VALUE_ARB
|
||||||
|
#define TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
@ -91,7 +94,6 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
|||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
|
|
||||||
Texture();
|
Texture();
|
||||||
|
|
||||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||||
@ -266,7 +268,10 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
|||||||
void setShadowTextureMode(ShadowTextureMode mode) { _shadow_texture_mode = mode; }
|
void setShadowTextureMode(ShadowTextureMode mode) { _shadow_texture_mode = mode; }
|
||||||
ShadowTextureMode getShadowTextureMode() { return _shadow_texture_mode; }
|
ShadowTextureMode getShadowTextureMode() { return _shadow_texture_mode; }
|
||||||
|
|
||||||
|
// set value of TEXTURE_COMPARE_FAIL_VALUE_ARB texture parameter
|
||||||
|
// http://oss.sgi.com/projects/ogl-sample/registry/ARB/shadow_ambient.txt
|
||||||
|
void setShadowAmbient(float shadow_ambient) { _shadow_ambient = shadow_ambient; }
|
||||||
|
float getShadowAmbient() { return _shadow_ambient; }
|
||||||
|
|
||||||
/** Texture is pure virtual base class, apply must be overriden. */
|
/** Texture is pure virtual base class, apply must be overriden. */
|
||||||
virtual void apply(State& state) const = 0;
|
virtual void apply(State& state) const = 0;
|
||||||
@ -315,6 +320,9 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
|||||||
void setShadowSupported(bool flag) { _isShadowSupported = flag; }
|
void setShadowSupported(bool flag) { _isShadowSupported = flag; }
|
||||||
bool isShadowSupported() const { return _isShadowSupported; }
|
bool isShadowSupported() const { return _isShadowSupported; }
|
||||||
|
|
||||||
|
void setShadowAmbientSupported(bool flag) { _isShadowAmbientSupported = flag; }
|
||||||
|
bool isShadowAmbientSupported() const { return _isShadowAmbientSupported; }
|
||||||
|
|
||||||
void setMaxTextureSize(GLint maxsize) { _maxTextureSize=maxsize; }
|
void setMaxTextureSize(GLint maxsize) { _maxTextureSize=maxsize; }
|
||||||
GLint maxTextureSize() const { return _maxTextureSize; }
|
GLint maxTextureSize() const { return _maxTextureSize; }
|
||||||
|
|
||||||
@ -342,6 +350,7 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
|||||||
bool _isTextureBorderClampSupported;
|
bool _isTextureBorderClampSupported;
|
||||||
bool _isGenerateMipMapSupported;
|
bool _isGenerateMipMapSupported;
|
||||||
bool _isShadowSupported;
|
bool _isShadowSupported;
|
||||||
|
bool _isShadowAmbientSupported;
|
||||||
|
|
||||||
GLint _maxTextureSize;
|
GLint _maxTextureSize;
|
||||||
|
|
||||||
@ -415,6 +424,7 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
|||||||
bool _use_shadow_comparison;
|
bool _use_shadow_comparison;
|
||||||
ShadowCompareFunc _shadow_compare_func;
|
ShadowCompareFunc _shadow_compare_func;
|
||||||
ShadowTextureMode _shadow_texture_mode;
|
ShadowTextureMode _shadow_texture_mode;
|
||||||
|
float _shadow_ambient;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -178,7 +178,8 @@ Texture::Texture():
|
|||||||
_internalFormat(0),
|
_internalFormat(0),
|
||||||
_use_shadow_comparison(false),
|
_use_shadow_comparison(false),
|
||||||
_shadow_compare_func(LEQUAL),
|
_shadow_compare_func(LEQUAL),
|
||||||
_shadow_texture_mode(LUMINANCE)
|
_shadow_texture_mode(LUMINANCE),
|
||||||
|
_shadow_ambient(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +199,8 @@ Texture::Texture(const Texture& text,const CopyOp& copyop):
|
|||||||
_internalFormat(text._internalFormat),
|
_internalFormat(text._internalFormat),
|
||||||
_use_shadow_comparison(text._use_shadow_comparison),
|
_use_shadow_comparison(text._use_shadow_comparison),
|
||||||
_shadow_compare_func(text._shadow_compare_func),
|
_shadow_compare_func(text._shadow_compare_func),
|
||||||
_shadow_texture_mode(text._shadow_texture_mode)
|
_shadow_texture_mode(text._shadow_texture_mode),
|
||||||
|
_shadow_ambient(text._shadow_ambient)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,6 +226,7 @@ int Texture::compareTexture(const Texture& rhs) const
|
|||||||
COMPARE_StateAttribute_Parameter(_use_shadow_comparison)
|
COMPARE_StateAttribute_Parameter(_use_shadow_comparison)
|
||||||
COMPARE_StateAttribute_Parameter(_shadow_compare_func)
|
COMPARE_StateAttribute_Parameter(_shadow_compare_func)
|
||||||
COMPARE_StateAttribute_Parameter(_shadow_texture_mode)
|
COMPARE_StateAttribute_Parameter(_shadow_texture_mode)
|
||||||
|
COMPARE_StateAttribute_Parameter(_shadow_ambient)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -494,6 +497,13 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
|||||||
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
|
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
|
||||||
glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC_ARB, _shadow_compare_func);
|
glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC_ARB, _shadow_compare_func);
|
||||||
glTexParameteri(target, GL_DEPTH_TEXTURE_MODE_ARB, _shadow_texture_mode);
|
glTexParameteri(target, GL_DEPTH_TEXTURE_MODE_ARB, _shadow_texture_mode);
|
||||||
|
|
||||||
|
// if ambient value is 0 - it is default behaviour of GL_ARB_shadow
|
||||||
|
// no need for GL_ARB_shadow_ambient in this case
|
||||||
|
if (extensions->isShadowAmbientSupported() && _shadow_ambient > 0)
|
||||||
|
{
|
||||||
|
glTexParameterf(target, TEXTURE_COMPARE_FAIL_VALUE_ARB, _shadow_ambient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1038,6 +1048,9 @@ Texture::Extensions::Extensions(const Extensions& rhs):
|
|||||||
_maxTextureSize = rhs._maxTextureSize;
|
_maxTextureSize = rhs._maxTextureSize;
|
||||||
|
|
||||||
_glCompressedTexImage2D = rhs._glCompressedTexImage2D;
|
_glCompressedTexImage2D = rhs._glCompressedTexImage2D;
|
||||||
|
|
||||||
|
_isShadowSupported = rhs._isShadowSupported;
|
||||||
|
_isShadowAmbientSupported = rhs._isShadowAmbientSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
void Texture::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||||
@ -1059,6 +1072,9 @@ void Texture::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
|||||||
if (!rhs._glCompressedTexImage2D) _glCompressedTexImage2D = 0;
|
if (!rhs._glCompressedTexImage2D) _glCompressedTexImage2D = 0;
|
||||||
if (!rhs._glCompressedTexSubImage2D) _glCompressedTexSubImage2D = 0;
|
if (!rhs._glCompressedTexSubImage2D) _glCompressedTexSubImage2D = 0;
|
||||||
if (!rhs._glGetCompressedTexImage) _glGetCompressedTexImage = 0;
|
if (!rhs._glGetCompressedTexImage) _glGetCompressedTexImage = 0;
|
||||||
|
|
||||||
|
if (!rhs._isShadowSupported) _isShadowSupported = 0;
|
||||||
|
if (!rhs._isShadowAmbientSupported) _isShadowAmbientSupported = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::Extensions::setupGLExtenions()
|
void Texture::Extensions::setupGLExtenions()
|
||||||
@ -1076,7 +1092,7 @@ void Texture::Extensions::setupGLExtenions()
|
|||||||
_isGenerateMipMapSupported = (strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0) ||
|
_isGenerateMipMapSupported = (strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0) ||
|
||||||
isGLExtensionSupported("GL_SGIS_generate_mipmap");
|
isGLExtensionSupported("GL_SGIS_generate_mipmap");
|
||||||
_isShadowSupported = isGLExtensionSupported("GL_ARB_shadow");
|
_isShadowSupported = isGLExtensionSupported("GL_ARB_shadow");
|
||||||
|
_isShadowAmbientSupported = isGLExtensionSupported("GL_ARB_shadow_ambient");
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&_maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&_maxTextureSize);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user