Commit 7b1e0815 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

d3d8: Map ZBIAS values to a smaller depth range.

parent 362a7d57
...@@ -1466,6 +1466,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(IDirect3DDevice8 *iface, ...@@ -1466,6 +1466,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(IDirect3DDevice8 *iface,
return hr; return hr;
} }
/* This factor is the result of a trial-and-error search. Both ZBIAS and DEPTHBIAS require
* guesswork by design. d3d9 apps usually use a DEPTHBIAS of -0.00002(Mass Effect 2, WoW).
* d3d8 apps(Final Fantasy XI) set ZBIAS to 15 and still expect the depth test to sort
* objects properly. */
static const float zbias_factor = -0.000005f;
static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *iface, static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *iface,
D3DRENDERSTATETYPE State, DWORD Value) D3DRENDERSTATETYPE State, DWORD Value)
{ {
...@@ -1483,7 +1489,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *ifac ...@@ -1483,7 +1489,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *ifac
switch (State) switch (State)
{ {
case D3DRS_ZBIAS: case D3DRS_ZBIAS:
wined3d_value.f = Value / -16.0f; wined3d_value.f = Value * zbias_factor;
hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, wined3d_value.d); hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, wined3d_value.d);
break; break;
...@@ -1513,7 +1519,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(IDirect3DDevice8 *ifac ...@@ -1513,7 +1519,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(IDirect3DDevice8 *ifac
{ {
case D3DRS_ZBIAS: case D3DRS_ZBIAS:
hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, &wined3d_value.d); hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, &wined3d_value.d);
if (SUCCEEDED(hr)) *pValue = -wined3d_value.f * 16.0f; if (SUCCEEDED(hr)) *pValue = wined3d_value.f / zbias_factor;
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment