mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Fixed sprite wrong normals
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Nuake
|
||||
}
|
||||
|
||||
m_Name = albedo;
|
||||
InitDefaultTextures();
|
||||
//InitDefaultTextures();
|
||||
}
|
||||
|
||||
Material::Material(const Vector3 albedoColor)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user