 CSGO: World To Screen flickering on EndScene
Hello, so recently i’ve been trying to fix multicore rendering with endscene drawing and I’ve seen the CRender matrix solution. I’ve tried applying it but my esp still goes all over the place.
Here’s the code:
bool Utils::WorldToScreen(const Vector &origin, Vector &screen)
{
const auto ScreenTransform = [&origin, &screen]() -> bool
{
if (crender_interface->m_ViewStack.Count() > 1)
{
const VMatrix& w2sMatrix = crender_interface->m_ViewStack.Top().m_matrixWorldToScreen;
screen.x = w2sMatrix.m[0][0] * origin.x + w2sMatrix.m[0][1] * origin.y + w2sMatrix.m[0][2] * origin.z + w2sMatrix.m[0][3];
screen.y = w2sMatrix.m[1][0] * origin.x + w2sMatrix.m[1][1] * origin.y + w2sMatrix.m[1][2] * origin.z + w2sMatrix.m[1][3];
screen.z = 0.0f;
float w = w2sMatrix.m[3][0] * origin.x + w2sMatrix.m[3][1] * origin.y + w2sMatrix.m[3][2] * origin.z + w2sMatrix.m[3][3];
if (w < 0.001f) {
screen.x *= 100000;
screen.y *= 100000;
return false;
}
screen.x /= w;
screen.y /= w;
return true;
}
return false;
};
if (ScreenTransform())
{
int w, h;
ivengine_interface->GetScreenSize(w, h);
screen.x = (w / 2.0f) + (screen.x * w) / 2.0f;
screen.y = (h / 2.0f) - (screen.y * h) / 2.0f;
return true;
}
return false;
}
How I get crender:
crender_interface = *(CRender**)(Utils::FindPatternIDA("engine.dll", "56 57 0F 57 C0 C7 05 ? ? ? ? ? ? ? ? 51") + 0x7);
CRender class:
struct ViewStack_t
{
CViewSetup m_View;
// matrices
VMatrix m_matrixView;
VMatrix m_matrixProjection;
VMatrix m_matrixWorldToScreen;
bool m_bIs2DView;
bool m_bNoDraw;
};
class CRender
{
public:
char pad_0x0000[0x4]; //0x0000
float m_yFOV; //0x0004
double m_frameStartTime; //0x0008
float m_framerate; //0x0010
float m_zNear; //0x0014
float m_zFar; //0x0018
VMatrix m_matrixView; //0x001C
VMatrix m_matrixProjection; //0x005C
VMatrix m_matrixWorldToScreen; //0x009C
CUtlStack< ViewStack_t >m_ViewStack; //0x00DC
int m_iLightmapUpdateDepth; //0x00F0
}; //Size=0x00F4
|