Merge fixes
This commit is contained in:
parent
d60fce169a
commit
a9801894e8
|
|
@ -91,7 +91,8 @@ int main()
|
||||||
|
|
||||||
Nz::MeshParams meshParams;
|
Nz::MeshParams meshParams;
|
||||||
meshParams.center = true;
|
meshParams.center = true;
|
||||||
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 0.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
|
meshParams.vertexRotation = Nz::EulerAnglesf(0.f, -90.f, 0.f);
|
||||||
|
meshParams.vertexScale = Nz::Vector3f(0.002f);
|
||||||
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
|
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
|
||||||
|
|
||||||
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ int main()
|
||||||
|
|
||||||
Nz::MeshParams meshParams;
|
Nz::MeshParams meshParams;
|
||||||
meshParams.center = true;
|
meshParams.center = true;
|
||||||
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, -90.f, 0.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
|
meshParams.vertexRotation = Nz::EulerAnglesf(0.f, -90.f, 0.f);
|
||||||
|
meshParams.vertexScale = Nz::Vector3f(0.002f);
|
||||||
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV_Tangent);
|
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV_Tangent);
|
||||||
|
|
||||||
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ int main()
|
||||||
|
|
||||||
Nz::MeshParams meshParams;
|
Nz::MeshParams meshParams;
|
||||||
meshParams.center = true;
|
meshParams.center = true;
|
||||||
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, -90.f, 0.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
|
meshParams.vertexRotation = Nz::EulerAnglesf(0.f, -90.f, 0.f);
|
||||||
|
meshParams.vertexScale = Nz::Vector3f(0.002f);
|
||||||
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV_Tangent);
|
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV_Tangent);
|
||||||
|
|
||||||
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,8 @@ int main()
|
||||||
|
|
||||||
Nz::MeshParams meshParams;
|
Nz::MeshParams meshParams;
|
||||||
meshParams.center = true;
|
meshParams.center = true;
|
||||||
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 0.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
|
meshParams.vertexRotation = Nz::EulerAnglesf(0.f, -90.f, 0.f);
|
||||||
|
meshParams.vertexScale = Nz::Vector3f(0.002f);
|
||||||
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV_Tangent);
|
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV_Tangent);
|
||||||
|
|
||||||
std::shared_ptr<Nz::Mesh> spaceshipMesh = Nz::Mesh::LoadFromFile(resourceDir / "Spaceship/spaceship.obj", meshParams);
|
std::shared_ptr<Nz::Mesh> spaceshipMesh = Nz::Mesh::LoadFromFile(resourceDir / "Spaceship/spaceship.obj", meshParams);
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,8 @@ int main()
|
||||||
Nz::MeshParams meshParams;
|
Nz::MeshParams meshParams;
|
||||||
meshParams.bufferFactory = Nz::GetRenderBufferFactory(device);
|
meshParams.bufferFactory = Nz::GetRenderBufferFactory(device);
|
||||||
meshParams.center = true;
|
meshParams.center = true;
|
||||||
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, -90.f, 0.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
|
meshParams.vertexRotation = Nz::EulerAnglesf(0.f, -90.f, 0.f);
|
||||||
|
meshParams.vertexScale = Nz::Vector3f(0.002f);
|
||||||
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
|
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
|
||||||
|
|
||||||
std::shared_ptr<Nz::Mesh> spaceship = Nz::Mesh::LoadFromFile(resourceDir / "Spaceship/spaceship.obj", meshParams);
|
std::shared_ptr<Nz::Mesh> spaceship = Nz::Mesh::LoadFromFile(resourceDir / "Spaceship/spaceship.obj", meshParams);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <Nazara/Core.hpp>
|
#include <Nazara/Core.hpp>
|
||||||
|
#include <Nazara/Core/Systems.hpp>
|
||||||
#include <Nazara/Platform.hpp>
|
#include <Nazara/Platform.hpp>
|
||||||
#include <Nazara/Graphics.hpp>
|
#include <Nazara/Graphics.hpp>
|
||||||
#include <Nazara/Graphics/TextSprite.hpp>
|
#include <Nazara/Graphics/TextSprite.hpp>
|
||||||
|
|
@ -9,11 +10,10 @@
|
||||||
#include <Nazara/Physics3D/Components.hpp>
|
#include <Nazara/Physics3D/Components.hpp>
|
||||||
#include <Nazara/Physics3D/Systems.hpp>
|
#include <Nazara/Physics3D/Systems.hpp>
|
||||||
#include <Nazara/Renderer.hpp>
|
#include <Nazara/Renderer.hpp>
|
||||||
#include <Nazara/Shader.hpp>
|
|
||||||
#include <Nazara/Shader/SpirvConstantCache.hpp>
|
|
||||||
#include <Nazara/Shader/SpirvPrinter.hpp>
|
|
||||||
#include <Nazara/Utility.hpp>
|
#include <Nazara/Utility.hpp>
|
||||||
#include <Nazara/Utility/Components.hpp>
|
#include <Nazara/Utility/Components.hpp>
|
||||||
|
#include <Nazara/Utils/CallOnExit.hpp>
|
||||||
|
#include <NZSL/Math/FieldOffsets.hpp>
|
||||||
#include <entt/entt.hpp>
|
#include <entt/entt.hpp>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -23,12 +23,12 @@ NAZARA_REQUEST_DEDICATED_GPU()
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::filesystem::path resourceDir = "resources";
|
std::filesystem::path resourceDir = "assets/examples";
|
||||||
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir))
|
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir))
|
||||||
resourceDir = ".." / resourceDir;
|
resourceDir = "../.." / resourceDir;
|
||||||
|
|
||||||
Nz::Renderer::Config rendererConfig;
|
Nz::Renderer::Config rendererConfig;
|
||||||
//rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;
|
rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;
|
||||||
|
|
||||||
Nz::Modules<Nz::Graphics> nazara(rendererConfig);
|
Nz::Modules<Nz::Graphics> nazara(rendererConfig);
|
||||||
|
|
||||||
|
|
@ -40,18 +40,14 @@ int main()
|
||||||
|
|
||||||
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
||||||
|
|
||||||
std::string windowTitle = "Skinning test";
|
|
||||||
Nz::RenderWindow window;
|
|
||||||
if (!window.Create(device, Nz::VideoMode(1280, 720, 32), windowTitle))
|
|
||||||
{
|
|
||||||
std::cout << "Failed to create Window" << std::endl;
|
|
||||||
return __LINE__;
|
|
||||||
}
|
|
||||||
|
|
||||||
entt::registry registry;
|
entt::registry registry;
|
||||||
|
Nz::SystemGraph systemGraph(registry);
|
||||||
|
|
||||||
Nz::Physics3DSystem physSytem(registry);
|
Nz::Physics3DSystem& physSytem = systemGraph.AddSystem<Nz::Physics3DSystem>();
|
||||||
Nz::RenderSystem renderSystem(registry);
|
Nz::RenderSystem& renderSystem = systemGraph.AddSystem<Nz::RenderSystem>();
|
||||||
|
|
||||||
|
std::string windowTitle = "Skinning test";
|
||||||
|
Nz::RenderWindow& window = renderSystem.CreateWindow(device, Nz::VideoMode(1280, 720, 32), windowTitle);
|
||||||
|
|
||||||
physSytem.GetPhysWorld().SetGravity({ 0.f, -9.81f, 0.f });
|
physSytem.GetPhysWorld().SetGravity({ 0.f, -9.81f, 0.f });
|
||||||
|
|
||||||
|
|
@ -82,8 +78,8 @@ int main()
|
||||||
cameraComponent.UpdateClearColor(Nz::Color(0.5f, 0.5f, 0.5f));
|
cameraComponent.UpdateClearColor(Nz::Color(0.5f, 0.5f, 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
Nz::FieldOffsets skeletalOffsets(Nz::StructLayout::Std140);
|
nzsl::FieldOffsets skeletalOffsets(nzsl::StructLayout::Std140);
|
||||||
std::size_t arrayOffset = skeletalOffsets.AddMatrixArray(Nz::StructFieldType::Float1, 4, 4, true, 200);
|
std::size_t arrayOffset = skeletalOffsets.AddMatrixArray(nzsl::StructFieldType::Float1, 4, 4, true, 200);
|
||||||
|
|
||||||
std::vector<Nz::UInt8> skeletalBufferMem(skeletalOffsets.GetAlignedSize());
|
std::vector<Nz::UInt8> skeletalBufferMem(skeletalOffsets.GetAlignedSize());
|
||||||
Nz::Matrix4f* matrices = Nz::AccessByOffset<Nz::Matrix4f*>(skeletalBufferMem.data(), arrayOffset);
|
Nz::Matrix4f* matrices = Nz::AccessByOffset<Nz::Matrix4f*>(skeletalBufferMem.data(), arrayOffset);
|
||||||
|
|
@ -143,14 +139,14 @@ int main()
|
||||||
std::shared_ptr<Nz::RenderBuffer> renderBuffer = device->InstantiateBuffer(Nz::BufferType::Uniform, skeletalBufferMem.size(), Nz::BufferUsage::Write, skeletalBufferMem.data());
|
std::shared_ptr<Nz::RenderBuffer> renderBuffer = device->InstantiateBuffer(Nz::BufferType::Uniform, skeletalBufferMem.size(), Nz::BufferUsage::Write, skeletalBufferMem.data());
|
||||||
|
|
||||||
const Nz::Boxf& bobAABB = bobMesh->GetAABB();
|
const Nz::Boxf& bobAABB = bobMesh->GetAABB();
|
||||||
std::shared_ptr<Nz::GraphicalMesh> bobGfxMesh = std::make_shared<Nz::GraphicalMesh>(*bobMesh);
|
std::shared_ptr<Nz::GraphicalMesh> bobGfxMesh = Nz::GraphicalMesh::BuildFromMesh(*bobMesh);
|
||||||
|
|
||||||
std::shared_ptr<Nz::Model> bobModel = std::make_shared<Nz::Model>(std::move(bobGfxMesh), bobAABB);
|
std::shared_ptr<Nz::Model> bobModel = std::make_shared<Nz::Model>(std::move(bobGfxMesh), bobAABB);
|
||||||
std::vector<std::shared_ptr<Nz::Material>> materials(bobMesh->GetMaterialCount());
|
std::vector<std::shared_ptr<Nz::Material>> materials(bobMesh->GetMaterialCount());
|
||||||
for (std::size_t i = 0; i < bobMesh->GetMaterialCount(); ++i)
|
for (std::size_t i = 0; i < bobMesh->GetMaterialCount(); ++i)
|
||||||
{
|
{
|
||||||
std::string matPath;
|
std::string matPath;
|
||||||
bobMesh->GetMaterialData(i).GetStringParameter(Nz::MaterialData::DiffuseTexturePath, &matPath);
|
bobMesh->GetMaterialData(i).GetStringParameter(Nz::MaterialData::BaseColorTexturePath, &matPath);
|
||||||
|
|
||||||
std::shared_ptr<Nz::Material> bobMat = std::make_shared<Nz::Material>();
|
std::shared_ptr<Nz::Material> bobMat = std::make_shared<Nz::Material>();
|
||||||
|
|
||||||
|
|
@ -175,7 +171,7 @@ int main()
|
||||||
bobMatPass->SetBlendFunc(Nz::BlendFunc::SrcAlpha, Nz::BlendFunc::InvSrcAlpha, Nz::BlendFunc::One, Nz::BlendFunc::Zero);
|
bobMatPass->SetBlendFunc(Nz::BlendFunc::SrcAlpha, Nz::BlendFunc::InvSrcAlpha, Nz::BlendFunc::One, Nz::BlendFunc::Zero);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
basicMat.SetDiffuseMap(Nz::Texture::LoadFromFile(path, texParams));
|
basicMat.SetBaseColorMap(Nz::Texture::LoadFromFile(path, texParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
bobMat->AddPass("ForwardPass", bobMatPass);
|
bobMat->AddPass("ForwardPass", bobMatPass);
|
||||||
|
|
@ -225,7 +221,7 @@ int main()
|
||||||
planeMesh.BuildSubMesh(Nz::Primitive::Plane(planeSize, Nz::Vector2ui(0u), Nz::Matrix4f::Identity(), Nz::Rectf(0.f, 0.f, 10.f, 10.f)), meshPrimitiveParams);
|
planeMesh.BuildSubMesh(Nz::Primitive::Plane(planeSize, Nz::Vector2ui(0u), Nz::Matrix4f::Identity(), Nz::Rectf(0.f, 0.f, 10.f, 10.f)), meshPrimitiveParams);
|
||||||
planeMesh.SetMaterialCount(1);
|
planeMesh.SetMaterialCount(1);
|
||||||
|
|
||||||
std::shared_ptr<Nz::GraphicalMesh> planeMeshGfx = std::make_shared<Nz::GraphicalMesh>(planeMesh);
|
std::shared_ptr<Nz::GraphicalMesh> planeMeshGfx = Nz::GraphicalMesh::BuildFromMesh(planeMesh);
|
||||||
|
|
||||||
std::shared_ptr<Nz::Material> planeMat = std::make_shared<Nz::Material>();
|
std::shared_ptr<Nz::Material> planeMat = std::make_shared<Nz::Material>();
|
||||||
|
|
||||||
|
|
@ -233,13 +229,13 @@ int main()
|
||||||
planeMatPass->EnableDepthBuffer(true);
|
planeMatPass->EnableDepthBuffer(true);
|
||||||
{
|
{
|
||||||
Nz::BasicMaterial basicMat(*planeMatPass);
|
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;
|
Nz::TextureSamplerInfo planeSampler;
|
||||||
planeSampler.anisotropyLevel = 16;
|
planeSampler.anisotropyLevel = 16;
|
||||||
planeSampler.wrapModeU = Nz::SamplerWrap::Repeat;
|
planeSampler.wrapModeU = Nz::SamplerWrap::Repeat;
|
||||||
planeSampler.wrapModeV = Nz::SamplerWrap::Repeat;
|
planeSampler.wrapModeV = Nz::SamplerWrap::Repeat;
|
||||||
basicMat.SetDiffuseSampler(planeSampler);
|
basicMat.SetBaseColorSampler(planeSampler);
|
||||||
}
|
}
|
||||||
planeMat->AddPass("ForwardPass", planeMatPass);
|
planeMat->AddPass("ForwardPass", planeMatPass);
|
||||||
|
|
||||||
|
|
@ -308,8 +304,6 @@ int main()
|
||||||
{
|
{
|
||||||
float updateTime = updateClock.Restart() / 1'000'000.f;
|
float updateTime = updateClock.Restart() / 1'000'000.f;
|
||||||
|
|
||||||
physSytem.Update(registry, 1.f / 60.f);
|
|
||||||
|
|
||||||
auto& playerBody = registry.get<Nz::RigidBody3DComponent>(playerEntity);
|
auto& playerBody = registry.get<Nz::RigidBody3DComponent>(playerEntity);
|
||||||
|
|
||||||
float mass = playerBody.GetMass();
|
float mass = playerBody.GetMass();
|
||||||
|
|
@ -414,7 +408,7 @@ int main()
|
||||||
builder.EndDebugRegion();
|
builder.EndDebugRegion();
|
||||||
}, Nz::QueueType::Graphics);
|
}, Nz::QueueType::Graphics);
|
||||||
|
|
||||||
renderSystem.Render(registry, frame);
|
systemGraph.Update();
|
||||||
|
|
||||||
frame.Present();
|
frame.Present();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -609,7 +609,10 @@ std::shared_ptr<Nz::SubMesh> ProcessSubMesh(const std::filesystem::path& originP
|
||||||
if (aiGetMaterialColor(aiMat, aiKey, aiType, aiIndex, &color) == aiReturn_SUCCESS)
|
if (aiGetMaterialColor(aiMat, aiKey, aiType, aiIndex, &color) == aiReturn_SUCCESS)
|
||||||
{
|
{
|
||||||
matData.SetParameter(colorKey, Nz::Color(color.r, color.g, color.b, color.a));
|
matData.SetParameter(colorKey, Nz::Color(color.r, color.g, color.b, color.a));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto SaveEmbeddedTextureToFile = [](const aiTexture* embeddedTexture, const std::filesystem::path& basePath, const char* filename) -> std::filesystem::path
|
auto SaveEmbeddedTextureToFile = [](const aiTexture* embeddedTexture, const std::filesystem::path& basePath, const char* filename) -> std::filesystem::path
|
||||||
|
|
@ -698,10 +701,10 @@ std::shared_ptr<Nz::SubMesh> ProcessSubMesh(const std::filesystem::path& originP
|
||||||
else
|
else
|
||||||
embeddedTexturePath = it->second;
|
embeddedTexturePath = it->second;
|
||||||
|
|
||||||
matData.SetParameter(textureKey, embeddedTexturePath.generic_u8string());
|
matData.SetParameter(textureKey, Nz::PathToString(embeddedTexturePath));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
matData.SetParameter(textureKey, (originPath / std::filesystem::u8path(path.data, path.data + path.length)).generic_u8string());
|
matData.SetParameter(textureKey, Nz::PathToString((originPath / std::filesystem::u8path(path.data, path.data + path.length))));
|
||||||
|
|
||||||
if (wrapKey)
|
if (wrapKey)
|
||||||
{
|
{
|
||||||
|
|
@ -728,19 +731,30 @@ std::shared_ptr<Nz::SubMesh> ProcessSubMesh(const std::filesystem::path& originP
|
||||||
|
|
||||||
matData.SetParameter(wrapKey, static_cast<long long>(wrap));
|
matData.SetParameter(wrapKey, static_cast<long long>(wrap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
ConvertColor(AI_MATKEY_COLOR_AMBIENT, Nz::MaterialData::AmbientColor);
|
ConvertColor(AI_MATKEY_COLOR_AMBIENT, Nz::MaterialData::AmbientColor);
|
||||||
ConvertColor(AI_MATKEY_COLOR_DIFFUSE, Nz::MaterialData::DiffuseColor);
|
|
||||||
|
if (!ConvertColor(AI_MATKEY_BASE_COLOR, Nz::MaterialData::BaseColor))
|
||||||
|
ConvertColor(AI_MATKEY_COLOR_DIFFUSE, Nz::MaterialData::BaseColor);
|
||||||
|
|
||||||
ConvertColor(AI_MATKEY_COLOR_SPECULAR, Nz::MaterialData::SpecularColor);
|
ConvertColor(AI_MATKEY_COLOR_SPECULAR, Nz::MaterialData::SpecularColor);
|
||||||
|
|
||||||
ConvertTexture(aiTextureType_DIFFUSE, Nz::MaterialData::DiffuseTexturePath, Nz::MaterialData::DiffuseWrap);
|
if (!ConvertTexture(aiTextureType_BASE_COLOR, Nz::MaterialData::BaseColorTexturePath, Nz::MaterialData::BaseColorWrap))
|
||||||
ConvertTexture(aiTextureType_EMISSIVE, Nz::MaterialData::EmissiveTexturePath);
|
ConvertTexture(aiTextureType_DIFFUSE, Nz::MaterialData::BaseColorTexturePath, Nz::MaterialData::BaseColorWrap);
|
||||||
ConvertTexture(aiTextureType_HEIGHT, Nz::MaterialData::HeightTexturePath);
|
|
||||||
ConvertTexture(aiTextureType_NORMALS, Nz::MaterialData::NormalTexturePath);
|
ConvertTexture(aiTextureType_DIFFUSE_ROUGHNESS, Nz::MaterialData::RoughnessTexturePath, Nz::MaterialData::RoughnessWrap);
|
||||||
ConvertTexture(aiTextureType_OPACITY, Nz::MaterialData::AlphaTexturePath);
|
ConvertTexture(aiTextureType_EMISSIVE, Nz::MaterialData::EmissiveTexturePath, Nz::MaterialData::EmissiveWrap);
|
||||||
ConvertTexture(aiTextureType_SPECULAR, Nz::MaterialData::SpecularTexturePath, Nz::MaterialData::SpecularWrap);
|
ConvertTexture(aiTextureType_HEIGHT, Nz::MaterialData::HeightTexturePath, Nz::MaterialData::HeightWrap);
|
||||||
|
ConvertTexture(aiTextureType_METALNESS, Nz::MaterialData::MetallicTexturePath, Nz::MaterialData::MetallicWrap);
|
||||||
|
ConvertTexture(aiTextureType_NORMALS, Nz::MaterialData::NormalTexturePath, Nz::MaterialData::NormalWrap);
|
||||||
|
ConvertTexture(aiTextureType_OPACITY, Nz::MaterialData::AlphaTexturePath, Nz::MaterialData::AlphaWrap);
|
||||||
|
ConvertTexture(aiTextureType_SPECULAR, Nz::MaterialData::SpecularTexturePath, Nz::MaterialData::SpecularWrap);
|
||||||
|
|
||||||
aiString name;
|
aiString name;
|
||||||
if (aiGetMaterialString(aiMat, AI_MATKEY_NAME, &name) == aiReturn_SUCCESS)
|
if (aiGetMaterialString(aiMat, AI_MATKEY_NAME, &name) == aiReturn_SUCCESS)
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ namespace Nz
|
||||||
options.pbrTextureIndexes->emissive = settings.textures.size();
|
options.pbrTextureIndexes->emissive = settings.textures.size();
|
||||||
|
|
||||||
settings.textures.push_back({
|
settings.textures.push_back({
|
||||||
7,
|
8,
|
||||||
"Emissive",
|
"Emissive",
|
||||||
ImageType::E2D
|
ImageType::E2D
|
||||||
});
|
});
|
||||||
|
|
@ -197,7 +197,7 @@ namespace Nz
|
||||||
options.pbrTextureIndexes->height = settings.textures.size();
|
options.pbrTextureIndexes->height = settings.textures.size();
|
||||||
|
|
||||||
settings.textures.push_back({
|
settings.textures.push_back({
|
||||||
8,
|
9,
|
||||||
"Height",
|
"Height",
|
||||||
ImageType::E2D
|
ImageType::E2D
|
||||||
});
|
});
|
||||||
|
|
@ -206,7 +206,7 @@ namespace Nz
|
||||||
options.pbrTextureIndexes->metallic = settings.textures.size();
|
options.pbrTextureIndexes->metallic = settings.textures.size();
|
||||||
|
|
||||||
settings.textures.push_back({
|
settings.textures.push_back({
|
||||||
9,
|
10,
|
||||||
"Metallic",
|
"Metallic",
|
||||||
ImageType::E2D
|
ImageType::E2D
|
||||||
});
|
});
|
||||||
|
|
@ -215,7 +215,7 @@ namespace Nz
|
||||||
options.pbrTextureIndexes->normal = settings.textures.size();
|
options.pbrTextureIndexes->normal = settings.textures.size();
|
||||||
|
|
||||||
settings.textures.push_back({
|
settings.textures.push_back({
|
||||||
10,
|
11,
|
||||||
"Normal",
|
"Normal",
|
||||||
ImageType::E2D
|
ImageType::E2D
|
||||||
});
|
});
|
||||||
|
|
@ -224,7 +224,7 @@ namespace Nz
|
||||||
options.pbrTextureIndexes->roughness = settings.textures.size();
|
options.pbrTextureIndexes->roughness = settings.textures.size();
|
||||||
|
|
||||||
settings.textures.push_back({
|
settings.textures.push_back({
|
||||||
11,
|
12,
|
||||||
"Roughness",
|
"Roughness",
|
||||||
ImageType::E2D
|
ImageType::E2D
|
||||||
});
|
});
|
||||||
|
|
@ -233,7 +233,7 @@ namespace Nz
|
||||||
options.pbrTextureIndexes->specular = settings.textures.size();
|
options.pbrTextureIndexes->specular = settings.textures.size();
|
||||||
|
|
||||||
settings.textures.push_back({
|
settings.textures.push_back({
|
||||||
12,
|
13,
|
||||||
"Specular",
|
"Specular",
|
||||||
ImageType::E2D
|
ImageType::E2D
|
||||||
});
|
});
|
||||||
|
|
@ -249,8 +249,8 @@ namespace Nz
|
||||||
options.defaultValues
|
options.defaultValues
|
||||||
});
|
});
|
||||||
|
|
||||||
settings.sharedUniformBlocks.push_back(PredefinedLightData::GetUniformBlock(6, nzsl::ShaderStageType::Fragment));
|
settings.sharedUniformBlocks.push_back(PredefinedLightData::GetUniformBlock(7, nzsl::ShaderStageType::Fragment));
|
||||||
settings.predefinedBindings[UnderlyingCast(PredefinedShaderBinding::LightDataUbo)] = 6;
|
settings.predefinedBindings[UnderlyingCast(PredefinedShaderBinding::LightDataUbo)] = 7;
|
||||||
|
|
||||||
settings.shaders = options.shaders;
|
settings.shaders = options.shaders;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
module BasicMaterial;
|
module BasicMaterial;
|
||||||
|
|
||||||
import InstanceData from Engine.InstanceData;
|
import InstanceData from Engine.InstanceData;
|
||||||
|
import SkeletalData from Engine.SkeletalData;
|
||||||
import ViewerData from Engine.ViewerData;
|
import ViewerData from Engine.ViewerData;
|
||||||
|
|
||||||
option HasBaseColorTexture: bool = false;
|
option HasBaseColorTexture: bool = false;
|
||||||
|
|
@ -34,14 +35,6 @@ struct MaterialSettings
|
||||||
BaseColor: vec4[f32]
|
BaseColor: vec4[f32]
|
||||||
}
|
}
|
||||||
|
|
||||||
const MaxJointCount: u32 = u32(200); //< FIXME: Fix integral value types
|
|
||||||
|
|
||||||
[layout(std140)]
|
|
||||||
struct SkeletalData
|
|
||||||
{
|
|
||||||
JointMatrices: array[mat4[f32], MaxJointCount]
|
|
||||||
}
|
|
||||||
|
|
||||||
external
|
external
|
||||||
{
|
{
|
||||||
[binding(0)] settings: uniform[MaterialSettings],
|
[binding(0)] settings: uniform[MaterialSettings],
|
||||||
|
|
@ -163,7 +156,7 @@ fn billboardMain(input: VertIn) -> VertOut
|
||||||
fn main(input: VertIn) -> VertOut
|
fn main(input: VertIn) -> VertOut
|
||||||
{
|
{
|
||||||
let pos: vec3[f32];
|
let pos: vec3[f32];
|
||||||
const if (HasSkinning)
|
const if (HasSkinning && false)
|
||||||
{
|
{
|
||||||
pos = vec3[f32](0.0, 0.0, 0.0);
|
pos = vec3[f32](0.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
[nzsl_version("1.0")]
|
||||||
|
module Engine.SkeletalData;
|
||||||
|
|
||||||
|
const MaxJointCount: u32 = u32(200); //< FIXME: Fix integral value types
|
||||||
|
|
||||||
|
[export]
|
||||||
|
[layout(std140)]
|
||||||
|
struct SkeletalData
|
||||||
|
{
|
||||||
|
JointMatrices: array[mat4[f32], MaxJointCount]
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ module PhongMaterial;
|
||||||
|
|
||||||
import InstanceData from Engine.InstanceData;
|
import InstanceData from Engine.InstanceData;
|
||||||
import LightData from Engine.LightData;
|
import LightData from Engine.LightData;
|
||||||
|
import SkeletalData from Engine.SkeletalData;
|
||||||
import ViewerData from Engine.ViewerData;
|
import ViewerData from Engine.ViewerData;
|
||||||
|
|
||||||
// Basic material options
|
// Basic material options
|
||||||
|
|
@ -62,6 +63,7 @@ external
|
||||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||||
[binding(4)] instanceData: uniform[InstanceData],
|
[binding(4)] instanceData: uniform[InstanceData],
|
||||||
[binding(5)] viewerData: uniform[ViewerData],
|
[binding(5)] viewerData: uniform[ViewerData],
|
||||||
|
[binding(6)] skeletalData: uniform[SkeletalData],
|
||||||
[binding(7)] lightData: uniform[LightData],
|
[binding(7)] lightData: uniform[LightData],
|
||||||
[binding(8)] MaterialEmissiveMap: sampler2D[f32],
|
[binding(8)] MaterialEmissiveMap: sampler2D[f32],
|
||||||
[binding(9)] MaterialHeightMap: sampler2D[f32],
|
[binding(9)] MaterialHeightMap: sampler2D[f32],
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ module PhysicallyBasedMaterial;
|
||||||
|
|
||||||
import InstanceData from Engine.InstanceData;
|
import InstanceData from Engine.InstanceData;
|
||||||
import LightData from Engine.LightData;
|
import LightData from Engine.LightData;
|
||||||
|
import SkeletalData from Engine.SkeletalData;
|
||||||
import ViewerData from Engine.ViewerData;
|
import ViewerData from Engine.ViewerData;
|
||||||
|
|
||||||
// Basic material options
|
// Basic material options
|
||||||
|
|
@ -64,13 +65,14 @@ external
|
||||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||||
[binding(4)] instanceData: uniform[InstanceData],
|
[binding(4)] instanceData: uniform[InstanceData],
|
||||||
[binding(5)] viewerData: uniform[ViewerData],
|
[binding(5)] viewerData: uniform[ViewerData],
|
||||||
[binding(6)] lightData: uniform[LightData],
|
[binding(6)] skeletalData: uniform[SkeletalData],
|
||||||
[binding(7)] MaterialEmissiveMap: sampler2D[f32],
|
[binding(7)] lightData: uniform[LightData],
|
||||||
[binding(8)] MaterialHeightMap: sampler2D[f32],
|
[binding(8)] MaterialEmissiveMap: sampler2D[f32],
|
||||||
[binding(9)] MaterialMetallicMap: sampler2D[f32],
|
[binding(9)] MaterialHeightMap: sampler2D[f32],
|
||||||
[binding(10)] MaterialNormalMap: sampler2D[f32],
|
[binding(10)] MaterialMetallicMap: sampler2D[f32],
|
||||||
[binding(11)] MaterialRoughnessMap: sampler2D[f32],
|
[binding(11)] MaterialNormalMap: sampler2D[f32],
|
||||||
[binding(12)] MaterialSpecularMap: sampler2D[f32],
|
[binding(12)] MaterialRoughnessMap: sampler2D[f32],
|
||||||
|
[binding(13)] MaterialSpecularMap: sampler2D[f32],
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VertToFrag
|
struct VertToFrag
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ namespace Nz
|
||||||
|
|
||||||
// Material
|
// Material
|
||||||
ParameterList matData;
|
ParameterList matData;
|
||||||
matData.SetParameter(MaterialData::DiffuseTexturePath, (baseDir / md5Mesh.shader).generic_u8string());
|
matData.SetParameter(MaterialData::BaseColorTexturePath, (baseDir / md5Mesh.shader).generic_u8string());
|
||||||
|
|
||||||
mesh->SetMaterialData(i, std::move(matData));
|
mesh->SetMaterialData(i, std::move(matData));
|
||||||
|
|
||||||
|
|
@ -341,7 +341,7 @@ namespace Nz
|
||||||
|
|
||||||
// Material
|
// Material
|
||||||
ParameterList matData;
|
ParameterList matData;
|
||||||
matData.SetParameter(MaterialData::DiffuseTexturePath, (baseDir / md5Mesh.shader).generic_u8string());
|
matData.SetParameter(MaterialData::BaseColorTexturePath, (baseDir / md5Mesh.shader).generic_u8string());
|
||||||
|
|
||||||
mesh->SetMaterialData(i, std::move(matData));
|
mesh->SetMaterialData(i, std::move(matData));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue