Fix matrix in GEVulkanCameraSceneNode::render
This commit is contained in:
parent
8ab63edd30
commit
fa72ef7246
@ -1,5 +1,7 @@
|
|||||||
#include "ge_vulkan_camera_scene_node.hpp"
|
#include "ge_vulkan_camera_scene_node.hpp"
|
||||||
|
|
||||||
|
#include "ge_main.hpp"
|
||||||
|
#include "ge_vulkan_driver.hpp"
|
||||||
#include "ge_vulkan_dynamic_buffer.hpp"
|
#include "ge_vulkan_dynamic_buffer.hpp"
|
||||||
|
|
||||||
namespace GE
|
namespace GE
|
||||||
@ -29,16 +31,22 @@ void GEVulkanCameraSceneNode::render()
|
|||||||
|
|
||||||
m_ubo_data.m_view_matrix = ViewArea.getTransform(irr::video::ETS_VIEW);
|
m_ubo_data.m_view_matrix = ViewArea.getTransform(irr::video::ETS_VIEW);
|
||||||
m_ubo_data.m_projection_matrix = ViewArea.getTransform(irr::video::ETS_PROJECTION);
|
m_ubo_data.m_projection_matrix = ViewArea.getTransform(irr::video::ETS_PROJECTION);
|
||||||
|
// Irrlicht matrix4 was originally designed for OpenGL,
|
||||||
|
// where the Y coordinate of the clip coordinates is inverted.
|
||||||
|
// The easiest way to compensate for that is to flip the sign on the
|
||||||
|
// scaling factor of the Y axis in the projection matrix.
|
||||||
|
m_ubo_data.m_projection_matrix(1, 1) *= -1.0f;
|
||||||
|
m_ubo_data.m_projection_matrix = getVKDriver()->getPreRotationMatrix() *
|
||||||
|
m_ubo_data.m_projection_matrix;
|
||||||
|
|
||||||
irr::core::matrix4 mat;
|
irr::core::matrix4 mat;
|
||||||
ViewArea.getTransform(irr::video::ETS_VIEW).getInverse(mat);
|
ViewArea.getTransform(irr::video::ETS_VIEW).getInverse(mat);
|
||||||
m_ubo_data.m_inverse_view_matrix = mat;
|
m_ubo_data.m_inverse_view_matrix = mat;
|
||||||
|
|
||||||
ViewArea.getTransform(irr::video::ETS_PROJECTION).getInverse(mat);
|
m_ubo_data.m_projection_matrix.getInverse(mat);
|
||||||
m_ubo_data.m_inverse_projection_matrix = mat;
|
m_ubo_data.m_inverse_projection_matrix = mat;
|
||||||
|
|
||||||
mat = ViewArea.getTransform(irr::video::ETS_PROJECTION) *
|
mat = m_ubo_data.m_projection_matrix * m_ubo_data.m_view_matrix;
|
||||||
ViewArea.getTransform(irr::video::ETS_VIEW);
|
|
||||||
|
|
||||||
m_ubo_data.m_projection_view_matrix = mat;
|
m_ubo_data.m_projection_view_matrix = mat;
|
||||||
} // render
|
} // render
|
||||||
|
Loading…
Reference in New Issue
Block a user