Fixed sprite wrong normals

This commit is contained in:
Antoine Pilote
2023-09-23 22:59:32 -04:00
parent c90065c85e
commit 42c82e4ca3
3 changed files with 12 additions and 8 deletions

View File

@@ -76,7 +76,9 @@ void main()
// Normal
vec3 normal = vec3(0.5, 0.5, 1.0);
if (u_HasNormal == 1)
{
normal = texture(m_Normal, UV).rgb;
}
normal = normal * 2.0 - 1.0;
normal = TBN * normalize(normal);
gNormal = vec4(normal / 2.0 + 0.5, 1.0f);

View File

@@ -53,7 +53,7 @@ namespace Nuake
}
m_Name = albedo;
InitDefaultTextures();
//InitDefaultTextures();
}
Material::Material(const Vector3 albedoColor)

View File

@@ -3,6 +3,7 @@
#include "src/Core/FileSystem.h"
#include "src/Rendering/Textures/TextureManager.h"
#include "src/Rendering/Textures/MaterialManager.h"
#include "src/Rendering/Textures/Material.h"
#include "src/Rendering/Vertex.h"
namespace Nuake
@@ -19,19 +20,20 @@ namespace Nuake
{
std::vector<Vertex> quadVertices =
{
{ Vector3(-1.0f, 1.0f, 0.0f), Vector2(0.0f, 1.0f), Vector3(0, 0, -1) },
{ Vector3(1.0f, 1.0f, 0.0f), Vector2(1.0f, 1.0f), Vector3(0, 0, -1) },
{ Vector3(-1.0f, -1.0f, 0.0f), Vector2(0, 0), Vector3(0, 0, -1) },
{ Vector3(-1.0f, 1.0f, 0.0f), Vector2(0.0f, 1.0f), Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(0, 1, 0) },
{ Vector3(1.0f, 1.0f, 0.0f), Vector2(1.0f, 1.0f), Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(0, 1, 0) },
{ Vector3(-1.0f, -1.0f, 0.0f), Vector2(0, 0), Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(0, 1, 0) },
{ Vector3(1.0f, -1.0f, 0.0f), Vector2(1.0f, 0.0f), Vector3(0, 0, -1) },
{ Vector3(-1.0f, -1.0f, 0.0f), Vector2(0.0f, 0.0f), Vector3(0, 0, -1) },
{ Vector3(1.0f, 1.0f, 0.0f), Vector2(1.0f, 1.0f), Vector3(0, 0, -1) }
{ Vector3(1.0f, -1.0f, 0.0f), Vector2(1.0f, 0.0f), Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(0, 1, 0) },
{ Vector3(-1.0f, -1.0f, 0.0f), Vector2(0.0f, 0.0f), Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(0, 1, 0) },
{ Vector3(1.0f, 1.0f, 0.0f), Vector2(1.0f, 1.0f), Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(0, 1, 0) }
};
SpriteMesh = CreateRef<Mesh>();
SpriteMesh->AddSurface(quadVertices, { 0, 1, 2, 3, 4, 5 });
auto material = MaterialManager::Get()->GetMaterial(FileSystem::Root + SpritePath);
Ref<Material> material = MaterialManager::Get()->GetMaterial(FileSystem::Root + SpritePath);
bool hasNormal = material->HasNormal();
SpriteMesh->SetMaterial(material);
return true;