From ad8b46db38404795ae61732d27b26f41bc159b51 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 19 Jul 2022 20:02:01 +0200 Subject: [PATCH] Rename Diffuse to BaseColor --- assets/shaders/deferred_frag.nzsl | 20 ++++---- assets/shaders/deferred_vert.nzsl | 2 +- examples/DeferredShading/main.cpp | 8 +-- examples/GraphicsTest/main.cpp | 2 +- examples/PhysicallyBasedRendering/main.cpp | 2 +- examples/Physics2DDemo/main.cpp | 4 +- examples/PhysicsDemo/main.cpp | 6 +-- examples/WidgetDemo/main.cpp | 4 +- include/Nazara/Graphics/BasicMaterial.hpp | 22 ++++---- include/Nazara/Graphics/BasicMaterial.inl | 40 +++++++-------- include/Nazara/Utility/MaterialData.hpp | 6 +-- plugins/Assimp/Plugin.cpp | 19 +++++-- src/Nazara/Graphics/BasicMaterial.cpp | 50 +++++++++---------- src/Nazara/Graphics/LinearSlicedSprite.cpp | 4 +- src/Nazara/Graphics/PhongLightingMaterial.cpp | 18 +++---- .../Graphics/PhysicallyBasedMaterial.cpp | 10 ++-- .../Resources/Shaders/BasicMaterial.nzsl | 22 ++++---- .../Resources/Shaders/DepthMaterial.nzsl | 14 +++--- .../Resources/Shaders/PhongMaterial.nzsl | 24 ++++----- .../Shaders/PhysicallyBasedMaterial.nzsl | 26 +++++----- src/Nazara/Graphics/SlicedSprite.cpp | 4 +- src/Nazara/Graphics/Sprite.cpp | 4 +- src/Nazara/Utility/Formats/MD2Loader.cpp | 2 +- src/Nazara/Utility/Formats/OBJLoader.cpp | 8 +-- src/Nazara/Utility/Formats/OBJSaver.cpp | 4 +- src/Nazara/Widgets/DefaultWidgetTheme.cpp | 2 +- 26 files changed, 169 insertions(+), 158 deletions(-) diff --git a/assets/shaders/deferred_frag.nzsl b/assets/shaders/deferred_frag.nzsl index f3f43be7e..8626c0d4b 100644 --- a/assets/shaders/deferred_frag.nzsl +++ b/assets/shaders/deferred_frag.nzsl @@ -4,7 +4,7 @@ module; import InstanceData from Engine.InstanceData; import ViewerData from Engine.ViewerData; -option HasDiffuseTexture: bool = false; +option HasBaseColorTexture: bool = false; option HasAlphaTexture: bool = false; option AlphaTest: bool = false; @@ -12,13 +12,13 @@ option AlphaTest: bool = false; struct BasicSettings { AlphaThreshold: f32, - DiffuseColor: vec4[f32] + BaseColor: vec4[f32] } external { [binding(0)] settings: uniform[BasicSettings], - [binding(1)] MaterialDiffuseMap: sampler2D[f32], + [binding(1)] MaterialBaseColorMap: sampler2D[f32], [binding(2)] MaterialAlphaMap: sampler2D[f32], [binding(3)] TextureOverlay: sampler2D[f32], [binding(4)] instanceData: uniform[InstanceData], @@ -34,7 +34,7 @@ struct InputData struct OutputData { - [location(0)] diffuseMap: vec4[f32], + [location(0)] baseColorMap: vec4[f32], [location(1)] normalMap: vec4[f32], [location(2)] positionMap: vec4[f32] } @@ -42,21 +42,21 @@ struct OutputData [entry(frag)] fn main(input: InputData) -> OutputData { - let diffuseColor = settings.DiffuseColor; - const if (HasDiffuseTexture) - diffuseColor *= MaterialDiffuseMap.Sample(input.uv); + let color = settings.BaseColor; + const if (HasBaseColorTexture) + color *= MaterialBaseColorMap.Sample(input.uv); const if (HasAlphaTexture) - diffuseColor.w *= MaterialAlphaMap.Sample(input.uv).x; + color.w *= MaterialAlphaMap.Sample(input.uv).x; const if (AlphaTest) { - if (diffuseColor.w < settings.AlphaThreshold) + if (color.w < settings.AlphaThreshold) discard; } let output: OutputData; - output.diffuseMap = diffuseColor; + output.baseColorMap = color; output.normalMap = vec4[f32]((vec3[f32](1.0, 1.0, 1.0) + input.normal) * 0.5, 1.0); output.positionMap = vec4[f32](input.pos, 1.0); return output; diff --git a/assets/shaders/deferred_vert.nzsl b/assets/shaders/deferred_vert.nzsl index a05afc716..18c36f43d 100644 --- a/assets/shaders/deferred_vert.nzsl +++ b/assets/shaders/deferred_vert.nzsl @@ -8,7 +8,7 @@ import ViewerData from Engine.ViewerData; struct BasicSettings { AlphaThreshold: f32, - DiffuseColor: vec4[f32] + BaseColor: vec4[f32] } external diff --git a/examples/DeferredShading/main.cpp b/examples/DeferredShading/main.cpp index b916eabdb..958770c39 100644 --- a/examples/DeferredShading/main.cpp +++ b/examples/DeferredShading/main.cpp @@ -206,7 +206,7 @@ int main() Nz::BasicMaterial basicMat(*spaceshipMatPass); basicMat.EnableAlphaTest(false); basicMat.SetAlphaMap(Nz::Texture::LoadFromFile(resourceDir / "alphatile.png", texParams)); - basicMat.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); + basicMat.SetBaseColorMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); } spaceshipMat->AddPass("ForwardPass", spaceshipMatPass); @@ -225,7 +225,7 @@ int main() flareMaterialPass->SetBlendFunc(Nz::BlendFunc::SrcAlpha, Nz::BlendFunc::InvSrcAlpha, Nz::BlendFunc::One, Nz::BlendFunc::Zero); Nz::BasicMaterial Osef(*flareMaterialPass); - Osef.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "flare1.png", texParams)); + Osef.SetBaseColorMap(Nz::Texture::LoadFromFile(resourceDir / "flare1.png", texParams)); flareMaterial->AddPass("ForwardPass", flareMaterialPass); } @@ -236,13 +236,13 @@ int main() planeMatPass->EnableDepthBuffer(true); { Nz::BasicMaterial basicMat(*planeMatPass); - basicMat.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "dev_grey.png", texParams)); + basicMat.SetBaseColorMap(Nz::Texture::LoadFromFile(resourceDir / "dev_grey.png", texParams)); Nz::TextureSamplerInfo planeSampler; planeSampler.anisotropyLevel = 16; planeSampler.wrapModeU = Nz::SamplerWrap::Repeat; planeSampler.wrapModeV = Nz::SamplerWrap::Repeat; - basicMat.SetDiffuseSampler(planeSampler); + basicMat.SetBaseColorSampler(planeSampler); } planeMat->AddPass("ForwardPass", planeMatPass); diff --git a/examples/GraphicsTest/main.cpp b/examples/GraphicsTest/main.cpp index b48b9a362..0438e964b 100644 --- a/examples/GraphicsTest/main.cpp +++ b/examples/GraphicsTest/main.cpp @@ -73,7 +73,7 @@ int main() Nz::PhongLightingMaterial phongMat(*forwardPass); phongMat.EnableAlphaTest(false); phongMat.SetAlphaMap(Nz::Texture::LoadFromFile(resourceDir / "alphatile.png", texParams)); - phongMat.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); + phongMat.SetBaseColorMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); phongMat.SetNormalMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/normal.png", texParams)); Nz::Model model(std::move(gfxMesh), spaceshipMesh->GetAABB()); diff --git a/examples/PhysicallyBasedRendering/main.cpp b/examples/PhysicallyBasedRendering/main.cpp index de4ef5083..bb044c93e 100644 --- a/examples/PhysicallyBasedRendering/main.cpp +++ b/examples/PhysicallyBasedRendering/main.cpp @@ -67,7 +67,7 @@ int main() Nz::PhysicallyBasedMaterial pbrMat(*forwardPass); pbrMat.EnableAlphaTest(false); pbrMat.SetAlphaMap(Nz::Texture::LoadFromFile(resourceDir / "alphatile.png", texParams)); - pbrMat.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "Rusty/rustediron2_basecolor.png", srgbTexParams)); + pbrMat.SetBaseColorMap(Nz::Texture::LoadFromFile(resourceDir / "Rusty/rustediron2_basecolor.png", srgbTexParams)); pbrMat.SetMetallicMap(Nz::Texture::LoadFromFile(resourceDir / "Rusty/rustediron2_metallic.png", texParams)); pbrMat.SetRoughnessMap(Nz::Texture::LoadFromFile(resourceDir / "Rusty/rustediron2_roughness.png", texParams)); pbrMat.SetNormalMap(normalMap); diff --git a/examples/Physics2DDemo/main.cpp b/examples/Physics2DDemo/main.cpp index 83b1c5177..c766c5404 100644 --- a/examples/Physics2DDemo/main.cpp +++ b/examples/Physics2DDemo/main.cpp @@ -75,8 +75,8 @@ int main() texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB; Nz::BasicMaterial basicMat(*materialPass); - basicMat.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); - basicMat.SetDiffuseSampler(samplerInfo); + basicMat.SetBaseColorMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); + basicMat.SetBaseColorSampler(samplerInfo); for (std::size_t y = 0; y < 10; ++y) { diff --git a/examples/PhysicsDemo/main.cpp b/examples/PhysicsDemo/main.cpp index 24315711e..a754ca062 100644 --- a/examples/PhysicsDemo/main.cpp +++ b/examples/PhysicsDemo/main.cpp @@ -81,8 +81,8 @@ int main() Nz::BasicMaterial basicMat(*materialPass); basicMat.EnableAlphaTest(false); basicMat.SetAlphaMap(Nz::Texture::LoadFromFile(resourceDir / "alphatile.png", texParams)); - basicMat.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); - basicMat.SetDiffuseSampler(samplerInfo); + basicMat.SetBaseColorMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); + basicMat.SetBaseColorSampler(samplerInfo); Nz::DepthMaterial basicMatDepth(*depthPass); basicMatDepth.SetAlphaMap(Nz::Texture::LoadFromFile(resourceDir / "alphatile.png", texParams)); @@ -142,7 +142,7 @@ int main() colliderMat->AddPass("ForwardPass", colliderMatPass); Nz::BasicMaterial colliderBasicMat(*colliderMatPass); - colliderBasicMat.SetDiffuseColor(Nz::Color::Green); + colliderBasicMat.SetBaseColor(Nz::Color::Green); std::shared_ptr colliderModel; { diff --git a/examples/WidgetDemo/main.cpp b/examples/WidgetDemo/main.cpp index 9a6351e32..86e04f4eb 100644 --- a/examples/WidgetDemo/main.cpp +++ b/examples/WidgetDemo/main.cpp @@ -77,8 +77,8 @@ int main() texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB; Nz::BasicMaterial basicMat(*materialPass); - basicMat.SetDiffuseMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); - basicMat.SetDiffuseSampler(samplerInfo); + basicMat.SetBaseColorMap(Nz::Texture::LoadFromFile(resourceDir / "Spaceship/Texture/diffuse.png", texParams)); + basicMat.SetBaseColorSampler(samplerInfo); Nz::ImageWidget* imageWidget = canvas2D.Add(); imageWidget->SetPosition(1200.f, 200.f); diff --git a/include/Nazara/Graphics/BasicMaterial.hpp b/include/Nazara/Graphics/BasicMaterial.hpp index a16601f50..ae8f77634 100644 --- a/include/Nazara/Graphics/BasicMaterial.hpp +++ b/include/Nazara/Graphics/BasicMaterial.hpp @@ -32,24 +32,24 @@ namespace Nz inline const std::shared_ptr& GetAlphaMap() const; inline const TextureSamplerInfo& GetAlphaSampler() const; float GetAlphaTestThreshold() const; - Color GetDiffuseColor() const; - inline const std::shared_ptr& GetDiffuseMap() const; - inline const TextureSamplerInfo& GetDiffuseSampler() const; + Color GetBaseColor() const; + inline const std::shared_ptr& GetBaseColorMap() const; + inline const TextureSamplerInfo& GetBaseColorSampler() const; inline bool IsAlphaTestEnabled() const; inline bool HasAlphaMap() const; inline bool HasAlphaTest() const; inline bool HasAlphaTestThreshold() const; - inline bool HasDiffuseColor() const; - inline bool HasDiffuseMap() const; + inline bool HasBaseColor() const; + inline bool HasBaseColorMap() const; inline void SetAlphaMap(std::shared_ptr alphaMap); inline void SetAlphaSampler(TextureSamplerInfo alphaSampler); void SetAlphaTestThreshold(float alphaThreshold); - void SetDiffuseColor(const Color& diffuse); - inline void SetDiffuseMap(std::shared_ptr diffuseMap); - inline void SetDiffuseSampler(TextureSamplerInfo diffuseSampler); + void SetBaseColor(const Color& baseColor); + inline void SetBaseColorMap(std::shared_ptr baseColorMap); + inline void SetBaseColorSampler(TextureSamplerInfo baseColorSampler); static inline const BasicUniformOffsets& GetOffsets(); static inline const std::shared_ptr& GetSettings(); @@ -57,7 +57,7 @@ namespace Nz struct BasicUniformOffsets { std::size_t alphaThreshold; - std::size_t diffuseColor; + std::size_t baseColor; std::size_t totalSize; }; @@ -70,13 +70,13 @@ namespace Nz { std::size_t alphaTest; std::size_t hasAlphaMap; - std::size_t hasDiffuseMap; + std::size_t hasBaseColorMap; }; struct BasicTextureIndexes { std::size_t alpha; - std::size_t diffuse; + std::size_t baseColor; }; struct BasicBuildOptions diff --git a/include/Nazara/Graphics/BasicMaterial.inl b/include/Nazara/Graphics/BasicMaterial.inl index 8c7f3b742..31d2e8803 100644 --- a/include/Nazara/Graphics/BasicMaterial.inl +++ b/include/Nazara/Graphics/BasicMaterial.inl @@ -46,16 +46,16 @@ namespace Nz return m_material.GetTextureSampler(m_basicTextureIndexes.alpha); } - inline const std::shared_ptr& BasicMaterial::GetDiffuseMap() const + inline const std::shared_ptr& BasicMaterial::GetBaseColorMap() const { - NazaraAssert(HasDiffuseMap(), "Material has no alpha texture slot"); - return m_material.GetTexture(m_basicTextureIndexes.diffuse); + NazaraAssert(HasBaseColorMap(), "Material has no alpha texture slot"); + return m_material.GetTexture(m_basicTextureIndexes.baseColor); } - inline const TextureSamplerInfo& BasicMaterial::GetDiffuseSampler() const + inline const TextureSamplerInfo& BasicMaterial::GetBaseColorSampler() const { - NazaraAssert(HasDiffuseMap(), "Material has no alpha texture slot"); - return m_material.GetTextureSampler(m_basicTextureIndexes.diffuse); + NazaraAssert(HasBaseColorMap(), "Material has no alpha texture slot"); + return m_material.GetTextureSampler(m_basicTextureIndexes.baseColor); } inline bool BasicMaterial::IsAlphaTestEnabled() const @@ -83,14 +83,14 @@ namespace Nz return m_basicUniformOffsets.alphaThreshold != MaterialSettings::InvalidIndex; } - inline bool BasicMaterial::HasDiffuseColor() const + inline bool BasicMaterial::HasBaseColor() const { - return m_basicUniformOffsets.diffuseColor != MaterialSettings::InvalidIndex; + return m_basicUniformOffsets.baseColor != MaterialSettings::InvalidIndex; } - inline bool BasicMaterial::HasDiffuseMap() const + inline bool BasicMaterial::HasBaseColorMap() const { - return m_basicTextureIndexes.diffuse != MaterialSettings::InvalidIndex; + return m_basicTextureIndexes.baseColor != MaterialSettings::InvalidIndex; } inline void BasicMaterial::SetAlphaMap(std::shared_ptr alphaMap) @@ -99,7 +99,7 @@ namespace Nz bool hasAlphaMap = (alphaMap != nullptr); m_material.SetTexture(m_basicTextureIndexes.alpha, std::move(alphaMap)); - if (m_basicOptionIndexes.hasDiffuseMap != MaterialSettings::InvalidIndex) + if (m_basicOptionIndexes.hasBaseColorMap != MaterialSettings::InvalidIndex) m_material.SetOptionValue(m_basicOptionIndexes.hasAlphaMap, hasAlphaMap); } @@ -109,20 +109,20 @@ namespace Nz m_material.SetTextureSampler(m_basicTextureIndexes.alpha, std::move(alphaSampler)); } - inline void BasicMaterial::SetDiffuseMap(std::shared_ptr diffuseMap) + inline void BasicMaterial::SetBaseColorMap(std::shared_ptr baseColorMap) { - NazaraAssert(HasDiffuseMap(), "Material has no diffuse map slot"); - bool hasDiffuseMap = (diffuseMap != nullptr); - m_material.SetTexture(m_basicTextureIndexes.diffuse, std::move(diffuseMap)); + NazaraAssert(HasBaseColorMap(), "Material has no diffuse map slot"); + bool hasBaseColorMap = (baseColorMap != nullptr); + m_material.SetTexture(m_basicTextureIndexes.baseColor, std::move(baseColorMap)); - if (m_basicOptionIndexes.hasDiffuseMap != MaterialSettings::InvalidIndex) - m_material.SetOptionValue(m_basicOptionIndexes.hasDiffuseMap, hasDiffuseMap); + if (m_basicOptionIndexes.hasBaseColorMap != MaterialSettings::InvalidIndex) + m_material.SetOptionValue(m_basicOptionIndexes.hasBaseColorMap, hasBaseColorMap); } - inline void BasicMaterial::SetDiffuseSampler(TextureSamplerInfo diffuseSampler) + inline void BasicMaterial::SetBaseColorSampler(TextureSamplerInfo diffuseSampler) { - NazaraAssert(HasDiffuseMap(), "Material has no diffuse map slot"); - m_material.SetTextureSampler(m_basicTextureIndexes.diffuse, std::move(diffuseSampler)); + NazaraAssert(HasBaseColorMap(), "Material has no diffuse map slot"); + m_material.SetTextureSampler(m_basicTextureIndexes.baseColor, std::move(diffuseSampler)); } inline MaterialPass& BasicMaterial::GetMaterial() diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index 2a2ec1d37..6f77d2605 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -21,6 +21,9 @@ namespace Nz static constexpr const char* BackFaceStencilPass = "MatBackFaceStencilPass"; static constexpr const char* BackFaceStencilReference = "MatBackFaceStencilReference"; static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail"; + static constexpr const char* BaseColor = "MatBaseColor"; + static constexpr const char* BaseColorTexturePath = "MatBaseColorTexturePath"; + static constexpr const char* BaseColorWrap = "MatBaseColorWrap"; static constexpr const char* Blending = "MatBlending"; static constexpr const char* BlendModeAlpha = "MatBlendModeAlpha"; static constexpr const char* BlendModeColor = "MatBlendModeColor"; @@ -35,10 +38,7 @@ namespace Nz static constexpr const char* DepthSorting = "MatDepthSorting"; static constexpr const char* DepthWrite = "MatDepthWrite"; static constexpr const char* DiffuseAnisotropyLevel = "MatDiffuseAnisotropyLevel"; - static constexpr const char* DiffuseColor = "MatDiffuseColor"; static constexpr const char* DiffuseFilter = "MatDiffuseFilter"; - static constexpr const char* DiffuseTexturePath = "MatDiffuseTexturePath"; - static constexpr const char* DiffuseWrap = "MatDiffuseWrap"; static constexpr const char* EmissiveTexturePath = "MatEmissiveTexturePath"; static constexpr const char* FaceCulling = "MatFaceCulling"; static constexpr const char* FaceFilling = "MatFaceFilling"; diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 58341392c..16b7e3981 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -377,7 +377,10 @@ std::shared_ptr LoadMesh(Stream& stream, const MeshParams& parameters) if (aiGetMaterialColor(aiMat, aiKey, aiType, aiIndex, &color) == aiReturn_SUCCESS) { matData.SetParameter(colorKey, Color(color.r, color.g, color.b, color.a)); + return true; } + + return false; }; auto ConvertTexture = [&](aiTextureType aiType, const char* textureKey, const char* wrapKey = nullptr) @@ -413,19 +416,27 @@ std::shared_ptr LoadMesh(Stream& stream, const MeshParams& parameters) matData.SetParameter(wrapKey, static_cast(wrap)); } + + return true; } + + return false; }; ConvertColor(AI_MATKEY_COLOR_AMBIENT, MaterialData::AmbientColor); - ConvertColor(AI_MATKEY_COLOR_DIFFUSE, MaterialData::DiffuseColor); + + if (!ConvertColor(AI_MATKEY_BASE_COLOR, MaterialData::BaseColor)) + ConvertColor(AI_MATKEY_COLOR_DIFFUSE, MaterialData::BaseColor); + ConvertColor(AI_MATKEY_COLOR_SPECULAR, MaterialData::SpecularColor); - ConvertTexture(aiTextureType_DIFFUSE, MaterialData::DiffuseTexturePath, MaterialData::DiffuseWrap); ConvertTexture(aiTextureType_EMISSIVE, MaterialData::EmissiveTexturePath); ConvertTexture(aiTextureType_HEIGHT, MaterialData::HeightTexturePath); ConvertTexture(aiTextureType_NORMALS, MaterialData::NormalTexturePath); ConvertTexture(aiTextureType_OPACITY, MaterialData::AlphaTexturePath); ConvertTexture(aiTextureType_SPECULAR, MaterialData::SpecularTexturePath, MaterialData::SpecularWrap); + if (!ConvertTexture(aiTextureType_BASE_COLOR, MaterialData::BaseColorTexturePath, MaterialData::BaseColorWrap)) + ConvertTexture(aiTextureType_DIFFUSE, MaterialData::BaseColorTexturePath, MaterialData::BaseColorWrap); aiString name; if (aiGetMaterialString(aiMat, AI_MATKEY_NAME, &name) == aiReturn_SUCCESS) @@ -627,10 +638,10 @@ std::shared_ptr LoadMesh(Stream& stream, const MeshParams& parameters) }; ConvertColor(AI_MATKEY_COLOR_AMBIENT, MaterialData::AmbientColor); - ConvertColor(AI_MATKEY_COLOR_DIFFUSE, MaterialData::DiffuseColor); + ConvertColor(AI_MATKEY_COLOR_DIFFUSE, MaterialData::BaseColor); ConvertColor(AI_MATKEY_COLOR_SPECULAR, MaterialData::SpecularColor); - ConvertTexture(aiTextureType_DIFFUSE, MaterialData::DiffuseTexturePath, MaterialData::DiffuseWrap); + ConvertTexture(aiTextureType_DIFFUSE, MaterialData::BaseColorTexturePath, MaterialData::BaseColorWrap); ConvertTexture(aiTextureType_EMISSIVE, MaterialData::EmissiveTexturePath); ConvertTexture(aiTextureType_HEIGHT, MaterialData::HeightTexturePath); ConvertTexture(aiTextureType_NORMALS, MaterialData::NormalTexturePath); diff --git a/src/Nazara/Graphics/BasicMaterial.cpp b/src/Nazara/Graphics/BasicMaterial.cpp index 7d7657075..4533e7bf7 100644 --- a/src/Nazara/Graphics/BasicMaterial.cpp +++ b/src/Nazara/Graphics/BasicMaterial.cpp @@ -33,21 +33,21 @@ namespace Nz { m_basicOptionIndexes.alphaTest = materialSettings->GetOptionIndex("AlphaTest"); m_basicOptionIndexes.hasAlphaMap = materialSettings->GetOptionIndex("HasAlphaMap"); - m_basicOptionIndexes.hasDiffuseMap = materialSettings->GetOptionIndex("HasDiffuseMap"); + m_basicOptionIndexes.hasBaseColorMap = materialSettings->GetOptionIndex("HasBaseColorMap"); m_basicTextureIndexes.alpha = materialSettings->GetTextureIndex("Alpha"); - m_basicTextureIndexes.diffuse = materialSettings->GetTextureIndex("Diffuse"); + m_basicTextureIndexes.baseColor = materialSettings->GetTextureIndex("BaseColor"); m_uniformBlockIndex = materialSettings->GetUniformBlockIndex("MaterialSettings"); if (m_uniformBlockIndex != MaterialSettings::InvalidIndex) { m_basicUniformOffsets.alphaThreshold = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "AlphaThreshold"); - m_basicUniformOffsets.diffuseColor = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "DiffuseColor"); + m_basicUniformOffsets.baseColor = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "BaseColor"); } else { m_basicUniformOffsets.alphaThreshold = MaterialSettings::InvalidIndex; - m_basicUniformOffsets.diffuseColor = MaterialSettings::InvalidIndex; + m_basicUniformOffsets.baseColor = MaterialSettings::InvalidIndex; } } } @@ -61,13 +61,13 @@ namespace Nz return AccessByOffset(bufferData.data(), m_basicUniformOffsets.alphaThreshold); } - Color BasicMaterial::GetDiffuseColor() const + Color BasicMaterial::GetBaseColor() const { - NazaraAssert(HasDiffuseColor(), "Material has no diffuse color uniform"); + NazaraAssert(HasBaseColor(), "Material has no base color uniform"); const std::vector& bufferData = m_material.GetUniformBufferConstData(m_uniformBlockIndex); - const float* colorPtr = AccessByOffset(bufferData.data(), m_basicUniformOffsets.diffuseColor); + const float* colorPtr = AccessByOffset(bufferData.data(), m_basicUniformOffsets.baseColor); return Color(colorPtr[0], colorPtr[1], colorPtr[2], colorPtr[3]); } @@ -79,17 +79,17 @@ namespace Nz AccessByOffset(bufferData.data(), m_basicUniformOffsets.alphaThreshold) = alphaThreshold; } - void BasicMaterial::SetDiffuseColor(const Color& diffuse) + void BasicMaterial::SetBaseColor(const Color& baseColor) { - NazaraAssert(HasDiffuseColor(), "Material has no diffuse color uniform"); + NazaraAssert(HasBaseColor(), "Material has no base color uniform"); std::vector& bufferData = m_material.GetUniformBufferData(m_uniformBlockIndex); - float* colorPtr = AccessByOffset(bufferData.data(), m_basicUniformOffsets.diffuseColor); - colorPtr[0] = diffuse.r; - colorPtr[1] = diffuse.g; - colorPtr[2] = diffuse.b; - colorPtr[3] = diffuse.a; + float* colorPtr = AccessByOffset(bufferData.data(), m_basicUniformOffsets.baseColor); + colorPtr[0] = baseColor.r; + colorPtr[1] = baseColor.g; + colorPtr[2] = baseColor.b; + colorPtr[3] = baseColor.a; } MaterialSettings::Builder BasicMaterial::Build(BasicBuildOptions& options) @@ -105,11 +105,11 @@ namespace Nz }); } - if (options.basicOffsets.diffuseColor != std::numeric_limits::max()) + if (options.basicOffsets.baseColor != std::numeric_limits::max()) { variables.push_back({ - "DiffuseColor", - options.basicOffsets.diffuseColor + "BaseColor", + options.basicOffsets.baseColor }); } @@ -118,8 +118,8 @@ namespace Nz if (options.basicOffsets.alphaThreshold != std::numeric_limits::max()) AccessByOffset(options.defaultValues.data(), options.basicOffsets.alphaThreshold) = 0.2f; - if (options.basicOffsets.diffuseColor != std::numeric_limits::max()) - AccessByOffset(options.defaultValues.data(), options.basicOffsets.diffuseColor) = Vector4f(1.f, 1.f, 1.f, 1.f); + if (options.basicOffsets.baseColor != std::numeric_limits::max()) + AccessByOffset(options.defaultValues.data(), options.basicOffsets.baseColor) = Vector4f(1.f, 1.f, 1.f, 1.f); // Textures if (options.basicTextureIndexes) @@ -132,11 +132,11 @@ namespace Nz }); if (options.basicTextureIndexes) - options.basicTextureIndexes->diffuse = settings.textures.size(); + options.basicTextureIndexes->baseColor = settings.textures.size(); settings.textures.push_back({ 1, - "Diffuse", + "BaseColor", ImageType::E2D }); @@ -206,11 +206,11 @@ namespace Nz // Options - // HasDiffuseMap + // HasBaseColorMap if (options.basicOptionIndexes) - options.basicOptionIndexes->hasDiffuseMap = settings.options.size(); + options.basicOptionIndexes->hasBaseColorMap = settings.options.size(); - MaterialSettings::BuildOption(settings.options, "HasDiffuseMap", "HasDiffuseTexture"); + MaterialSettings::BuildOption(settings.options, "HasBaseColorMap", "HasBaseColorTexture"); // HasAlphaMap if (options.basicOptionIndexes) @@ -240,7 +240,7 @@ namespace Nz BasicUniformOffsets uniformOffsets; uniformOffsets.alphaThreshold = fieldOffsets.AddField(nzsl::StructFieldType::Float1); - uniformOffsets.diffuseColor = fieldOffsets.AddField(nzsl::StructFieldType::Float4); + uniformOffsets.baseColor = fieldOffsets.AddField(nzsl::StructFieldType::Float4); uniformOffsets.totalSize = fieldOffsets.GetAlignedSize(); return std::make_pair(std::move(uniformOffsets), std::move(fieldOffsets)); diff --git a/src/Nazara/Graphics/LinearSlicedSprite.cpp b/src/Nazara/Graphics/LinearSlicedSprite.cpp index fed157901..a7c75e3cb 100644 --- a/src/Nazara/Graphics/LinearSlicedSprite.cpp +++ b/src/Nazara/Graphics/LinearSlicedSprite.cpp @@ -66,10 +66,10 @@ namespace Nz if (const auto& material = m_material->FindPass("ForwardPass")) { BasicMaterial mat(*material); - if (mat.HasDiffuseMap()) + if (mat.HasBaseColorMap()) { // Material should always have textures but we're better safe than sorry - if (const auto& texture = mat.GetDiffuseMap()) + if (const auto& texture = mat.GetBaseColorMap()) return texture->GetSize(); } } diff --git a/src/Nazara/Graphics/PhongLightingMaterial.cpp b/src/Nazara/Graphics/PhongLightingMaterial.cpp index 2a1610c5b..c713b0372 100644 --- a/src/Nazara/Graphics/PhongLightingMaterial.cpp +++ b/src/Nazara/Graphics/PhongLightingMaterial.cpp @@ -36,7 +36,7 @@ namespace Nz { m_basicOptionIndexes.alphaTest = materialSettings->GetOptionIndex("AlphaTest"); m_basicOptionIndexes.hasAlphaMap = materialSettings->GetOptionIndex("HasAlphaMap"); - m_basicOptionIndexes.hasDiffuseMap = materialSettings->GetOptionIndex("HasDiffuseMap"); + m_basicOptionIndexes.hasBaseColorMap = materialSettings->GetOptionIndex("HasBaseColorMap"); m_phongOptionIndexes.hasEmissiveMap = materialSettings->GetOptionIndex("HasEmissiveMap"); m_phongOptionIndexes.hasHeightMap = materialSettings->GetOptionIndex("HasHeightMap"); @@ -44,7 +44,7 @@ namespace Nz m_phongOptionIndexes.hasSpecularMap = materialSettings->GetOptionIndex("HasSpecularMap"); m_basicTextureIndexes.alpha = materialSettings->GetTextureIndex("Alpha"); - m_basicTextureIndexes.diffuse = materialSettings->GetTextureIndex("Diffuse"); + m_basicTextureIndexes.baseColor = materialSettings->GetTextureIndex("BaseColor"); m_phongTextureIndexes.emissive = materialSettings->GetTextureIndex("Emissive"); m_phongTextureIndexes.height = materialSettings->GetTextureIndex("Height"); @@ -55,7 +55,7 @@ namespace Nz if (m_uniformBlockIndex != MaterialSettings::InvalidIndex) { m_basicUniformOffsets.alphaThreshold = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "AlphaThreshold"); - m_basicUniformOffsets.diffuseColor = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "DiffuseColor"); + m_basicUniformOffsets.baseColor = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "BaseColor"); m_phongUniformOffsets.ambientColor = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "AmbientColor"); m_phongUniformOffsets.shininess = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "Shininess"); @@ -64,7 +64,7 @@ namespace Nz else { m_basicUniformOffsets.alphaThreshold = MaterialSettings::InvalidIndex; - m_basicUniformOffsets.diffuseColor = MaterialSettings::InvalidIndex; + m_basicUniformOffsets.baseColor = MaterialSettings::InvalidIndex; m_phongUniformOffsets.ambientColor = MaterialSettings::InvalidIndex; m_phongUniformOffsets.shininess = MaterialSettings::InvalidIndex; @@ -121,16 +121,16 @@ namespace Nz AccessByOffset(bufferData.data(), m_phongUniformOffsets.shininess) = shininess; } - void PhongLightingMaterial::SetSpecularColor(const Color& diffuse) + void PhongLightingMaterial::SetSpecularColor(const Color& specular) { NazaraAssert(HasSpecularColor(), "Material has no specular color uniform"); std::vector& bufferData = GetMaterial().GetUniformBufferData(m_uniformBlockIndex); float* colorPtr = AccessByOffset(bufferData.data(), m_phongUniformOffsets.specularColor); - colorPtr[0] = diffuse.r; - colorPtr[1] = diffuse.g; - colorPtr[2] = diffuse.b; - colorPtr[3] = diffuse.a; + colorPtr[0] = specular.r; + colorPtr[1] = specular.g; + colorPtr[2] = specular.b; + colorPtr[3] = specular.a; } const std::shared_ptr& PhongLightingMaterial::GetSettings() diff --git a/src/Nazara/Graphics/PhysicallyBasedMaterial.cpp b/src/Nazara/Graphics/PhysicallyBasedMaterial.cpp index cb63ebf9d..5b3b47533 100644 --- a/src/Nazara/Graphics/PhysicallyBasedMaterial.cpp +++ b/src/Nazara/Graphics/PhysicallyBasedMaterial.cpp @@ -36,7 +36,7 @@ namespace Nz { m_basicOptionIndexes.alphaTest = materialSettings->GetOptionIndex("AlphaTest"); m_basicOptionIndexes.hasAlphaMap = materialSettings->GetOptionIndex("HasAlphaMap"); - m_basicOptionIndexes.hasDiffuseMap = materialSettings->GetOptionIndex("HasDiffuseMap"); + m_basicOptionIndexes.hasBaseColorMap = materialSettings->GetOptionIndex("HasBaseColorMap"); m_pbrOptionIndexes.hasEmissiveMap = materialSettings->GetOptionIndex("HasEmissiveMap"); m_pbrOptionIndexes.hasHeightMap = materialSettings->GetOptionIndex("HasHeightMap"); @@ -46,7 +46,7 @@ namespace Nz m_pbrOptionIndexes.hasSpecularMap = materialSettings->GetOptionIndex("HasSpecularMap"); m_basicTextureIndexes.alpha = materialSettings->GetTextureIndex("Alpha"); - m_basicTextureIndexes.diffuse = materialSettings->GetTextureIndex("Diffuse"); + m_basicTextureIndexes.baseColor = materialSettings->GetTextureIndex("BaseColor"); m_pbrTextureIndexes.emissive = materialSettings->GetTextureIndex("Emissive"); m_pbrTextureIndexes.height = materialSettings->GetTextureIndex("Height"); @@ -57,7 +57,7 @@ namespace Nz if (m_uniformBlockIndex != MaterialSettings::InvalidIndex) { m_basicUniformOffsets.alphaThreshold = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "AlphaThreshold"); - m_basicUniformOffsets.diffuseColor = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "DiffuseColor"); + m_basicUniformOffsets.baseColor = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "BaseColor"); m_pbrUniformOffsets.ambientColor = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "AmbientColor"); m_pbrUniformOffsets.shininess = materialSettings->GetUniformBlockVariableOffset(m_uniformBlockIndex, "Shininess"); @@ -66,7 +66,7 @@ namespace Nz else { m_basicUniformOffsets.alphaThreshold = MaterialSettings::InvalidIndex; - m_basicUniformOffsets.diffuseColor = MaterialSettings::InvalidIndex; + m_basicUniformOffsets.baseColor = MaterialSettings::InvalidIndex; m_pbrUniformOffsets.ambientColor = MaterialSettings::InvalidIndex; m_pbrUniformOffsets.shininess = MaterialSettings::InvalidIndex; @@ -123,7 +123,7 @@ namespace Nz AccessByOffset(bufferData.data(), m_pbrUniformOffsets.shininess) = shininess; } - void PhysicallyBasedMaterial::SetSpecularColor(const Color& diffuse) + void PhysicallyBasedMaterial::SetSpecularColor(const Color& specular) { NazaraAssert(HasSpecularColor(), "Material has no specular color uniform"); diff --git a/src/Nazara/Graphics/Resources/Shaders/BasicMaterial.nzsl b/src/Nazara/Graphics/Resources/Shaders/BasicMaterial.nzsl index f13c116fb..3fa01d4d4 100644 --- a/src/Nazara/Graphics/Resources/Shaders/BasicMaterial.nzsl +++ b/src/Nazara/Graphics/Resources/Shaders/BasicMaterial.nzsl @@ -4,7 +4,7 @@ module BasicMaterial; import InstanceData from Engine.InstanceData; import ViewerData from Engine.ViewerData; -option HasDiffuseTexture: bool = false; +option HasBaseColorTexture: bool = false; option HasAlphaTexture: bool = false; option AlphaTest: bool = false; @@ -27,13 +27,13 @@ const HasUV = (UvLocation >= 0); struct MaterialSettings { AlphaThreshold: f32, - DiffuseColor: vec4[f32] + BaseColor: vec4[f32] } external { [binding(0)] settings: uniform[MaterialSettings], - [binding(1)] MaterialDiffuseMap: sampler2D[f32], + [binding(1)] MaterialBaseColorMap: sampler2D[f32], [binding(2)] MaterialAlphaMap: sampler2D[f32], [binding(3)] TextureOverlay: sampler2D[f32], [binding(4)] instanceData: uniform[InstanceData], @@ -55,28 +55,28 @@ struct FragOut [entry(frag)] fn main(input: FragIn) -> FragOut { - let diffuseColor = settings.DiffuseColor; + let color = settings.BaseColor; const if (HasUV) - diffuseColor *= TextureOverlay.Sample(input.uv); + color *= TextureOverlay.Sample(input.uv); const if (HasColor) - diffuseColor *= input.color; + color *= input.color; - const if (HasDiffuseTexture) - diffuseColor *= MaterialDiffuseMap.Sample(input.uv); + const if (HasBaseColorTexture) + color *= MaterialBaseColorMap.Sample(input.uv); const if (HasAlphaTexture) - diffuseColor.w *= MaterialAlphaMap.Sample(input.uv).x; + color.w *= MaterialAlphaMap.Sample(input.uv).x; const if (AlphaTest) { - if (diffuseColor.w < settings.AlphaThreshold) + if (color.w < settings.AlphaThreshold) discard; } let output: FragOut; - output.RenderTarget0 = diffuseColor; + output.RenderTarget0 = color; return output; } diff --git a/src/Nazara/Graphics/Resources/Shaders/DepthMaterial.nzsl b/src/Nazara/Graphics/Resources/Shaders/DepthMaterial.nzsl index 9a56b6a7a..af1f62bb5 100644 --- a/src/Nazara/Graphics/Resources/Shaders/DepthMaterial.nzsl +++ b/src/Nazara/Graphics/Resources/Shaders/DepthMaterial.nzsl @@ -4,23 +4,23 @@ module DepthMaterial; import InstanceData from Engine.InstanceData; import ViewerData from Engine.ViewerData; -option HasDiffuseTexture: bool = false; +option HasBaseColorTexture: bool = false; option HasAlphaTexture: bool = false; option AlphaTest: bool = false; -const HasUV = AlphaTest && (HasDiffuseTexture || HasAlphaTexture); +const HasUV = AlphaTest && (HasBaseColorTexture || HasAlphaTexture); [layout(std140)] struct BasicSettings { AlphaThreshold: f32, - DiffuseColor: vec4[f32] + BaseColor: vec4[f32] } external { [binding(0)] settings: uniform[BasicSettings], - [binding(1)] MaterialDiffuseMap: sampler2D[f32], + [binding(1)] MaterialBaseColorMap: sampler2D[f32], [binding(2)] MaterialAlphaMap: sampler2D[f32], [binding(3)] TextureOverlay: sampler2D[f32], [binding(4)] instanceData: uniform[InstanceData], @@ -36,13 +36,13 @@ struct FragIn [entry(frag), cond(AlphaTest)] fn main(input: FragIn) { - let alpha = settings.DiffuseColor.a; + let alpha = settings.BaseColor.a; const if (HasUV) alpha *= TextureOverlay.Sample(input.uv).a; - const if (HasDiffuseTexture) - alpha *= MaterialDiffuseMap.Sample(input.uv).a; + const if (HasBaseColorTexture) + alpha *= MaterialBaseColorMap.Sample(input.uv).a; const if (HasAlphaTexture) alpha *= MaterialAlphaMap.Sample(input.uv).x; diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongMaterial.nzsl b/src/Nazara/Graphics/Resources/Shaders/PhongMaterial.nzsl index 937d7a274..d00cf7fcb 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongMaterial.nzsl +++ b/src/Nazara/Graphics/Resources/Shaders/PhongMaterial.nzsl @@ -6,7 +6,7 @@ import LightData from Engine.LightData; import ViewerData from Engine.ViewerData; // Basic material options -option HasDiffuseTexture: bool = false; +option HasBaseColorTexture: bool = false; option HasAlphaTexture: bool = false; option AlphaTest: bool = false; @@ -41,7 +41,7 @@ struct MaterialSettings { // BasicSettings AlphaThreshold: f32, - DiffuseColor: vec4[f32], + BaseColor: vec4[f32], // PhongSettings AmbientColor: vec3[f32], @@ -57,7 +57,7 @@ const SpotLight = 2; external { [binding(0)] settings: uniform[MaterialSettings], - [binding(1)] MaterialDiffuseMap: sampler2D[f32], + [binding(1)] MaterialBaseColorMap: sampler2D[f32], [binding(2)] MaterialAlphaMap: sampler2D[f32], [binding(3)] TextureOverlay: sampler2D[f32], [binding(4)] instanceData: uniform[InstanceData], @@ -88,23 +88,23 @@ struct FragOut [entry(frag)] fn main(input: VertToFrag) -> FragOut { - let diffuseColor = settings.DiffuseColor; + let color = settings.BaseColor; const if (HasUV) - diffuseColor *= TextureOverlay.Sample(input.uv); + color *= TextureOverlay.Sample(input.uv); const if (HasColor) - diffuseColor *= input.color; + color *= input.color; - const if (HasDiffuseTexture) - diffuseColor *= MaterialDiffuseMap.Sample(input.uv); + const if (HasBaseColorTexture) + color *= MaterialBaseColorMap.Sample(input.uv); const if (HasAlphaTexture) - diffuseColor.w *= MaterialAlphaMap.Sample(input.uv).x; + color.w *= MaterialAlphaMap.Sample(input.uv).x; const if (AlphaTest) { - if (diffuseColor.w < settings.AlphaThreshold) + if (color.w < settings.AlphaThreshold) discard; } @@ -216,13 +216,13 @@ fn main(input: VertToFrag) -> FragOut let lightColor = lightAmbient + lightDiffuse + lightSpecular; let output: FragOut; - output.RenderTarget0 = vec4[f32](lightColor, 1.0) * diffuseColor; + output.RenderTarget0 = vec4[f32](lightColor, 1.0) * color; return output; } else { let output: FragOut; - output.RenderTarget0 = diffuseColor; + output.RenderTarget0 = color; return output; } } diff --git a/src/Nazara/Graphics/Resources/Shaders/PhysicallyBasedMaterial.nzsl b/src/Nazara/Graphics/Resources/Shaders/PhysicallyBasedMaterial.nzsl index 899f8a01d..59d094c59 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhysicallyBasedMaterial.nzsl +++ b/src/Nazara/Graphics/Resources/Shaders/PhysicallyBasedMaterial.nzsl @@ -6,7 +6,7 @@ import LightData from Engine.LightData; import ViewerData from Engine.ViewerData; // Basic material options -option HasDiffuseTexture: bool = false; +option HasBaseColorTexture: bool = false; option HasAlphaTexture: bool = false; option AlphaTest: bool = false; @@ -43,7 +43,7 @@ struct MaterialSettings { // BasicSettings AlphaThreshold: f32, - DiffuseColor: vec4[f32], + BaseColor: vec4[f32], // PhongSettings AmbientColor: vec3[f32], @@ -59,7 +59,7 @@ const SpotLight = 2; external { [binding(0)] settings: uniform[MaterialSettings], - [binding(1)] MaterialDiffuseMap: sampler2D[f32], + [binding(1)] MaterialBaseColorMap: sampler2D[f32], [binding(2)] MaterialAlphaMap: sampler2D[f32], [binding(3)] TextureOverlay: sampler2D[f32], [binding(4)] instanceData: uniform[InstanceData], @@ -95,23 +95,23 @@ struct FragOut [entry(frag)] fn main(input: VertToFrag) -> FragOut { - let diffuseColor = settings.DiffuseColor; + let color = settings.BaseColor; const if (HasUV) - diffuseColor *= TextureOverlay.Sample(input.uv); + color *= TextureOverlay.Sample(input.uv); const if (HasColor) - diffuseColor *= input.color; + color *= input.color; - const if (HasDiffuseTexture) - diffuseColor *= MaterialDiffuseMap.Sample(input.uv); + const if (HasBaseColorTexture) + color *= MaterialBaseColorMap.Sample(input.uv); const if (HasAlphaTexture) - diffuseColor.w *= MaterialAlphaMap.Sample(input.uv).x; + color.w *= MaterialAlphaMap.Sample(input.uv).x; const if (AlphaTest) { - if (diffuseColor.w < settings.AlphaThreshold) + if (color.w < settings.AlphaThreshold) discard; } @@ -134,7 +134,7 @@ fn main(input: VertToFrag) -> FragOut else normal = normalize(input.normal); - let albedo = diffuseColor.xyz; + let albedo = color.xyz; let metallic: f32; let roughness: f32; @@ -211,7 +211,7 @@ fn main(input: VertToFrag) -> FragOut let ambient = (0.03).rrr * albedo; - let color = ambient + lightRadiance * diffuseColor.rgb; + let color = ambient + lightRadiance * color.rgb; color = color / (color + vec3[f32](1.0, 1.0, 1.0)); color = pow(color, (1.0 / 2.2).xxx); @@ -222,7 +222,7 @@ fn main(input: VertToFrag) -> FragOut else { let output: FragOut; - output.RenderTarget0 = diffuseColor; + output.RenderTarget0 = color; return output; } } diff --git a/src/Nazara/Graphics/SlicedSprite.cpp b/src/Nazara/Graphics/SlicedSprite.cpp index a961d477c..4cf485293 100644 --- a/src/Nazara/Graphics/SlicedSprite.cpp +++ b/src/Nazara/Graphics/SlicedSprite.cpp @@ -63,10 +63,10 @@ namespace Nz if (const auto& material = m_material->FindPass("ForwardPass")) { BasicMaterial mat(*material); - if (mat.HasDiffuseMap()) + if (mat.HasBaseColorMap()) { // Material should always have textures but we're better safe than sorry - if (const auto& texture = mat.GetDiffuseMap()) + if (const auto& texture = mat.GetBaseColorMap()) return texture->GetSize(); } } diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index bf346049c..325732314 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -67,10 +67,10 @@ namespace Nz if (const auto& material = m_material->FindPass("ForwardPass")) { BasicMaterial mat(*material); - if (mat.HasDiffuseMap()) + if (mat.HasBaseColorMap()) { // Material should always have textures but we're better safe than sorry - if (const auto& texture = mat.GetDiffuseMap()) + if (const auto& texture = mat.GetBaseColorMap()) return texture->GetSize(); } } diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index 5d04d98b9..c13e941a6 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -101,7 +101,7 @@ namespace Nz stream.Read(skin, 68*sizeof(char)); ParameterList matData; - matData.SetParameter(MaterialData::DiffuseTexturePath, (baseDir / skin).generic_u8string()); + matData.SetParameter(MaterialData::BaseColorTexturePath, (baseDir / skin).generic_u8string()); mesh->SetMaterialData(i, std::move(matData)); } diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index d26bf0ffa..cb2fa2f0e 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -78,14 +78,14 @@ namespace Nz float alphaValue = mtlMat->alpha; Color ambientColor(mtlMat->ambient); - Color diffuseColor(mtlMat->diffuse); + Color baseColor(mtlMat->diffuse); Color specularColor(mtlMat->specular); ambientColor.a = alphaValue; - diffuseColor.a = alphaValue; + baseColor.a = alphaValue; specularColor.a = alphaValue; data.SetParameter(MaterialData::AmbientColor, ambientColor); - data.SetParameter(MaterialData::DiffuseColor, diffuseColor); + data.SetParameter(MaterialData::BaseColor, baseColor); data.SetParameter(MaterialData::Shininess, mtlMat->shininess); data.SetParameter(MaterialData::SpecularColor, specularColor); @@ -104,7 +104,7 @@ namespace Nz if (!fullPath.is_absolute()) fullPath = baseDir / fullPath; - data.SetParameter(MaterialData::DiffuseTexturePath, fullPath.generic_u8string()); + data.SetParameter(MaterialData::BaseColorTexturePath, fullPath.generic_u8string()); } if (!mtlMat->emissiveMap.empty()) diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 3737aa590..a858b707e 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -123,7 +123,7 @@ namespace Nz if (matData.GetColorParameter(MaterialData::AmbientColor, &colorVal)) material->ambient = colorVal; - if (matData.GetColorParameter(MaterialData::DiffuseColor, &colorVal)) + if (matData.GetColorParameter(MaterialData::BaseColor, &colorVal)) material->diffuse = colorVal; if (matData.GetColorParameter(MaterialData::SpecularColor, &colorVal)) @@ -133,7 +133,7 @@ namespace Nz material->shininess = float(dValue); matData.GetStringParameter(MaterialData::AlphaTexturePath, &material->alphaMap); - matData.GetStringParameter(MaterialData::DiffuseTexturePath, &material->diffuseMap); + matData.GetStringParameter(MaterialData::BaseColorTexturePath, &material->diffuseMap); matData.GetStringParameter(MaterialData::SpecularTexturePath, &material->specularMap); } } diff --git a/src/Nazara/Widgets/DefaultWidgetTheme.cpp b/src/Nazara/Widgets/DefaultWidgetTheme.cpp index e08c79bf9..b6668933c 100644 --- a/src/Nazara/Widgets/DefaultWidgetTheme.cpp +++ b/src/Nazara/Widgets/DefaultWidgetTheme.cpp @@ -66,7 +66,7 @@ namespace Nz material->AddPass("ForwardPass", buttonMaterialPass); BasicMaterial buttonBasicMat(*buttonMaterialPass); - buttonBasicMat.SetDiffuseMap(texture); + buttonBasicMat.SetBaseColorMap(texture); return material; };