-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert D3DFVF_XYZRHW into D3DFVF_XYZW #188
Conversation
What's the use-case? |
If you want to use RTX Remix, your geometry has to be in XYZ or XYZW mode. D3DFVF_XYZRHW is not supported. |
ddraw/IDirect3DDeviceX.cpp
Outdated
@@ -330,6 +330,28 @@ HRESULT m_IDirect3DDeviceX::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStat | |||
break; | |||
} | |||
|
|||
if(Config.DdrawConvertHomogeneousW) | |||
{ | |||
if(dtstTransformStateType == D3DTS_VIEW) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assumes that SetTransform is called, which is not the case for DK2 for example
{ | ||
float *pos = (float*) vertex; | ||
|
||
pos[3] = 1.0f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you lose information here if rhw is != 1?
It's not used for many things, but at least for perspective-correct texture mapping and some exotic stuff like fog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation read that the use of W is undefined here, and not seen as part of the position vector. For me it made no difference if I had it or not. So it is probably better to just remove it then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah not sure if they use the W at all in this mode, also they also say it's "designed for, and can only be used with, the programmable vertex pipeline."
https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dfvf
So the input coordinates are in screen space and your view matrix transforms it back into clip space?
https://gamedev.net/forums/topic/582097-difference-between-d3dfvf_xyzw-and-d3dfvf_xyzrhw/4705397/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SetTransform function overrides the game matrices with its own, when the mode is active.
// Replace the matrix with one that handles D3DFVF_XYZRHW geometry
D3DVIEWPORT9 Viewport9;
if(SUCCEEDED((*d3d9Device)->GetViewport(&Viewport9)))
{
ZeroMemory(lpD3DMatrix, sizeof(_D3DMATRIX));
lpD3DMatrix->_11 = 2.0f / (float)Viewport9.Width;
lpD3DMatrix->_22 = -2.0f / (float)Viewport9.Height;
lpD3DMatrix->_33 = 1.0f;
lpD3DMatrix->_41 = -1.0f; // translate X
lpD3DMatrix->_42 = 1.0f; // translate Y
lpD3DMatrix->_44 = 1.0f;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know.
I guess an identity viewport matrix would also suffice but not sure about this mode.
https://learn.microsoft.com/en-us/windows/win32/dxtecharts/the-direct3d-transformation-pipeline
Okay let me take a look. It is definitely working on my side. |
Hey, I just wanted to say, I have not forgotten about this, but I will take until the weekend before I can take an actual look at it. Work is pretty rough right now. |
No problem. Thanks. |
I created a new pull request #199. |
You can now turn D3DFVF_XYZRHW rendering into D3DFVF_XYZW and it should look the same.