Refactor material system (#382)

This commit is contained in:
Jérôme Leclercq
2022-10-31 19:53:41 +01:00
committed by GitHub
parent 0a8048809c
commit dc6ce8427c
156 changed files with 3633 additions and 4569 deletions

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_GRAPHICS_PROPERTYHANDLER_OPTIONVALUEPROPERTYHANDLER_HPP
#define NAZARA_GRAPHICS_PROPERTYHANDLER_OPTIONVALUEPROPERTYHANDLER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/PropertyHandler/PropertyHandler.hpp>
namespace Nz
{
class NAZARA_GRAPHICS_API OptionValuePropertyHandler : public PropertyHandler
{
public:
inline OptionValuePropertyHandler(std::string propertyName, std::string optionName);
OptionValuePropertyHandler(const OptionValuePropertyHandler&) = default;
OptionValuePropertyHandler(OptionValuePropertyHandler&&) = delete;
~OptionValuePropertyHandler() = default;
bool NeedsUpdateOnValueUpdate(std::size_t updatedPropertyIndex) const override;
void Setup(const Material& material, const ShaderReflection& reflection) override;
void Update(MaterialInstance& materialInstance) const override;
OptionValuePropertyHandler& operator=(const OptionValuePropertyHandler&) = delete;
OptionValuePropertyHandler& operator=(OptionValuePropertyHandler&&) = delete;
private:
std::size_t m_propertyIndex;
std::string m_propertyName;
std::string m_optionName;
UInt32 m_optionHash;
};
}
#include <Nazara/Graphics/PropertyHandler/OptionValuePropertyHandler.inl>
#endif // NAZARA_GRAPHICS_PROPERTYHANDLER_OPTIONVALUEPROPERTYHANDLER_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/PropertyHandler/OptionValuePropertyHandler.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
inline OptionValuePropertyHandler::OptionValuePropertyHandler(std::string propertyName, std::string optionName) :
m_propertyName(std::move(propertyName)),
m_optionName(std::move(optionName))
{
}
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -0,0 +1,54 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_GRAPHICS_PROPERTYHANDLER_PROPERTYHANDLER_HPP
#define NAZARA_GRAPHICS_PROPERTYHANDLER_PROPERTYHANDLER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Enums.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <NZSL/Enums.hpp>
namespace Nz
{
class Material;
class MaterialInstance;
class ShaderReflection;
class NAZARA_GRAPHICS_API PropertyHandler
{
public:
PropertyHandler() = default;
PropertyHandler(const PropertyHandler&) = delete;
PropertyHandler(PropertyHandler&&) = delete;
virtual ~PropertyHandler();
virtual bool NeedsUpdateOnTextureUpdate(std::size_t updatedTexturePropertyIndex) const;
virtual bool NeedsUpdateOnValueUpdate(std::size_t updatedValuePropertyIndex) const;
virtual void Setup(const Material& material, const ShaderReflection& reflection) = 0;
virtual void Update(MaterialInstance& materialInstance) const = 0;
PropertyHandler& operator=(const PropertyHandler&) = delete;
PropertyHandler& operator=(PropertyHandler&&) = delete;
struct SamplerData
{
std::size_t textureIndex;
};
struct UniformValue
{
std::size_t uniformBufferIndex;
std::size_t offset;
};
};
}
#include <Nazara/Graphics/PropertyHandler/PropertyHandler.inl>
#endif // NAZARA_GRAPHICS_PROPERTYHANDLER_PROPERTYHANDLER_HPP

View File

@@ -0,0 +1,13 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/PropertyHandler/PropertyHandler.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -0,0 +1,48 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_GRAPHICS_PROPERTYHANDLER_TEXTUREPROPERTYHANDLER_HPP
#define NAZARA_GRAPHICS_PROPERTYHANDLER_TEXTUREPROPERTYHANDLER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/PropertyHandler/PropertyHandler.hpp>
#include <string>
namespace Nz
{
class NAZARA_GRAPHICS_API TexturePropertyHandler : public PropertyHandler
{
public:
inline TexturePropertyHandler(std::string propertyName);
inline TexturePropertyHandler(std::string propertyName, std::string optionName);
inline TexturePropertyHandler(std::string propertyName, std::string samplerTag, std::string optionName);
TexturePropertyHandler(const TexturePropertyHandler&) = delete;
TexturePropertyHandler(TexturePropertyHandler&&) = delete;
~TexturePropertyHandler() = default;
bool NeedsUpdateOnTextureUpdate(std::size_t updatedPropertyIndex) const override;
void Setup(const Material& material, const ShaderReflection& reflection) override;
void Update(MaterialInstance& materialInstance) const override;
TexturePropertyHandler& operator=(const TexturePropertyHandler&) = delete;
TexturePropertyHandler& operator=(TexturePropertyHandler&&) = delete;
private:
std::size_t m_propertyIndex;
std::size_t m_textureIndex;
std::string m_optionName;
std::string m_propertyName;
std::string m_samplerTag;
UInt32 m_optionHash;
};
}
#include <Nazara/Graphics/PropertyHandler/TexturePropertyHandler.inl>
#endif // NAZARA_GRAPHICS_PROPERTYHANDLER_TEXTUREPROPERTYHANDLER_HPP

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/PropertyHandler/TexturePropertyHandler.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
inline TexturePropertyHandler::TexturePropertyHandler(std::string propertyName) :
m_propertyName(std::move(propertyName)),
m_samplerTag(m_propertyName)
{
}
inline TexturePropertyHandler::TexturePropertyHandler(std::string propertyName, std::string optionName) :
m_optionName(std::move(optionName)),
m_propertyName(std::move(propertyName)),
m_samplerTag(m_propertyName)
{
}
inline TexturePropertyHandler::TexturePropertyHandler(std::string propertyName, std::string samplerTag, std::string optionName) :
m_optionName(std::move(optionName)),
m_propertyName(std::move(propertyName)),
m_samplerTag(std::move(samplerTag))
{
}
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -0,0 +1,47 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_GRAPHICS_PROPERTYHANDLER_UNIFORMVALUEPROPERTYHANDLER_HPP
#define NAZARA_GRAPHICS_PROPERTYHANDLER_UNIFORMVALUEPROPERTYHANDLER_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/PropertyHandler/PropertyHandler.hpp>
namespace Nz
{
class NAZARA_GRAPHICS_API UniformValuePropertyHandler : public PropertyHandler
{
public:
inline UniformValuePropertyHandler(std::string propertyName, std::string blockTag = "Settings");
inline UniformValuePropertyHandler(std::string propertyName, std::string memberTag, std::string blockTag = "Settings");
UniformValuePropertyHandler(const UniformValuePropertyHandler&) = delete;
UniformValuePropertyHandler(UniformValuePropertyHandler&&) = delete;
~UniformValuePropertyHandler() = default;
bool NeedsUpdateOnValueUpdate(std::size_t updatedPropertyIndex) const override;
void Setup(const Material& material, const ShaderReflection& reflection) override;
void Update(MaterialInstance& materialInstance) const override;
UniformValuePropertyHandler& operator=(const UniformValuePropertyHandler&) = delete;
UniformValuePropertyHandler& operator=(UniformValuePropertyHandler&&) = delete;
private:
std::size_t m_propertyIndex;
std::size_t m_offset;
std::size_t m_size;
std::size_t m_uniformBlockIndex;
std::string m_blockTag;
std::string m_propertyName;
std::string m_memberTag;
};
}
#include <Nazara/Graphics/PropertyHandler/UniformValuePropertyHandler.inl>
#endif // NAZARA_GRAPHICS_PROPERTYHANDLER_UNIFORMVALUEPROPERTYHANDLER_HPP

View File

@@ -0,0 +1,25 @@
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/PropertyHandler/UniformValuePropertyHandler.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
inline UniformValuePropertyHandler::UniformValuePropertyHandler(std::string propertyName, std::string blockTag) :
m_blockTag(std::move(blockTag)),
m_propertyName(std::move(propertyName)),
m_memberTag(m_propertyName)
{
}
inline UniformValuePropertyHandler::UniformValuePropertyHandler(std::string propertyName, std::string memberTag, std::string blockTag) :
m_blockTag(std::move(blockTag)),
m_propertyName(std::move(propertyName)),
m_memberTag(std::move(memberTag))
{
}
}
#include <Nazara/Graphics/DebugOff.hpp>