Hey everyone!
Since patch 6.0 hit last week, I started working on WoW again and I encountered something that's quite strange.
When I draw 3D objects with clipping, they're kinda broken now. The clipping only looks okay when my camera is zoomed in. When I zoom out my camera, all objects start to disappear behind the terrain.
Okay: https://i.imgur.com/ZEKBXIu.jpg
Not okay (slightly zoomed out): https://i.imgur.com/gNNjfBa.jpg
My near clip and far clip values are taken from World::GetNearClip & World::GetFarClip. Viewport Depth is still constant 0.94f.
The depth target is taken from a hook in CWorldSceneRender::Render; it's the depth buffer that the game uses to draw the world.
The projection matrix that I use is taken from GxuXformCreateProjection_Exact (0x77A89; 19034), which looks like this:
Code:
static Matrix PerspectiveFovWoW(float fovy, float aspect, float zn, float zf) {
float xs = tanf(fovy * 0.5f) * zn;
float xn = zn / (xs * aspect);
Matrix mat = {
xn, 0.0f, 0.0f, 0.0f,
0.0f, zn / xs, 0.0f, 0.0f,
0.0f, 0.0f, (zn + zf) / (zf - zn), 1.0f,
0.0f, 0.0f, ((zf * -2.0f) * zn) / (zf - zn), 0.0f
};
return mat;
}
The look at matrix for WoW's coordinate system looks like:
Code:
static Matrix LookAtWoW(const Vector3 &eye, const Vector3 &at, const Vector3 &up) {
Vector3 zaxis = (at - eye).normalize();
Vector3 xaxis = Vector3::Cross(zaxis, up).normalize();
Vector3 yaxis = Vector3::Cross(xaxis, zaxis);
Matrix mat = {
xaxis.x, yaxis.x, zaxis.x, 0.0f,
xaxis.y, yaxis.y, zaxis.y, 0.0f,
xaxis.z, yaxis.z, zaxis.z, 0.0f,
-xaxis.dot(eye), -yaxis.dot(eye), -zaxis.dot(eye), 1.0f
};
return mat;
}
GetNearClip/GetFarClip offsets:
Code:
uintptr_t GetNearClip = 0x4F847C; // 19034
uintptr_t GetFarClip = 0x4F8452; // 19034
Camera offsets:
Code:
struct CameraHolder {
struct VMTHolder {
uint32_t FOV = 0;
uint32_t Forward = 1;
uint32_t Right = 2;
uint32_t Up = 3;
} VMT;
uintptr_t Position = 0x8;
} CGCamera;
I was wondering if anyone of you guys did anything drawing related since MoP/WoD and if you have similar issues.
Without Z-testing everything looks fine ofcourse.
Thanks