Skip to content

Commit

Permalink
Merge pull request dfkeenan#6 from catapillie/catapillie/fix/aspect-r…
Browse files Browse the repository at this point in the history
…atio

Fix aspect ratio when calculating the projection matrix
  • Loading branch information
dfkeenan authored Aug 26, 2023
2 parents cf01a77 + 0189336 commit b2b34f4
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Source/21_DescriptorLayout/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Radians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Radians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Radians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down
2 changes: 1 addition & 1 deletion Source/22_DescriptorSets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Scalar.DegreesToRadians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down
2 changes: 1 addition & 1 deletion Source/23_TextureImage/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Scalar.DegreesToRadians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down
2 changes: 1 addition & 1 deletion Source/24_Sampler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Scalar.DegreesToRadians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down
2 changes: 1 addition & 1 deletion Source/25_TextureMapping/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Scalar.DegreesToRadians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down
2 changes: 1 addition & 1 deletion Source/26_DepthBuffering/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Scalar.DegreesToRadians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down
2 changes: 1 addition & 1 deletion Source/27_ModelLoading/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Scalar.DegreesToRadians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down
2 changes: 1 addition & 1 deletion Source/28_MipMapping/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Scalar.DegreesToRadians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down
2 changes: 1 addition & 1 deletion Source/29_Multisampling/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ private void UpdateUniformBuffer(uint currentImage)
{
model = Matrix4X4<float>.Identity * Matrix4X4.CreateFromAxisAngle<float>(new Vector3D<float>(0, 0, 1), time * Scalar.DegreesToRadians(90.0f)),
view = Matrix4X4.CreateLookAt(new Vector3D<float>(2, 2, 2), new Vector3D<float>(0, 0, 0), new Vector3D<float>(0, 0, 1)),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
proj = Matrix4X4.CreatePerspectiveFieldOfView(Scalar.DegreesToRadians(45.0f), (float)swapChainExtent.Width / swapChainExtent.Height, 0.1f, 10.0f),
};
ubo.proj.M22 *= -1;

Expand Down

0 comments on commit b2b34f4

Please sign in to comment.