Fix normal tangent
Some tangents did not get calculate, this cause some uncolored triangles show in the rendered model, this commit fixed it.master
parent
1853e45ea4
commit
538528d103
|
@ -218,7 +218,7 @@ void TextureGenerator::generate()
|
|||
m_resultTextureBorderImage->fill(Qt::transparent);
|
||||
|
||||
m_resultTextureNormalImage = new QImage(TextureGenerator::m_textureSize, TextureGenerator::m_textureSize, QImage::Format_ARGB32);
|
||||
m_resultTextureNormalImage->fill(Qt::transparent);
|
||||
m_resultTextureNormalImage->fill(QColor(127, 127, 127));
|
||||
|
||||
m_resultTextureMetalnessRoughnessAmbientOcclusionImage = new QImage(TextureGenerator::m_textureSize, TextureGenerator::m_textureSize, QImage::Format_ARGB32);
|
||||
m_resultTextureMetalnessRoughnessAmbientOcclusionImage->fill(QColor(255, 255, 0));
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <QDebug>
|
||||
#include "triangletangentresolve.h"
|
||||
|
||||
void triangleTangentResolve(const Outcome &outcome, std::vector<QVector3D> &tangents)
|
||||
|
@ -24,8 +25,9 @@ void triangleTangentResolve(const Outcome &outcome, std::vector<QVector3D> &tang
|
|||
QVector2D deltaUv1 = uv2 - uv1;
|
||||
QVector2D deltaUv2 = uv3 - uv1;
|
||||
auto bottom = deltaUv1.x() * deltaUv2.y() - deltaUv2.x() * deltaUv1.y();
|
||||
if (qFuzzyIsNull(bottom))
|
||||
continue;
|
||||
if (qFuzzyIsNull(bottom)) {
|
||||
bottom = 0.000001;
|
||||
}
|
||||
float f = 1.0 / bottom;
|
||||
QVector3D tangent = {
|
||||
f * (deltaUv2.y() * edge1.x() - deltaUv1.y() * edge2.x()),
|
||||
|
|
Loading…
Reference in New Issue