Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
-Fix broken fixed-function pipeline vertex shaders
-Fix possible broken winding order when drawing HUD
  • Loading branch information
SaiyansKing committed Sep 12, 2021
1 parent 7f81d93 commit 8dfa95b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions D3D11Engine/D3D7/MyDirect3DDevice7.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ class MyDirect3DDevice7 : public IDirect3DDevice7 {
exv[i].Color = rhw[i].color;
}

if ( Engine::GAPI->GetRendererState().RasterizerState.FrontCounterClockwise ) {
// Some mods can change winding order
Engine::GAPI->GetRendererState().RasterizerState.FrontCounterClockwise = false;
Engine::GAPI->GetRendererState().RasterizerState.SetDirty();
}

Engine::GraphicsEngine->SetActiveVertexShader( "VS_TransformedEx" );
Engine::GraphicsEngine->BindViewportInformation( "VS_TransformedEx", 0 );
break;
Expand Down
6 changes: 3 additions & 3 deletions D3D11Engine/Shaders/VS_TransformedEx.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ float4 TransformXYZRHW(float4 xyzrhw)
ndc.y = 1 - ((2 * (xyzrhw.y - V_ViewportPos.y)) / V_ViewportSize.y);
ndc.z = xyzrhw.z;

// Remove the stupid half-pixel offset from pre D3D10
ndc.xy -= 0.5f / V_ViewportSize;

// Convert to clip-space. rhw is actually 1/w ("reciprocal"). So to undo the devide by w, devide by the given 1/w.
float actualW = 1.0f / xyzrhw.w;
float3 clipSpace = ndc.xyz * actualW;

// Remove the stupid half-pixel offset from pre D3D10
clipSpace.xy -= 0.5f / V_ViewportSize;

return float4(clipSpace, actualW);

// Remove viewport-transformation
Expand Down
6 changes: 3 additions & 3 deletions D3D11Engine/Shaders/VS_XYZRHW_DIF_T1.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ float4 TransformXYZRHW(float4 xyzrhw)
ndc.y = 1 - ((2 * (xyzrhw.y - V_ViewportPos.y)) / V_ViewportSize.y);
ndc.z = xyzrhw.z;

// Remove the stupid half-pixel offset from pre D3D10
ndc.xy -= 0.5f / V_ViewportSize;

// Convert to clip-space. rhw is actually 1/w ("reciprocal"). So to undo the devide by w, devide by the given 1/w.
float actualW = 1.0f / xyzrhw.w;
float3 clipSpace = ndc.xyz * actualW;

// Remove the stupid half-pixel offset from pre D3D10
clipSpace.xy -= 0.5f / V_ViewportSize;

return float4(clipSpace, actualW);

// Remove viewport-transformation
Expand Down

0 comments on commit 8dfa95b

Please sign in to comment.