Fixes upDirection Vector for camera
This commit is contained in:
parent
da6d2af058
commit
26a8ef7913
1 changed files with 5 additions and 1 deletions
|
@ -8,8 +8,12 @@ Ray PerspectiveCamera::createRay(float x, float y) const {
|
|||
// in which the camera looks along the positive z-Axis
|
||||
|
||||
Vector3d normalVector = normalized(crossProduct(upDirection, forwardDirection));
|
||||
|
||||
// Orthogonolize upDirection, to avoid skewing the image
|
||||
Vector3d orthogonalUpDirection = -crossProduct(normalVector, forwardDirection);
|
||||
|
||||
Vector3d normalVector_fov = normalVector * std::abs(tan(this->fovAngle / 360.0f * PI));
|
||||
Vector3d upVector_fov = this->upDirection * std::abs(tan(this->fovAngle / 360.0f * PI));
|
||||
Vector3d upVector_fov = orthogonalUpDirection * std::abs(tan(this->fovAngle / 360.0f * PI));
|
||||
Vector3d directionVector = normalized(forwardDirection + x * normalVector_fov + y * upVector_fov);
|
||||
|
||||
return Ray {this->position, directionVector};
|
||||
|
|
Loading…
Reference in a new issue