Skip to content

Commit

Permalink
Solve small vertical FOV issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelarius committed Nov 9, 2023
1 parent 23b3364 commit 82208c1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common/camera.cpp
Expand Up @@ -11,7 +11,7 @@ Camera createCamera(
const float aspectRatio)
{
const float theta = vfov.as_radians();
const float halfHeight = glm::tan(0.5f * theta);
const float halfHeight = focusDistance * glm::tan(0.5f * theta);
const float halfWidth = aspectRatio * halfHeight;

const glm::vec3 w = glm::normalize(lookAt - origin);
Expand Down
2 changes: 1 addition & 1 deletion src/pt/fly_camera_controller.cpp
Expand Up @@ -121,7 +121,7 @@ glm::vec3 FlyCameraController::generateCameraRayDir(
const MousePos& pos) const
{
const float aspect = aspectRatio(mWindowSize);
const float halfHeight = std::tan(0.5f * mVfov.as_radians());
const float halfHeight = mFocusDistance * std::tan(0.5f * mVfov.as_radians());
const float halfWidth = aspect * halfHeight;

// UV coordinates in [0, 1] range with (0, 0) in the top-left corner.
Expand Down
2 changes: 1 addition & 1 deletion src/pt/main.cpp
Expand Up @@ -54,7 +54,7 @@ int main()

{
pt::Extent2i curFramebufferSize = window.resolution();
float vfovDegrees = 80.0f;
float vfovDegrees = 70.0f;
while (!glfwWindowShouldClose(window.ptr()))
{
glfwPollEvents();
Expand Down

0 comments on commit 82208c1

Please sign in to comment.