separately-controllable ZBias
This commit is contained in:
@@ -76,6 +76,7 @@ void Actor::Reset()
|
|||||||
|
|
||||||
m_bTextureWrapping = false;
|
m_bTextureWrapping = false;
|
||||||
m_BlendMode = BLEND_NORMAL;
|
m_BlendMode = BLEND_NORMAL;
|
||||||
|
m_bZBias = false;
|
||||||
m_bClearZBuffer = false;
|
m_bClearZBuffer = false;
|
||||||
m_ZTestMode = ZTEST_OFF;
|
m_ZTestMode = ZTEST_OFF;
|
||||||
m_bZWrite = false;
|
m_bZWrite = false;
|
||||||
@@ -385,6 +386,11 @@ void Actor::SetGlobalRenderStates()
|
|||||||
DISPLAY->SetBlendMode( m_BlendMode );
|
DISPLAY->SetBlendMode( m_BlendMode );
|
||||||
DISPLAY->SetZWrite( m_bZWrite );
|
DISPLAY->SetZWrite( m_bZWrite );
|
||||||
DISPLAY->SetZTestMode( m_ZTestMode );
|
DISPLAY->SetZTestMode( m_ZTestMode );
|
||||||
|
|
||||||
|
// BLEND_NO_EFFECT is used to draw masks to the Z-buffer, which always wants
|
||||||
|
// Z-bias enabled.
|
||||||
|
DISPLAY->SetZBias( m_bZBias || m_BlendMode == BLEND_NO_EFFECT );
|
||||||
|
|
||||||
if( m_bClearZBuffer )
|
if( m_bClearZBuffer )
|
||||||
DISPLAY->ClearZBuffer();
|
DISPLAY->ClearZBuffer();
|
||||||
DISPLAY->SetCullMode( m_CullMode );
|
DISPLAY->SetCullMode( m_CullMode );
|
||||||
|
|||||||
@@ -342,6 +342,7 @@ public:
|
|||||||
virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; }
|
virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; }
|
||||||
void SetZTestModeString( const CString &s ); // convenience
|
void SetZTestModeString( const CString &s ); // convenience
|
||||||
virtual void SetZWrite( bool b ) { m_bZWrite = b; }
|
virtual void SetZWrite( bool b ) { m_bZWrite = b; }
|
||||||
|
void SetZBias( bool b ) { m_bZBias = b; }
|
||||||
virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; }
|
virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; }
|
||||||
void SetCullModeString( const CString &s ); // convenience
|
void SetCullModeString( const CString &s ); // convenience
|
||||||
|
|
||||||
@@ -463,6 +464,7 @@ protected:
|
|||||||
bool m_bClearZBuffer;
|
bool m_bClearZBuffer;
|
||||||
ZTestMode m_ZTestMode;
|
ZTestMode m_ZTestMode;
|
||||||
bool m_bZWrite;
|
bool m_bZWrite;
|
||||||
|
bool m_bZBias; // if true, always wins z-test against a coplanar actor
|
||||||
CullMode m_CullMode;
|
CullMode m_CullMode;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -576,6 +578,7 @@ public:
|
|||||||
static int ztest( T* p, lua_State *L ) { p->SetZTestMode((!!IArg(1))?ZTEST_WRITE_ON_PASS:ZTEST_OFF); return 0; }
|
static int ztest( T* p, lua_State *L ) { p->SetZTestMode((!!IArg(1))?ZTEST_WRITE_ON_PASS:ZTEST_OFF); return 0; }
|
||||||
static int ztestmode( T* p, lua_State *L ) { p->SetZTestModeString(SArg(1)); return 0; }
|
static int ztestmode( T* p, lua_State *L ) { p->SetZTestModeString(SArg(1)); return 0; }
|
||||||
static int zwrite( T* p, lua_State *L ) { p->SetZWrite(!!IArg(1)); return 0; }
|
static int zwrite( T* p, lua_State *L ) { p->SetZWrite(!!IArg(1)); return 0; }
|
||||||
|
static int zbias( T* p, lua_State *L ) { p->SetZBias(!!IArg(1)); return 0; }
|
||||||
static int clearzbuffer( T* p, lua_State *L ) { p->SetClearZBuffer(!!IArg(1)); return 0; }
|
static int clearzbuffer( T* p, lua_State *L ) { p->SetClearZBuffer(!!IArg(1)); return 0; }
|
||||||
static int backfacecull( T* p, lua_State *L ) { p->SetCullMode((!!IArg(1)) ? CULL_BACK : CULL_NONE); return 0; }
|
static int backfacecull( T* p, lua_State *L ) { p->SetCullMode((!!IArg(1)) ? CULL_BACK : CULL_NONE); return 0; }
|
||||||
static int cullmode( T* p, lua_State *L ) { p->SetCullModeString(SArg(1)); return 0; }
|
static int cullmode( T* p, lua_State *L ) { p->SetCullModeString(SArg(1)); return 0; }
|
||||||
@@ -694,6 +697,7 @@ public:
|
|||||||
ADD_METHOD( ztest )
|
ADD_METHOD( ztest )
|
||||||
ADD_METHOD( ztestmode )
|
ADD_METHOD( ztestmode )
|
||||||
ADD_METHOD( zwrite )
|
ADD_METHOD( zwrite )
|
||||||
|
ADD_METHOD( zbias )
|
||||||
ADD_METHOD( clearzbuffer )
|
ADD_METHOD( clearzbuffer )
|
||||||
ADD_METHOD( backfacecull )
|
ADD_METHOD( backfacecull )
|
||||||
ADD_METHOD( cullmode )
|
ADD_METHOD( cullmode )
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ public:
|
|||||||
virtual bool IsZWriteEnabled() const = 0;
|
virtual bool IsZWriteEnabled() const = 0;
|
||||||
virtual void SetZWrite( bool b ) = 0;
|
virtual void SetZWrite( bool b ) = 0;
|
||||||
virtual void SetZTestMode( ZTestMode mode ) = 0;
|
virtual void SetZTestMode( ZTestMode mode ) = 0;
|
||||||
|
virtual void SetZBias( bool b ) = 0;
|
||||||
virtual void ClearZBuffer() = 0;
|
virtual void ClearZBuffer() = 0;
|
||||||
|
|
||||||
virtual void SetCullMode( CullMode mode ) = 0;
|
virtual void SetCullMode( CullMode mode ) = 0;
|
||||||
|
|||||||
@@ -1035,7 +1035,6 @@ void RageDisplay_D3D::SetTextureFiltering( bool b )
|
|||||||
void RageDisplay_D3D::SetBlendMode( BlendMode mode )
|
void RageDisplay_D3D::SetBlendMode( BlendMode mode )
|
||||||
{
|
{
|
||||||
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
||||||
g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, 0 );
|
|
||||||
switch( mode )
|
switch( mode )
|
||||||
{
|
{
|
||||||
case BLEND_NORMAL:
|
case BLEND_NORMAL:
|
||||||
@@ -1049,11 +1048,6 @@ void RageDisplay_D3D::SetBlendMode( BlendMode mode )
|
|||||||
case BLEND_NO_EFFECT:
|
case BLEND_NO_EFFECT:
|
||||||
g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO );
|
g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO );
|
||||||
g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
|
g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
|
||||||
|
|
||||||
/* This is almost exclusively used to draw masks to the Z-buffer. Make sure
|
|
||||||
* masks always win the depth test when drawn at the same position. */
|
|
||||||
g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, 30 ); // this bias is bigger than it needs to be to handle the coplanar case
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
@@ -1067,6 +1061,15 @@ bool RageDisplay_D3D::IsZWriteEnabled() const
|
|||||||
return b!=0;
|
return b!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RageDisplay_D3D::SetZBias( bool b )
|
||||||
|
{
|
||||||
|
if( b )
|
||||||
|
g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, 30 );
|
||||||
|
else
|
||||||
|
g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RageDisplay_D3D::IsZTestEnabled() const
|
bool RageDisplay_D3D::IsZTestEnabled() const
|
||||||
{
|
{
|
||||||
DWORD b;
|
DWORD b;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public:
|
|||||||
bool IsZWriteEnabled() const;
|
bool IsZWriteEnabled() const;
|
||||||
bool IsZTestEnabled() const;
|
bool IsZTestEnabled() const;
|
||||||
void SetZWrite( bool b );
|
void SetZWrite( bool b );
|
||||||
|
void SetZBias( bool b );
|
||||||
void SetZTestMode( ZTestMode mode );
|
void SetZTestMode( ZTestMode mode );
|
||||||
void ClearZBuffer();
|
void ClearZBuffer();
|
||||||
void SetCullMode( CullMode mode );
|
void SetCullMode( CullMode mode );
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
bool IsZWriteEnabled() const { return false; }
|
bool IsZWriteEnabled() const { return false; }
|
||||||
bool IsZTestEnabled() const { return false; }
|
bool IsZTestEnabled() const { return false; }
|
||||||
void SetZWrite( bool b ) { }
|
void SetZWrite( bool b ) { }
|
||||||
|
void SetZBias( bool b ) { }
|
||||||
void SetZTestMode( ZTestMode mode ) { }
|
void SetZTestMode( ZTestMode mode ) { }
|
||||||
void ClearZBuffer() { }
|
void ClearZBuffer() { }
|
||||||
void SetCullMode( CullMode mode ) { }
|
void SetCullMode( CullMode mode ) { }
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ RageDisplay_OGL::RageDisplay_OGL()
|
|||||||
InitStringMap();
|
InitStringMap();
|
||||||
|
|
||||||
wind = NULL;
|
wind = NULL;
|
||||||
|
g_bTextureMatrixShader = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString GetInfoLog( GLhandleARB h )
|
CString GetInfoLog( GLhandleARB h )
|
||||||
@@ -1472,7 +1473,6 @@ void RageDisplay_OGL::SetBlendMode( BlendMode mode )
|
|||||||
{
|
{
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
glDepthRange( 0.05, 1.0 );
|
|
||||||
switch( mode )
|
switch( mode )
|
||||||
{
|
{
|
||||||
case BLEND_NORMAL:
|
case BLEND_NORMAL:
|
||||||
@@ -1484,10 +1484,6 @@ void RageDisplay_OGL::SetBlendMode( BlendMode mode )
|
|||||||
case BLEND_NO_EFFECT:
|
case BLEND_NO_EFFECT:
|
||||||
/* XXX: Would it be faster and have the same effect to say glDisable(GL_COLOR_WRITEMASK)? */
|
/* XXX: Would it be faster and have the same effect to say glDisable(GL_COLOR_WRITEMASK)? */
|
||||||
glBlendFunc( GL_ZERO, GL_ONE );
|
glBlendFunc( GL_ZERO, GL_ONE );
|
||||||
|
|
||||||
/* This is almost exclusively used to draw masks to the Z-buffer. Make sure
|
|
||||||
* masks always win the depth test when drawn at the same position. */
|
|
||||||
glDepthRange( 0.0, 0.95 ); // this bias is bigger than it needs to be to handle the coplanar case
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
@@ -1521,6 +1517,14 @@ void RageDisplay_OGL::SetZWrite( bool b )
|
|||||||
glDepthMask( b );
|
glDepthMask( b );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RageDisplay_OGL::SetZBias( bool b )
|
||||||
|
{
|
||||||
|
if( b )
|
||||||
|
glDepthRange( 0.0, 0.95 );
|
||||||
|
else
|
||||||
|
glDepthRange( 0.05, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
void RageDisplay_OGL::SetZTestMode( ZTestMode mode )
|
void RageDisplay_OGL::SetZTestMode( ZTestMode mode )
|
||||||
{
|
{
|
||||||
glEnable( GL_DEPTH_TEST );
|
glEnable( GL_DEPTH_TEST );
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
bool IsZWriteEnabled() const;
|
bool IsZWriteEnabled() const;
|
||||||
bool IsZTestEnabled() const;
|
bool IsZTestEnabled() const;
|
||||||
void SetZWrite( bool b );
|
void SetZWrite( bool b );
|
||||||
|
void SetZBias( bool b );
|
||||||
void SetZTestMode( ZTestMode mode );
|
void SetZTestMode( ZTestMode mode );
|
||||||
void ClearZBuffer();
|
void ClearZBuffer();
|
||||||
void SetCullMode( CullMode mode );
|
void SetCullMode( CullMode mode );
|
||||||
|
|||||||
Reference in New Issue
Block a user