diff --git a/Editor/resources/Shaders/gbuffer.shader b/Editor/resources/Shaders/gbuffer.shader index e2200c8e..30207f61 100644 --- a/Editor/resources/Shaders/gbuffer.shader +++ b/Editor/resources/Shaders/gbuffer.shader @@ -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); diff --git a/Nuake/src/Rendering/Textures/Material.cpp b/Nuake/src/Rendering/Textures/Material.cpp index 8257debc..08bba30b 100644 --- a/Nuake/src/Rendering/Textures/Material.cpp +++ b/Nuake/src/Rendering/Textures/Material.cpp @@ -53,7 +53,7 @@ namespace Nuake } m_Name = albedo; - InitDefaultTextures(); + //InitDefaultTextures(); } Material::Material(const Vector3 albedoColor) diff --git a/Nuake/src/Scene/Components/SpriteComponent.cpp b/Nuake/src/Scene/Components/SpriteComponent.cpp index 2f384db1..20e5d5f9 100644 --- a/Nuake/src/Scene/Components/SpriteComponent.cpp +++ b/Nuake/src/Scene/Components/SpriteComponent.cpp @@ -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 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(); SpriteMesh->AddSurface(quadVertices, { 0, 1, 2, 3, 4, 5 }); - auto material = MaterialManager::Get()->GetMaterial(FileSystem::Root + SpritePath); + Ref material = MaterialManager::Get()->GetMaterial(FileSystem::Root + SpritePath); + bool hasNormal = material->HasNormal(); SpriteMesh->SetMaterial(material); return true;