Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ void RTS3DScene::Render(RenderInfoClass & rinfo)
//wireframe should be visible.
///@todo: Clearing to black may not be needed if the scene already did the clear.
DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_ALPHA);
DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 0);
DX8Wrapper::Set_DX8_ZBias(0);
//Since all objects will be rendered with same material, disable resetting until all are done.
m_maskMaterialPass->setAllowUninstall(FALSE);

Expand All @@ -1025,7 +1025,7 @@ void RTS3DScene::Render(RenderInfoClass & rinfo)
///@todo: Clearing to black may not be needed if the scene already did the clear.
DX8Wrapper::Clear(true, false, Vector3(0.0f,0.0f,0.0f),1.0f); // Clear color but not z
DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_ALPHA);
DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 0);
DX8Wrapper::Set_DX8_ZBias(0);

//We're only filling the z-buffer so ignore normal textures and state changes to speed things up.
m_customPassMode = SCENE_PASS_ALPHA_MASK;
Expand Down Expand Up @@ -1057,7 +1057,7 @@ void RTS3DScene::Render(RenderInfoClass & rinfo)
rinfo.Camera.Set_Zbuffer_Range(nearZ, farZ);
rinfo.Camera.Apply();

// DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 0);
// DX8Wrapper::Set_DX8_ZBias(0);
WW3D::Enable_Texturing(old_enable);
WW3D::Enable_Coloring(0);

Expand All @@ -1069,7 +1069,7 @@ void RTS3DScene::Render(RenderInfoClass & rinfo)

//Disable writes to color buffer to save memory bandwidth - we only need Z.
DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,0);
DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 0);
DX8Wrapper::Set_DX8_ZBias(0);
Customized_Render(rinfo);
Flush(rinfo);
//Re-enable writes to color buffer.
Expand All @@ -1079,21 +1079,21 @@ void RTS3DScene::Render(RenderInfoClass & rinfo)
case EXTRA_PASS_LINE:
WW3D::Enable_Texturing(false);
DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 7);
DX8Wrapper::Set_DX8_ZBias(7);
Customized_Render(rinfo);
break;
case EXTRA_PASS_CLEAR_LINE:
DX8Wrapper::Clear(true, false, Vector3(0.0f,0.0f,0.0f), 0.0f); // Clear color but not z
WW3D::Enable_Texturing(false);
WW3D::Enable_Coloring(0xff008000);
DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 7);
DX8Wrapper::Set_DX8_ZBias(7);
Customized_Render(rinfo);
break;
}
Flush(rinfo);
DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_SOLID);
DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 0);
DX8Wrapper::Set_DX8_ZBias(0);
WW3D::Enable_Texturing(old_enable);
WW3D::Enable_Coloring(0);
ShaderClass::Invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2609,15 +2609,15 @@ void DX8MeshRendererClass::Render_Decal_Meshes()
DecalMeshClass * decal_mesh = visible_decal_meshes;
if (!decal_mesh) return;

DX8Wrapper::Set_DX8_Render_State(D3DRS_ZBIAS,8);
DX8Wrapper::Set_DX8_ZBias(8);

while (decal_mesh != nullptr) {
decal_mesh->Render();
decal_mesh = decal_mesh->Peek_Next_Visible();
}
visible_decal_meshes = nullptr;

DX8Wrapper::Set_DX8_Render_State(D3DRS_ZBIAS,0);
DX8Wrapper::Set_DX8_ZBias(0);
}

// ----------------------------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ class DX8Wrapper

static void Set_DX8_Light(int index,D3DLIGHT9* light);
static void Set_DX8_Render_State(D3DRENDERSTATETYPE state, unsigned value);
static void Set_DX8_ZBias(unsigned int zbias);
static void Set_DX8_Clip_Plane(DWORD Index, CONST float* pPlane);
static void Set_DX8_Texture_Stage_State(unsigned stage, D3DTEXTURESTAGESTATETYPE state, unsigned value);

Expand Down Expand Up @@ -1335,6 +1336,15 @@ WWINLINE void DX8Wrapper::Set_DX8_Render_State(D3DRENDERSTATETYPE state, unsigne

}

WWINLINE void DX8Wrapper::Set_DX8_ZBias(unsigned int zbias)
{
// D3D8 D3DRS_ZBIAS accepted integer values 0-16.
// D3D9 D3DRS_DEPTHBIAS accepts a float encoded as a DWORD.
// Convert the legacy integer to a float depth bias value.
float bias = zbias * (-0.000005f);
Set_DX8_Render_State(D3DRS_DEPTHBIAS, *reinterpret_cast<unsigned*>(&bias));
}

WWINLINE void DX8Wrapper::Set_DX8_Clip_Plane(DWORD Index, CONST float* pPlane)
{
DX8CALL(SetClipPlane( Index, pPlane ));
Expand Down