|
@@ -438,16 +438,6 @@ void Renderer::OnWindowResize()
|
|
|
CreateDepthBuffer();
|
|
|
}
|
|
|
|
|
|
-/// Construct a perspective matrix
|
|
|
-static inline Mat44 sPerspective(float inFovY, float inAspect, float inNear, float inFar)
|
|
|
-{
|
|
|
- float height = 1.0f / Tan(0.5f * inFovY);
|
|
|
- float width = height / inAspect;
|
|
|
- float range = inFar / (inNear - inFar);
|
|
|
-
|
|
|
- return Mat44(Vec4(width, 0.0f, 0.0f, 0.0f), Vec4(0.0f, height, 0.0f, 0.0f), Vec4(0.0f, 0.0f, range, -1.0f), Vec4(0.0f, 0.0f, range * inNear, 0.0f));
|
|
|
-}
|
|
|
-
|
|
|
void Renderer::BeginFrame(const CameraState &inCamera, float inWorldScale)
|
|
|
{
|
|
|
JPH_PROFILE_FUNCTION();
|
|
@@ -506,13 +496,13 @@ void Renderer::BeginFrame(const CameraState &inCamera, float inWorldScale)
|
|
|
VertexShaderConstantBuffer *vs = mVertexShaderConstantBufferProjection[mFrameIndex]->Map<VertexShaderConstantBuffer>();
|
|
|
|
|
|
// Camera projection and view
|
|
|
- vs->mProjection = sPerspective(camera_fovy, camera_aspect, camera_near, camera_far);
|
|
|
+ vs->mProjection = Mat44::sPerspective(camera_fovy, camera_aspect, camera_near, camera_far);
|
|
|
Vec3 cam_pos = Vec3(inCamera.mPos - mBaseOffset);
|
|
|
Vec3 tgt = cam_pos + inCamera.mForward;
|
|
|
vs->mView = Mat44::sLookAt(cam_pos, tgt, inCamera.mUp);
|
|
|
|
|
|
// Light projection and view
|
|
|
- vs->mLightProjection = sPerspective(light_fov, 1.0f, light_near, light_far);
|
|
|
+ vs->mLightProjection = Mat44::sPerspective(light_fov, 1.0f, light_near, light_far);
|
|
|
vs->mLightView = Mat44::sLookAt(light_pos, light_tgt, light_up);
|
|
|
|
|
|
mVertexShaderConstantBufferProjection[mFrameIndex]->Unmap();
|