Skip to content
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

Scissor bug fix #65

Open
JeremyAnsel opened this issue May 25, 2022 · 0 comments
Open

Scissor bug fix #65

JeremyAnsel opened this issue May 25, 2022 · 0 comments

Comments

@JeremyAnsel
Copy link

JeremyAnsel commented May 25, 2022

Hello,
Here is a suggestion about the reported scissor bug.

In D3dRenderer.h, I suggest to add D3D11_RECT scissor; to the DrawCommand struct.

In D3dRenderer.h, I suggest to add void GetScissorRect(D3D11_RECT* scissor); to the D3dRenderer class.

In XwaD3dRendererHook.cpp, I suggest to add this function:

void D3dRenderer::GetScissorRect(D3D11_RECT* scissor)
{
	unsigned short scissorLeft = *(unsigned short*)0x07D5244;
	unsigned short scissorTop = *(unsigned short*)0x07CA354;
	unsigned short scissorWidth = *(unsigned short*)0x08052B8;
	unsigned short scissorHeight = *(unsigned short*)0x07B33BC;
	float scaleX = _viewport.Width / _deviceResources->_displayWidth;
	float scaleY = _viewport.Height / _deviceResources->_displayHeight;

	// The scissor is in screen coordinates.
	scissor->left = (LONG)(_viewport.TopLeftX + scissorLeft * scaleX + 0.5f);
	scissor->top = (LONG)(_viewport.TopLeftY + scissorTop * scaleY + 0.5f);
	scissor->right = scissor->left + (LONG)(scissorWidth * scaleX + 0.5f);
	scissor->bottom = scissor->top + (LONG)(scissorHeight * scaleY + 0.5f);}

In EffectsRenderer.cpp, I suggest to add GetScissorRect(&command.scissor); before _LaserDrawCommands.push_back(command);.

In EffectsRenderer.cpp, I suggest to add GetScissorRect(&command.scissor); before _TransparentDrawCommands.push_back(command);.

In EffectsRenderer.cpp, I suggest to add GetScissorRect(&command.scissor); before _ShadowMapDrawCommands.push_back(command);.

In EffectsRenderer.cpp, I suggest to add that in the RenderLasers method before RenderScene();:

_deviceResources->InitScissorRect(&command.scissor);

In EffectsRenderer.cpp, I suggest to add that in the RenderTransparency method before RenderScene();:

_deviceResources->InitScissorRect(&command.scissor);

In EffectsRenderer.cpp, I suggest to add that in the RenderHangarShadowMap method before context->DrawIndexed(_trianglesCount * 3, 0, 0);:

_deviceResources->InitScissorRect(&command.scissor);

In EffectsRenderer.cpp, I suggest to add that in the MainSceneHook method before RenderScene();:

D3D11_RECT scissor{};
GetScissorRect(&scissor);
_deviceResources->InitScissorRect(&scissor);

In EffectsRenderer.cpp, I suggest to remove these lines in the RenderScene method:

	unsigned short scissorLeft = *(unsigned short*)0x07D5244;
	unsigned short scissorTop = *(unsigned short*)0x07CA354;
	unsigned short scissorWidth = *(unsigned short*)0x08052B8;
	unsigned short scissorHeight = *(unsigned short*)0x07B33BC;
	float scaleX = _viewport.Width / _deviceResources->_displayWidth;
	float scaleY = _viewport.Height / _deviceResources->_displayHeight;
	D3D11_RECT scissor{};
	// The scissor is in screen coordinates.
	scissor.left = (LONG)(_viewport.TopLeftX + scissorLeft * scaleX + 0.5f);
	scissor.top = (LONG)(_viewport.TopLeftY + scissorTop * scaleY + 0.5f);
	scissor.right = scissor.left + (LONG)(scissorWidth * scaleX + 0.5f);
	scissor.bottom = scissor.top + (LONG)(scissorHeight * scaleY + 0.5f);
	_deviceResources->InitScissorRect(&scissor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant