Quellcode durchsuchen

Fix slope-scale depth bias potentially not creating new rasterizer state on D3D11 due to poor hashing. Remove mistaken adjustment of slope-scale bias on OpenGL. Now behavior should be uniform between D3D9/D3D11/OpenGL. Closes #1547.

Lasse Öörni vor 9 Jahren
Ursprung
Commit
489f759e00

+ 1 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -2534,7 +2534,7 @@ void Graphics::PrepareDraw()
 
         unsigned newRasterizerStateHash =
             (scissorTest_ ? 1 : 0) | (fillMode_ << 1) | (cullMode_ << 3) | ((scaledDepthBias & 0x1fff) << 5) |
-            ((*((unsigned*)&slopeScaledDepthBias_) & 0x1fff) << 18);
+            (((int)(slopeScaledDepthBias_ * 100.0f) & 0x1fff) << 18);
         if (newRasterizerStateHash != impl_->rasterizerStateHash_)
         {
             HashMap<unsigned, ID3D11RasterizerState*>::Iterator i = impl_->rasterizerStates_.Find(newRasterizerStateHash);

+ 1 - 2
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -1707,9 +1707,8 @@ void Graphics::SetDepthBias(float constantBias, float slopeScaledBias)
         if (slopeScaledBias != 0.0f)
         {
             // OpenGL constant bias is unreliable and dependant on depth buffer bitdepth, apply in the projection matrix instead
-            float adjustedSlopeScaledBias = slopeScaledBias + 1.0f;
             glEnable(GL_POLYGON_OFFSET_FILL);
-            glPolygonOffset(adjustedSlopeScaledBias, 0.0f);
+            glPolygonOffset(slopeScaledBias, 0.0f);
         }
         else
             glDisable(GL_POLYGON_OFFSET_FILL);