diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 33baf6cd96..4516db7f10 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -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(); diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 8ba73fd1ce..28c9faeb47 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -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; } diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 3e340c3f7c..b20bed0054 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -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; diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 5282d0e76a..0dc39f6040 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -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 ) ); } diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index 5c72dca4c3..0a23cc7885 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -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 ); diff --git a/stepmania/src/RageDisplay_Null.h b/stepmania/src/RageDisplay_Null.h index 1e4238ea40..376256479f 100644 --- a/stepmania/src/RageDisplay_Null.h +++ b/stepmania/src/RageDisplay_Null.h @@ -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 ) { } diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 4131ac24ba..4a66fba758 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -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 ) diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index b3f3e56bb8..e9a452bf41 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -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 );