Mirror UV if needed in vulkan

This commit is contained in:
Benau 2022-09-01 10:54:33 +08:00
parent 089dd025f1
commit ad8ba4d417

View File

@ -43,6 +43,11 @@
#include <IMaterialRendererServices.h>
#include <ISceneNode.h>
#include <mini_glm.hpp>
#ifndef SERVER_ONLY
#include <ge_spm_buffer.hpp>
#endif
using namespace irr::video;
@ -788,8 +793,24 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
if (m_mirrorred_mesh_buffers.find((void*)mb) == m_mirrorred_mesh_buffers.end())
{
m_mirrorred_mesh_buffers[(void*)mb] = true;
//irr::video::S3DVertex* mbVertices = (video::S3DVertex*)mb->getVertices();
video::S3DVertexSkinnedMesh* mbVertices = (video::S3DVertexSkinnedMesh*)mb->getVertices();
for (unsigned int i = 0; i < mb->getVertexCount(); i++)
{
if (mb->getVertexType() == video::EVT_SKINNED_MESH)
{
using namespace MiniGLM;
if (m_mirror_axis_when_reverse == 'V')
{
mbVertices[i].m_all_uvs[1] =
toFloat16(1.0f - toFloat32(mbVertices[i].m_all_uvs[1]));
}
else
{
mbVertices[i].m_all_uvs[0] =
toFloat16(1.0f - toFloat32(mbVertices[i].m_all_uvs[0]));
}
}
else
{
core::vector2df &tc = mb->getTCoords(i);
if (m_mirror_axis_when_reverse == 'V')
@ -798,6 +819,15 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
tc.X = 1 - tc.X;
}
}
#ifndef SERVER_ONLY
if (is_vk)
{
GE::GESPMBuffer* spmb = static_cast<GE::GESPMBuffer*>(mb);
spmb->destroyVertexIndexBuffer();
spmb->createVertexIndexBuffer();
}
#endif
}
} // reverse track and texture needs mirroring
if (m_shader_name == "unlit")