|
|
|
|
@@ -186,14 +186,36 @@ TSE::Matrix4x4 BuildView_Zplus_RH(const TSE::Matrix4x4& world)
|
|
|
|
|
void TSE::Camera::PreDraw(IShader *shader)
|
|
|
|
|
{
|
|
|
|
|
rt->Bind();
|
|
|
|
|
shader->SetUniform("prMatrix", projectionMatrix);
|
|
|
|
|
// shader->SetUniform("prMatrix", projectionMatrix);
|
|
|
|
|
|
|
|
|
|
auto worlmatrix = baseObject->GetGlobalMatrix();
|
|
|
|
|
// auto worlmatrix = baseObject->GetGlobalMatrix();
|
|
|
|
|
|
|
|
|
|
viewMatrix = BuildView_Zplus_RH(worlmatrix);
|
|
|
|
|
// viewMatrix = BuildView_Zplus_RH(worlmatrix);
|
|
|
|
|
|
|
|
|
|
shader->SetUniform("camMatrix", &viewMatrix);
|
|
|
|
|
helper->OnRenderTargetChanged(lastRtSize.x, lastRtSize.y);
|
|
|
|
|
// shader->SetUniform("camMatrix", &viewMatrix);
|
|
|
|
|
// helper->OnRenderTargetChanged(lastRtSize.x, lastRtSize.y);
|
|
|
|
|
|
|
|
|
|
Vector3 pos = baseObject->GetGlobalPosition();
|
|
|
|
|
Vector3 right = baseObject->LocalToGlobalPosition(Vector3::right) - pos;
|
|
|
|
|
Vector3 up = baseObject->LocalToGlobalPosition(Vector3::up) - pos;
|
|
|
|
|
Vector3 forward = baseObject->LocalToGlobalPosition(Vector3::forward) - pos;
|
|
|
|
|
forward.Normalize();
|
|
|
|
|
|
|
|
|
|
shader->SetUniform("CamPos", &pos);
|
|
|
|
|
shader->SetUniform("CamRight", &right);
|
|
|
|
|
shader->SetUniform("CamUp", &up);
|
|
|
|
|
shader->SetUniform("CamForward", &forward);
|
|
|
|
|
|
|
|
|
|
float x = lastRtSize.x / RenderScale;
|
|
|
|
|
float y = lastRtSize.y / RenderScale;
|
|
|
|
|
float mx = -x;
|
|
|
|
|
float my = -y;
|
|
|
|
|
shader->SetUniform("OrthoLeft", mx);
|
|
|
|
|
shader->SetUniform("OrthoRight", x);
|
|
|
|
|
shader->SetUniform("OrthoBottom", my);
|
|
|
|
|
shader->SetUniform("OrthoTop", y);
|
|
|
|
|
shader->SetUniform("NearPlane", nearClippingPlane);
|
|
|
|
|
shader->SetUniform("FarPlane", farClippingPlane);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TSE::Camera::PostDraw()
|
|
|
|
|
|