floating-point zbias. For compatibility, 0 is off and 1 is the old "zbias on".

Going beyond 1 is allowed, but the usable/useful range of values is currently
undefined--try to stick to 0..1.
This commit is contained in:
Glenn Maynard
2005-05-06 04:05:02 +00:00
parent 52520f2135
commit 47db6ca9c4
8 changed files with 19 additions and 19 deletions
+5 -2
View File
@@ -76,7 +76,7 @@ void Actor::Reset()
m_bTextureWrapping = false;
m_BlendMode = BLEND_NORMAL;
m_bZBias = false;
m_fZBias = 0;
m_bClearZBuffer = false;
m_ZTestMode = ZTEST_OFF;
m_bZWrite = false;
@@ -389,7 +389,10 @@ void Actor::SetGlobalRenderStates()
// 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_fZBias == 0 && m_BlendMode == BLEND_NO_EFFECT )
DISPLAY->SetZBias( 1.0f );
else
DISPLAY->SetZBias( m_fZBias );
if( m_bClearZBuffer )
DISPLAY->ClearZBuffer();
+3 -3
View File
@@ -342,7 +342,7 @@ public:
virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; }
void SetZTestModeString( const CString &s ); // convenience
virtual void SetZWrite( bool b ) { m_bZWrite = b; }
void SetZBias( bool b ) { m_bZBias = b; }
void SetZBias( float f ) { m_fZBias = f; }
virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; }
void SetCullModeString( const CString &s ); // convenience
@@ -464,7 +464,7 @@ protected:
bool m_bClearZBuffer;
ZTestMode m_ZTestMode;
bool m_bZWrite;
bool m_bZBias; // if true, always wins z-test against a coplanar actor
float m_fZBias; // 0 = no bias; 1 = full bias
CullMode m_CullMode;
//
@@ -578,7 +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 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 zbias( T* p, lua_State *L ) { p->SetZBias(!!IArg(1)); return 0; }
static int zbias( T* p, lua_State *L ) { p->SetZBias(FArg(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 cullmode( T* p, lua_State *L ) { p->SetCullModeString(SArg(1)); return 0; }
+1 -1
View File
@@ -172,7 +172,7 @@ public:
virtual bool IsZWriteEnabled() const = 0;
virtual void SetZWrite( bool b ) = 0;
virtual void SetZTestMode( ZTestMode mode ) = 0;
virtual void SetZBias( bool b ) = 0;
virtual void SetZBias( float f ) = 0;
virtual void ClearZBuffer() = 0;
virtual void SetCullMode( CullMode mode ) = 0;
+2 -5
View File
@@ -1061,12 +1061,9 @@ bool RageDisplay_D3D::IsZWriteEnabled() const
return b!=0;
}
void RageDisplay_D3D::SetZBias( bool b )
void RageDisplay_D3D::SetZBias( float f )
{
if( b )
g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, 30 );
else
g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, 0 );
g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, (int) SCALE( f, 0.0f, 1.0f, 0, 30 ) );
}
+1 -1
View File
@@ -41,7 +41,7 @@ public:
bool IsZWriteEnabled() const;
bool IsZTestEnabled() const;
void SetZWrite( bool b );
void SetZBias( bool b );
void SetZBias( float f );
void SetZTestMode( ZTestMode mode );
void ClearZBuffer();
void SetCullMode( CullMode mode );
+1 -1
View File
@@ -39,7 +39,7 @@ public:
bool IsZWriteEnabled() const { return false; }
bool IsZTestEnabled() const { return false; }
void SetZWrite( bool b ) { }
void SetZBias( bool b ) { }
void SetZBias( float f ) { }
void SetZTestMode( ZTestMode mode ) { }
void ClearZBuffer() { }
void SetCullMode( CullMode mode ) { }
+5 -5
View File
@@ -1517,12 +1517,12 @@ void RageDisplay_OGL::SetZWrite( bool b )
glDepthMask( b );
}
void RageDisplay_OGL::SetZBias( bool b )
void RageDisplay_OGL::SetZBias( float f )
{
if( b )
glDepthRange( 0.0, 0.95 );
else
glDepthRange( 0.05, 1.0 );
float fNear = SCALE( f, 0.0f, 1.0f, 0.05f, 0.0f );
float fFar = SCALE( f, 0.0f, 1.0f, 1.0f, 0.95f );
glDepthRange( fNear, fFar );
}
void RageDisplay_OGL::SetZTestMode( ZTestMode mode )
+1 -1
View File
@@ -42,7 +42,7 @@ public:
bool IsZWriteEnabled() const;
bool IsZTestEnabled() const;
void SetZWrite( bool b );
void SetZBias( bool b );
void SetZBias( float f );
void SetZTestMode( ZTestMode mode );
void ClearZBuffer();
void SetCullMode( CullMode mode );