Skip to content

Commit

Permalink
Renderer: Adjust fixed weapon FOV for 4:3 view aspect
Browse files Browse the repository at this point in the history
IssueID #2379
  • Loading branch information
skyjake committed Dec 28, 2019
1 parent e11ae9f commit e851528
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion doomsday/apps/client/src/render/rend_main.cpp
Expand Up @@ -566,8 +566,24 @@ Matrix4f Rend_GetProjectionMatrix(float fixedFov, float clipRangeScale)
return fixedView->projectionMatrix;
}

const dfloat fov = (fixedFov > 0 ? fixedFov : Rend_FieldOfView());
const Vector2f size = R_Console3DViewRect(displayPlayer).size();

// IssueID #2379: adapt fixed FOV angle for a 4:3 aspect ratio
if (fixedFov > 0)
{
const float ASPECT_DEFAULT = 16.0f / 9.0f;
const float ASPECT_MIN = 4.0f / 3.0f;
const float aspect = de::max(size.x / size.y, ASPECT_MIN);

if (aspect < ASPECT_DEFAULT)
{
// The fixed FOV angle is specified for a 16:9 horizontal view.
// Adjust for this aspect ratio.
fixedFov *= lerp(0.825f, 1.0f, (aspect - ASPECT_MIN) / (ASPECT_DEFAULT - ASPECT_MIN));
}
}

const dfloat fov = (fixedFov > 0 ? fixedFov : Rend_FieldOfView());
yfov = vrCfg().verticalFieldOfView(fov, size);
const Rangef clip = GL_DepthClipRange();
return vrCfg().projectionMatrix(
Expand Down

0 comments on commit e851528

Please sign in to comment.