Formatted EVERYTHING
This commit is contained in:
@@ -1,60 +1,35 @@
|
||||
#include "Material.h"
|
||||
#include "Graphics/Enums.h"
|
||||
#include "Serialization/Serialization.h"
|
||||
#include "Window/WindowManager.h"
|
||||
#include "MaterialInstance.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Shader.h"
|
||||
#include "MaterialInstance.h"
|
||||
#include "Serialization/Serialization.h"
|
||||
#include "Window/WindowManager.h"
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
std::atomic_uint64_t Material::materialIdCounter = 0;
|
||||
Array<PMaterial> Material::materials;
|
||||
|
||||
Material::Material()
|
||||
{
|
||||
}
|
||||
Material::Material() {}
|
||||
|
||||
Material::Material(Gfx::PGraphics graphics,
|
||||
Gfx::ODescriptorLayout layout,
|
||||
uint32 uniformDataSize,
|
||||
uint32 uniformBinding,
|
||||
std::string materialName,
|
||||
Array<OShaderExpression> expressions,
|
||||
Array<std::string> parameter,
|
||||
MaterialNode brdf)
|
||||
: graphics(graphics)
|
||||
, uniformDataSize(uniformDataSize)
|
||||
, uniformBinding(uniformBinding)
|
||||
, instanceId(0)
|
||||
, layout(std::move(layout))
|
||||
, materialName(materialName)
|
||||
, codeExpressions(std::move(expressions))
|
||||
, parameters(std::move(parameter))
|
||||
, brdf(std::move(brdf))
|
||||
, materialId(materialIdCounter++)
|
||||
{
|
||||
Material::Material(Gfx::PGraphics graphics, Gfx::ODescriptorLayout layout, uint32 uniformDataSize, uint32 uniformBinding,
|
||||
std::string materialName, Array<OShaderExpression> expressions, Array<std::string> parameter, MaterialNode brdf)
|
||||
: graphics(graphics), uniformDataSize(uniformDataSize), uniformBinding(uniformBinding), instanceId(0), layout(std::move(layout)),
|
||||
materialName(materialName), codeExpressions(std::move(expressions)), parameters(std::move(parameter)), brdf(std::move(brdf)),
|
||||
materialId(materialIdCounter++) {
|
||||
materials.add(this);
|
||||
}
|
||||
|
||||
Material::~Material()
|
||||
{
|
||||
Material::~Material() {}
|
||||
|
||||
OMaterialInstance Material::instantiate() {
|
||||
return new MaterialInstance(instanceId++, graphics, codeExpressions, parameters, uniformBinding, uniformDataSize);
|
||||
}
|
||||
|
||||
OMaterialInstance Material::instantiate()
|
||||
{
|
||||
return new MaterialInstance(
|
||||
instanceId++,
|
||||
graphics,
|
||||
codeExpressions,
|
||||
parameters,
|
||||
uniformBinding,
|
||||
uniformDataSize);
|
||||
}
|
||||
|
||||
void Material::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void Material::save(ArchiveBuffer& buffer) const {
|
||||
Serialization::save(buffer, uniformDataSize);
|
||||
Serialization::save(buffer, uniformBinding);
|
||||
Serialization::save(buffer, instanceId);
|
||||
@@ -65,8 +40,7 @@ void Material::save(ArchiveBuffer& buffer) const
|
||||
Serialization::save(buffer, layout->getName());
|
||||
const auto& bindings = layout->getBindings();
|
||||
Serialization::save(buffer, bindings.size());
|
||||
for (const auto& binding : bindings)
|
||||
{
|
||||
for (const auto& binding : bindings) {
|
||||
Serialization::save(buffer, binding.binding);
|
||||
Serialization::save(buffer, binding.descriptorType);
|
||||
Serialization::save(buffer, binding.textureType);
|
||||
@@ -76,8 +50,7 @@ void Material::save(ArchiveBuffer& buffer) const
|
||||
}
|
||||
}
|
||||
|
||||
void Material::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void Material::load(ArchiveBuffer& buffer) {
|
||||
graphics = buffer.getGraphics();
|
||||
Serialization::load(buffer, uniformDataSize);
|
||||
Serialization::load(buffer, uniformBinding);
|
||||
@@ -91,8 +64,7 @@ void Material::load(ArchiveBuffer& buffer)
|
||||
uint64 numBindings;
|
||||
Serialization::load(buffer, numBindings);
|
||||
layout = graphics->createDescriptorLayout(descriptorName);
|
||||
for (uint64 i = 0; i < numBindings; ++i)
|
||||
{
|
||||
for (uint64 i = 0; i < numBindings; ++i) {
|
||||
uint32 binding;
|
||||
Serialization::load(buffer, binding);
|
||||
|
||||
@@ -111,21 +83,27 @@ void Material::load(ArchiveBuffer& buffer)
|
||||
Gfx::SeShaderStageFlags shaderStages;
|
||||
Serialization::load(buffer, shaderStages);
|
||||
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = binding, .descriptorType = descriptorType, .textureType = textureType, .descriptorCount = descriptorCount, .bindingFlags = bindingFlags, .shaderStages = shaderStages,});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = binding,
|
||||
.descriptorType = descriptorType,
|
||||
.textureType = textureType,
|
||||
.descriptorCount = descriptorCount,
|
||||
.bindingFlags = bindingFlags,
|
||||
.shaderStages = shaderStages,
|
||||
});
|
||||
}
|
||||
layout->create();
|
||||
materialId = materialIdCounter++;
|
||||
}
|
||||
|
||||
void Material::compile()
|
||||
{
|
||||
std::ofstream codeStream("./shaders/generated/"+materialName+".slang");
|
||||
void Material::compile() {
|
||||
std::ofstream codeStream("./shaders/generated/" + materialName + ".slang");
|
||||
codeStream << "import BRDF;\n";
|
||||
codeStream << "import MaterialParameter;\n";
|
||||
codeStream << "struct " << materialName << "{\n";
|
||||
for(const auto& parameter : parameters)
|
||||
{
|
||||
PShaderParameter handle = PShaderExpression(*codeExpressions.find([¶meter](const OShaderExpression& exp) {return exp->key == parameter; }));
|
||||
for (const auto& parameter : parameters) {
|
||||
PShaderParameter handle =
|
||||
PShaderExpression(*codeExpressions.find([¶meter](const OShaderExpression& exp) { return exp->key == parameter; }));
|
||||
handle->generateDeclaration(codeStream);
|
||||
}
|
||||
codeStream << "\ttypedef " << brdf.profile << " BRDF;\n";
|
||||
@@ -133,12 +111,10 @@ void Material::compile()
|
||||
codeStream << "\t\t" << brdf.profile << " result;\n";
|
||||
Map<std::string, std::string> varState;
|
||||
// initialize variable state
|
||||
for(const auto& expr :codeExpressions)
|
||||
{
|
||||
for (const auto& expr : codeExpressions) {
|
||||
codeStream << "\t\t" << expr->evaluate(varState);
|
||||
}
|
||||
for(const auto& [name, exp] : brdf.variables)
|
||||
{
|
||||
for (const auto& [name, exp] : brdf.variables) {
|
||||
codeStream << "\t\tresult." << name << " = " << varState[exp] << ";" << std::endl;
|
||||
}
|
||||
codeStream << "\t\treturn result;\n";
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
#pragma once
|
||||
#include "ShaderExpression.h"
|
||||
#include "Graphics/Descriptor.h"
|
||||
#include "ShaderExpression.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
|
||||
namespace Seele {
|
||||
DECLARE_REF(MaterialInstance)
|
||||
class Material
|
||||
{
|
||||
public:
|
||||
class Material {
|
||||
public:
|
||||
Material();
|
||||
Material(Gfx::PGraphics graphics,
|
||||
Gfx::ODescriptorLayout layout,
|
||||
uint32 uniformDataSize,
|
||||
uint32 uniformBinding,
|
||||
std::string materialName,
|
||||
Array<OShaderExpression> expressions,
|
||||
Array<std::string> parameter,
|
||||
MaterialNode brdf);
|
||||
Material(Gfx::PGraphics graphics, Gfx::ODescriptorLayout layout, uint32 uniformDataSize, uint32 uniformBinding,
|
||||
std::string materialName, Array<OShaderExpression> expressions, Array<std::string> parameter, MaterialNode brdf);
|
||||
~Material();
|
||||
const Gfx::PDescriptorLayout getDescriptorLayout() const { return layout; }
|
||||
Gfx::PDescriptorLayout getDescriptorLayout() { return layout; }
|
||||
@@ -30,7 +23,7 @@ public:
|
||||
|
||||
void compile();
|
||||
|
||||
private:
|
||||
private:
|
||||
Gfx::PGraphics graphics;
|
||||
uint32 uniformDataSize;
|
||||
uint32 uniformBinding;
|
||||
|
||||
@@ -1,40 +1,30 @@
|
||||
#include "MaterialInstance.h"
|
||||
#include "Material.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Material.h"
|
||||
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
MaterialInstance::MaterialInstance()
|
||||
{
|
||||
}
|
||||
MaterialInstance::MaterialInstance() {}
|
||||
|
||||
MaterialInstance::MaterialInstance(uint64 id,
|
||||
Gfx::PGraphics graphics,
|
||||
Array<OShaderExpression>& expressions,
|
||||
Array<std::string> params,
|
||||
uint32 uniformBinding,
|
||||
uint32 uniformSize)
|
||||
: graphics(graphics)
|
||||
, uniformBinding(uniformBinding)
|
||||
, id(id)
|
||||
{
|
||||
if(uniformSize > 0)
|
||||
{
|
||||
MaterialInstance::MaterialInstance(uint64 id, Gfx::PGraphics graphics, Array<OShaderExpression>& expressions, Array<std::string> params,
|
||||
uint32 uniformBinding, uint32 uniformSize)
|
||||
: graphics(graphics), uniformBinding(uniformBinding), id(id) {
|
||||
if (uniformSize > 0) {
|
||||
uniformBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData = {
|
||||
.sourceData =
|
||||
{
|
||||
.size = uniformSize,
|
||||
},
|
||||
.dynamic = true,
|
||||
}
|
||||
);
|
||||
.dynamic = true,
|
||||
});
|
||||
}
|
||||
uniformData.resize(uniformSize);
|
||||
ArchiveBuffer buffer(graphics);
|
||||
parameters.reserve(params.size());
|
||||
for (size_t i = 0; i < params.size(); ++i)
|
||||
{
|
||||
for (size_t i = 0; i < params.size(); ++i) {
|
||||
const std::string& name = params[i];
|
||||
Serialization::save(buffer, *expressions.find([&name](const OShaderExpression& p) {return p->key == name; }));
|
||||
Serialization::save(buffer, *expressions.find([&name](const OShaderExpression& p) { return p->key == name; }));
|
||||
buffer.rewind();
|
||||
OShaderParameter param;
|
||||
Serialization::load(buffer, param);
|
||||
@@ -43,21 +33,15 @@ MaterialInstance::MaterialInstance(uint64 id,
|
||||
}
|
||||
}
|
||||
|
||||
MaterialInstance::~MaterialInstance()
|
||||
{
|
||||
|
||||
}
|
||||
MaterialInstance::~MaterialInstance() {}
|
||||
|
||||
void MaterialInstance::updateDescriptor()
|
||||
{
|
||||
void MaterialInstance::updateDescriptor() {
|
||||
Gfx::PDescriptorLayout layout = baseMaterial->getMaterial()->getDescriptorLayout();
|
||||
descriptor = layout->allocateDescriptorSet();
|
||||
for (auto& param : parameters)
|
||||
{
|
||||
for (auto& param : parameters) {
|
||||
param->updateDescriptorSet(descriptor, uniformData.data());
|
||||
}
|
||||
if(uniformData.size() > 0)
|
||||
{
|
||||
if (uniformData.size() > 0) {
|
||||
uniformBuffer->updateContents(DataSource{
|
||||
.size = uniformData.size(),
|
||||
.data = uniformData.data(),
|
||||
@@ -67,36 +51,29 @@ void MaterialInstance::updateDescriptor()
|
||||
descriptor->writeChanges();
|
||||
}
|
||||
|
||||
Gfx::PDescriptorSet MaterialInstance::getDescriptorSet() const
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
Gfx::PDescriptorSet MaterialInstance::getDescriptorSet() const { return descriptor; }
|
||||
|
||||
void MaterialInstance::setBaseMaterial(PMaterialAsset asset)
|
||||
{
|
||||
if(uniformData.size() > 0)
|
||||
{
|
||||
void MaterialInstance::setBaseMaterial(PMaterialAsset asset) {
|
||||
if (uniformData.size() > 0) {
|
||||
uniformBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData = {
|
||||
.sourceData =
|
||||
{
|
||||
.size = uniformData.size(),
|
||||
},
|
||||
.dynamic = true,
|
||||
}
|
||||
);
|
||||
.dynamic = true,
|
||||
});
|
||||
}
|
||||
baseMaterial = asset;
|
||||
}
|
||||
|
||||
void MaterialInstance::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void MaterialInstance::save(ArchiveBuffer& buffer) const {
|
||||
Serialization::save(buffer, uniformData);
|
||||
Serialization::save(buffer, uniformBinding);
|
||||
Serialization::save(buffer, parameters);
|
||||
Serialization::save(buffer, id);
|
||||
}
|
||||
|
||||
void MaterialInstance::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void MaterialInstance::load(ArchiveBuffer& buffer) {
|
||||
graphics = buffer.getGraphics();
|
||||
Serialization::load(buffer, uniformData);
|
||||
Serialization::load(buffer, uniformBinding);
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
#pragma once
|
||||
#include "Material.h"
|
||||
#include "Graphics/Buffer.h"
|
||||
#include "Asset/MaterialAsset.h"
|
||||
#include "Graphics/Buffer.h"
|
||||
#include "Material.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class MaterialInstance
|
||||
{
|
||||
public:
|
||||
|
||||
namespace Seele {
|
||||
class MaterialInstance {
|
||||
public:
|
||||
MaterialInstance();
|
||||
MaterialInstance(uint64 id,
|
||||
Gfx::PGraphics graphics,
|
||||
Array<OShaderExpression>& expressions,
|
||||
Array<std::string> params,
|
||||
uint32 uniformBinding,
|
||||
uint32 uniformSize);
|
||||
MaterialInstance(uint64 id, Gfx::PGraphics graphics, Array<OShaderExpression>& expressions, Array<std::string> params,
|
||||
uint32 uniformBinding, uint32 uniformSize);
|
||||
~MaterialInstance();
|
||||
void updateDescriptor();
|
||||
Gfx::PDescriptorSet getDescriptorSet() const;
|
||||
@@ -26,7 +21,7 @@ public:
|
||||
void save(ArchiveBuffer& buffer) const;
|
||||
void load(ArchiveBuffer& buffer);
|
||||
|
||||
private:
|
||||
private:
|
||||
Gfx::PGraphics graphics;
|
||||
Array<uint8> uniformData;
|
||||
uint32 uniformBinding;
|
||||
|
||||
@@ -1,195 +1,139 @@
|
||||
#include "ShaderExpression.h"
|
||||
#include "Graphics/Resources.h"
|
||||
#include "Asset/TextureAsset.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Asset/TextureAsset.h"
|
||||
#include "Graphics/Descriptor.h"
|
||||
#include <fstream>
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Resources.h"
|
||||
#include <fmt/core.h>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
void ExpressionInput::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void ExpressionInput::save(ArchiveBuffer& buffer) const {
|
||||
Serialization::save(buffer, source);
|
||||
Serialization::save(buffer, type);
|
||||
}
|
||||
|
||||
void ExpressionInput::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void ExpressionInput::load(ArchiveBuffer& buffer) {
|
||||
Serialization::load(buffer, source);
|
||||
Serialization::load(buffer, type);
|
||||
}
|
||||
|
||||
void ExpressionOutput::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void ExpressionOutput::save(ArchiveBuffer& buffer) const {
|
||||
Serialization::save(buffer, name);
|
||||
Serialization::save(buffer, type);
|
||||
}
|
||||
|
||||
void ExpressionOutput::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void ExpressionOutput::load(ArchiveBuffer& buffer) {
|
||||
Serialization::load(buffer, name);
|
||||
Serialization::load(buffer, type);
|
||||
}
|
||||
|
||||
ShaderExpression::ShaderExpression()
|
||||
{
|
||||
}
|
||||
ShaderExpression::ShaderExpression() {}
|
||||
|
||||
ShaderExpression::ShaderExpression(std::string key)
|
||||
: key(key)
|
||||
{
|
||||
}
|
||||
ShaderExpression::ShaderExpression(std::string key) : key(key) {}
|
||||
|
||||
ShaderExpression::~ShaderExpression()
|
||||
{
|
||||
}
|
||||
ShaderExpression::~ShaderExpression() {}
|
||||
|
||||
void ShaderExpression::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void ShaderExpression::save(ArchiveBuffer& buffer) const {
|
||||
Serialization::save(buffer, inputs);
|
||||
Serialization::save(buffer, output);
|
||||
Serialization::save(buffer, key);
|
||||
}
|
||||
|
||||
void ShaderExpression::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void ShaderExpression::load(ArchiveBuffer& buffer) {
|
||||
Serialization::load(buffer, inputs);
|
||||
Serialization::load(buffer, output);
|
||||
Serialization::load(buffer, key);
|
||||
}
|
||||
|
||||
ShaderParameter::ShaderParameter(std::string name, uint32 byteOffset, uint32 binding)
|
||||
: ShaderExpression(name)
|
||||
, byteOffset(byteOffset)
|
||||
, binding(binding)
|
||||
{
|
||||
}
|
||||
ShaderParameter::ShaderParameter(std::string name, uint32 byteOffset, uint32 binding)
|
||||
: ShaderExpression(name), byteOffset(byteOffset), binding(binding) {}
|
||||
|
||||
ShaderParameter::~ShaderParameter()
|
||||
{
|
||||
}
|
||||
ShaderParameter::~ShaderParameter() {}
|
||||
|
||||
std::string ShaderParameter::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string ShaderParameter::evaluate(Map<std::string, std::string>& varState) const {
|
||||
varState[key] = key;
|
||||
return "";
|
||||
}
|
||||
|
||||
void ShaderParameter::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void ShaderParameter::save(ArchiveBuffer& buffer) const {
|
||||
ShaderExpression::save(buffer);
|
||||
Serialization::save(buffer, byteOffset);
|
||||
Serialization::save(buffer, binding);
|
||||
}
|
||||
|
||||
void ShaderParameter::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void ShaderParameter::load(ArchiveBuffer& buffer) {
|
||||
ShaderExpression::load(buffer);
|
||||
Serialization::load(buffer, byteOffset);
|
||||
Serialization::load(buffer, binding);
|
||||
}
|
||||
|
||||
FloatParameter::FloatParameter(std::string name, float data, uint32 byteOffset, uint32 binding)
|
||||
: ShaderParameter(name, byteOffset, binding)
|
||||
, data(data)
|
||||
{
|
||||
FloatParameter::FloatParameter(std::string name, float data, uint32 byteOffset, uint32 binding)
|
||||
: ShaderParameter(name, byteOffset, binding), data(data) {
|
||||
output.name = name;
|
||||
output.type = ExpressionType::FLOAT;
|
||||
}
|
||||
|
||||
FloatParameter::~FloatParameter()
|
||||
{
|
||||
}
|
||||
FloatParameter::~FloatParameter() {}
|
||||
|
||||
void FloatParameter::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void FloatParameter::save(ArchiveBuffer& buffer) const {
|
||||
ShaderParameter::save(buffer);
|
||||
Serialization::save(buffer, data);
|
||||
}
|
||||
|
||||
void FloatParameter::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void FloatParameter::load(ArchiveBuffer& buffer) {
|
||||
ShaderParameter::load(buffer);
|
||||
Serialization::load(buffer, data);
|
||||
}
|
||||
|
||||
void FloatParameter::updateDescriptorSet(Gfx::PDescriptorSet, uint8* dst)
|
||||
{
|
||||
std::memcpy(dst + byteOffset, &data, sizeof(float));
|
||||
}
|
||||
void FloatParameter::updateDescriptorSet(Gfx::PDescriptorSet, uint8* dst) { std::memcpy(dst + byteOffset, &data, sizeof(float)); }
|
||||
|
||||
void FloatParameter::generateDeclaration(std::ofstream& stream) const
|
||||
{
|
||||
stream << "\tfloat " << key << ";\n";
|
||||
}
|
||||
void FloatParameter::generateDeclaration(std::ofstream& stream) const { stream << "\tfloat " << key << ";\n"; }
|
||||
|
||||
VectorParameter::VectorParameter(std::string name, Vector data, uint32 byteOffset, uint32 binding)
|
||||
: ShaderParameter(name, byteOffset, binding)
|
||||
, data(data)
|
||||
{
|
||||
VectorParameter::VectorParameter(std::string name, Vector data, uint32 byteOffset, uint32 binding)
|
||||
: ShaderParameter(name, byteOffset, binding), data(data) {
|
||||
output.name = name;
|
||||
output.type = ExpressionType::FLOAT3;
|
||||
}
|
||||
|
||||
VectorParameter::~VectorParameter()
|
||||
{
|
||||
}
|
||||
VectorParameter::~VectorParameter() {}
|
||||
|
||||
void VectorParameter::updateDescriptorSet(Gfx::PDescriptorSet, uint8* dst)
|
||||
{
|
||||
std::memcpy(dst + byteOffset, &data, sizeof(Vector));
|
||||
}
|
||||
void VectorParameter::updateDescriptorSet(Gfx::PDescriptorSet, uint8* dst) { std::memcpy(dst + byteOffset, &data, sizeof(Vector)); }
|
||||
|
||||
void VectorParameter::generateDeclaration(std::ofstream& stream) const
|
||||
{
|
||||
stream << "\tfloat3 " << key << ";\n";
|
||||
}
|
||||
void VectorParameter::generateDeclaration(std::ofstream& stream) const { stream << "\tfloat3 " << key << ";\n"; }
|
||||
|
||||
void VectorParameter::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void VectorParameter::save(ArchiveBuffer& buffer) const {
|
||||
ShaderParameter::save(buffer);
|
||||
Serialization::save(buffer, data);
|
||||
}
|
||||
|
||||
void VectorParameter::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void VectorParameter::load(ArchiveBuffer& buffer) {
|
||||
ShaderParameter::load(buffer);
|
||||
Serialization::load(buffer, data);
|
||||
}
|
||||
|
||||
TextureParameter::TextureParameter(std::string name, PTextureAsset asset, uint32 binding)
|
||||
: ShaderParameter(name, 0, binding)
|
||||
, data(asset)
|
||||
{
|
||||
TextureParameter::TextureParameter(std::string name, PTextureAsset asset, uint32 binding) : ShaderParameter(name, 0, binding), data(asset) {
|
||||
output.name = name;
|
||||
output.type = ExpressionType::TEXTURE;
|
||||
}
|
||||
|
||||
TextureParameter::~TextureParameter()
|
||||
{
|
||||
}
|
||||
TextureParameter::~TextureParameter() {}
|
||||
|
||||
void TextureParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8*)
|
||||
{
|
||||
void TextureParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8*) {
|
||||
descriptorSet->updateTexture(binding, data->getTexture());
|
||||
}
|
||||
|
||||
void TextureParameter::generateDeclaration(std::ofstream& stream) const
|
||||
{
|
||||
stream << "\tTexture2D " << key << ";\n";
|
||||
}
|
||||
void TextureParameter::generateDeclaration(std::ofstream& stream) const { stream << "\tTexture2D " << key << ";\n"; }
|
||||
|
||||
void TextureParameter::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void TextureParameter::save(ArchiveBuffer& buffer) const {
|
||||
ShaderParameter::save(buffer);
|
||||
Serialization::save(buffer, data->getFolderPath());
|
||||
Serialization::save(buffer, data->getName());
|
||||
}
|
||||
|
||||
void TextureParameter::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void TextureParameter::load(ArchiveBuffer& buffer) {
|
||||
ShaderParameter::load(buffer);
|
||||
std::string folder;
|
||||
Serialization::load(buffer, folder);
|
||||
@@ -198,73 +142,46 @@ void TextureParameter::load(ArchiveBuffer& buffer)
|
||||
data = AssetRegistry::findTexture(folder, filename);
|
||||
}
|
||||
|
||||
SamplerParameter::SamplerParameter(std::string name, Gfx::OSampler sampler, uint32 binding)
|
||||
: ShaderParameter(name, 0, binding)
|
||||
, data(std::move(sampler))
|
||||
{
|
||||
SamplerParameter::SamplerParameter(std::string name, Gfx::OSampler sampler, uint32 binding)
|
||||
: ShaderParameter(name, 0, binding), data(std::move(sampler)) {
|
||||
output.name = name;
|
||||
output.type = ExpressionType::SAMPLER;
|
||||
}
|
||||
|
||||
SamplerParameter::~SamplerParameter()
|
||||
{
|
||||
|
||||
}
|
||||
SamplerParameter::~SamplerParameter() {}
|
||||
|
||||
void SamplerParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8*)
|
||||
{
|
||||
descriptorSet->updateSampler(binding, data);
|
||||
}
|
||||
void SamplerParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8*) { descriptorSet->updateSampler(binding, data); }
|
||||
|
||||
void SamplerParameter::generateDeclaration(std::ofstream& stream) const
|
||||
{
|
||||
stream << "\tSamplerState " << key << ";\n";
|
||||
}
|
||||
void SamplerParameter::generateDeclaration(std::ofstream& stream) const { stream << "\tSamplerState " << key << ";\n"; }
|
||||
|
||||
void SamplerParameter::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
ShaderParameter::save(buffer);
|
||||
}
|
||||
void SamplerParameter::save(ArchiveBuffer& buffer) const { ShaderParameter::save(buffer); }
|
||||
|
||||
void SamplerParameter::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void SamplerParameter::load(ArchiveBuffer& buffer) {
|
||||
ShaderParameter::load(buffer);
|
||||
data = buffer.getGraphics()->createSampler(SamplerCreateInfo{});
|
||||
}
|
||||
|
||||
CombinedTextureParameter::CombinedTextureParameter(std::string name, PTextureAsset data, Gfx::OSampler sampler, uint32 binding)
|
||||
: ShaderParameter(name, 0, binding)
|
||||
, data(data)
|
||||
, sampler(std::move(sampler))
|
||||
{
|
||||
CombinedTextureParameter::CombinedTextureParameter(std::string name, PTextureAsset data, Gfx::OSampler sampler, uint32 binding)
|
||||
: ShaderParameter(name, 0, binding), data(data), sampler(std::move(sampler)) {
|
||||
output.name = name;
|
||||
output.type = ExpressionType::TEXTURE;
|
||||
}
|
||||
|
||||
CombinedTextureParameter::~CombinedTextureParameter()
|
||||
{
|
||||
|
||||
}
|
||||
CombinedTextureParameter::~CombinedTextureParameter() {}
|
||||
|
||||
void CombinedTextureParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8*)
|
||||
{
|
||||
void CombinedTextureParameter::updateDescriptorSet(Gfx::PDescriptorSet descriptorSet, uint8*) {
|
||||
descriptorSet->updateTexture(binding, data->getTexture(), sampler);
|
||||
}
|
||||
|
||||
void CombinedTextureParameter::generateDeclaration(std::ofstream& stream) const
|
||||
{
|
||||
stream << "\tSampler2D " << key << ";\n";
|
||||
}
|
||||
void CombinedTextureParameter::generateDeclaration(std::ofstream& stream) const { stream << "\tSampler2D " << key << ";\n"; }
|
||||
|
||||
void CombinedTextureParameter::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void CombinedTextureParameter::save(ArchiveBuffer& buffer) const {
|
||||
ShaderParameter::save(buffer);
|
||||
Serialization::save(buffer, data->getFolderPath());
|
||||
Serialization::save(buffer, data->getName());
|
||||
}
|
||||
|
||||
void CombinedTextureParameter::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void CombinedTextureParameter::load(ArchiveBuffer& buffer) {
|
||||
ShaderParameter::load(buffer);
|
||||
std::string folder;
|
||||
Serialization::load(buffer, folder);
|
||||
@@ -274,146 +191,99 @@ void CombinedTextureParameter::load(ArchiveBuffer& buffer)
|
||||
sampler = buffer.getGraphics()->createSampler({});
|
||||
}
|
||||
|
||||
ConstantExpression::ConstantExpression()
|
||||
{
|
||||
}
|
||||
ConstantExpression::ConstantExpression() {}
|
||||
|
||||
ConstantExpression::ConstantExpression(std::string expr, ExpressionType type)
|
||||
: expr(expr)
|
||||
{
|
||||
ConstantExpression::ConstantExpression(std::string expr, ExpressionType type) : expr(expr) {
|
||||
output.name = "cexpr";
|
||||
output.type = type;
|
||||
}
|
||||
|
||||
ConstantExpression::~ConstantExpression()
|
||||
{
|
||||
|
||||
}
|
||||
ConstantExpression::~ConstantExpression() {}
|
||||
|
||||
std::string ConstantExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string ConstantExpression::evaluate(Map<std::string, std::string>& varState) const {
|
||||
std::string varName = fmt::format("const_exp_{}", key);
|
||||
varState[key] = varName;
|
||||
return fmt::format("let {} = {};\n", varName, expr);
|
||||
}
|
||||
|
||||
void ConstantExpression::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void ConstantExpression::save(ArchiveBuffer& buffer) const {
|
||||
ShaderExpression::save(buffer);
|
||||
Serialization::save(buffer, expr);
|
||||
}
|
||||
|
||||
void ConstantExpression::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void ConstantExpression::load(ArchiveBuffer& buffer) {
|
||||
ShaderExpression::load(buffer);
|
||||
Serialization::load(buffer, expr);
|
||||
}
|
||||
|
||||
AddExpression::AddExpression()
|
||||
{
|
||||
AddExpression::AddExpression() {}
|
||||
|
||||
}
|
||||
AddExpression::~AddExpression() {}
|
||||
|
||||
AddExpression::~AddExpression()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string AddExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string AddExpression::evaluate(Map<std::string, std::string>& varState) const {
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
std::string lhs = inputs.at("lhs").source;
|
||||
if (varState.contains(lhs))
|
||||
{
|
||||
if (varState.contains(lhs)) {
|
||||
lhs = varState[lhs];
|
||||
}
|
||||
std::string rhs = inputs.at("rhs").source;
|
||||
if (varState.contains(rhs))
|
||||
{
|
||||
if (varState.contains(rhs)) {
|
||||
rhs = varState[rhs];
|
||||
}
|
||||
|
||||
return fmt::format("let {} = {} + {};\n", varName, lhs, rhs);
|
||||
}
|
||||
|
||||
void AddExpression::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
ShaderExpression::save(buffer);
|
||||
}
|
||||
void AddExpression::save(ArchiveBuffer& buffer) const { ShaderExpression::save(buffer); }
|
||||
|
||||
void AddExpression::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
ShaderExpression::load(buffer);
|
||||
}
|
||||
void AddExpression::load(ArchiveBuffer& buffer) { ShaderExpression::load(buffer); }
|
||||
|
||||
std::string SubExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string SubExpression::evaluate(Map<std::string, std::string>& varState) const {
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
std::string lhs = inputs.at("lhs").source;
|
||||
if (varState.contains(lhs))
|
||||
{
|
||||
if (varState.contains(lhs)) {
|
||||
lhs = varState[lhs];
|
||||
}
|
||||
std::string rhs = inputs.at("rhs").source;
|
||||
if (varState.contains(rhs))
|
||||
{
|
||||
if (varState.contains(rhs)) {
|
||||
rhs = varState[rhs];
|
||||
}
|
||||
|
||||
return fmt::format("let {} = {} - {};\n", varName, lhs, rhs);
|
||||
}
|
||||
|
||||
void SubExpression::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
ShaderExpression::save(buffer);
|
||||
}
|
||||
void SubExpression::save(ArchiveBuffer& buffer) const { ShaderExpression::save(buffer); }
|
||||
|
||||
void SubExpression::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
ShaderExpression::load(buffer);
|
||||
}
|
||||
void SubExpression::load(ArchiveBuffer& buffer) { ShaderExpression::load(buffer); }
|
||||
|
||||
std::string MulExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string MulExpression::evaluate(Map<std::string, std::string>& varState) const {
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
std::string lhs = inputs.at("lhs").source;
|
||||
if (varState.contains(lhs))
|
||||
{
|
||||
if (varState.contains(lhs)) {
|
||||
lhs = varState[lhs];
|
||||
}
|
||||
std::string rhs = inputs.at("rhs").source;
|
||||
if (varState.contains(rhs))
|
||||
{
|
||||
if (varState.contains(rhs)) {
|
||||
rhs = varState[rhs];
|
||||
}
|
||||
return fmt::format("let {} = {} * {};\n", varName, lhs, rhs);
|
||||
}
|
||||
|
||||
void MulExpression::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
ShaderExpression::save(buffer);
|
||||
}
|
||||
void MulExpression::save(ArchiveBuffer& buffer) const { ShaderExpression::save(buffer); }
|
||||
|
||||
void MulExpression::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
ShaderExpression::load(buffer);
|
||||
}
|
||||
void MulExpression::load(ArchiveBuffer& buffer) { ShaderExpression::load(buffer); }
|
||||
|
||||
std::string SwizzleExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string SwizzleExpression::evaluate(Map<std::string, std::string>& varState) const {
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
std::string swizzle = "";
|
||||
for(uint32 i = 0; i < 4; ++i)
|
||||
{
|
||||
if(comp[i] == -1)
|
||||
{
|
||||
for (uint32 i = 0; i < 4; ++i) {
|
||||
if (comp[i] == -1) {
|
||||
break;
|
||||
}
|
||||
switch (comp[i])
|
||||
{
|
||||
switch (comp[i]) {
|
||||
case 0:
|
||||
swizzle += "x";
|
||||
break;
|
||||
@@ -434,54 +304,40 @@ std::string SwizzleExpression::evaluate(Map<std::string, std::string>& varState)
|
||||
return fmt::format("let {} = {}.{};\n", varName, varState[inputs.at("target").source], swizzle);
|
||||
}
|
||||
|
||||
void SwizzleExpression::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void SwizzleExpression::save(ArchiveBuffer& buffer) const {
|
||||
ShaderExpression::save(buffer);
|
||||
Serialization::save(buffer, comp);
|
||||
}
|
||||
|
||||
void SwizzleExpression::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void SwizzleExpression::load(ArchiveBuffer& buffer) {
|
||||
ShaderExpression::load(buffer);
|
||||
Serialization::load(buffer, comp);
|
||||
}
|
||||
|
||||
std::string SampleExpression::evaluate(Map<std::string, std::string>& varState) const
|
||||
{
|
||||
std::string SampleExpression::evaluate(Map<std::string, std::string>& varState) const {
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
std::string texCoords = inputs.at("coords").source;
|
||||
if (varState.contains(inputs.at("coords").source))
|
||||
{
|
||||
if (varState.contains(inputs.at("coords").source)) {
|
||||
texCoords = varState[inputs.at("coords").source];
|
||||
}
|
||||
if (inputs.contains("texture"))
|
||||
{
|
||||
return fmt::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source], varState[inputs.at("sampler").source], texCoords);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inputs.contains("texture")) {
|
||||
return fmt::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source],
|
||||
varState[inputs.at("sampler").source], texCoords);
|
||||
} else {
|
||||
return fmt::format("let {} = {}.Sample({});\n", varName, varState[inputs.at("sampler").source], texCoords);
|
||||
}
|
||||
}
|
||||
|
||||
void SampleExpression::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
ShaderExpression::save(buffer);
|
||||
}
|
||||
void SampleExpression::save(ArchiveBuffer& buffer) const { ShaderExpression::save(buffer); }
|
||||
|
||||
void SampleExpression::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
ShaderExpression::load(buffer);
|
||||
}
|
||||
void SampleExpression::load(ArchiveBuffer& buffer) { ShaderExpression::load(buffer); }
|
||||
|
||||
void MaterialNode::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
void MaterialNode::save(ArchiveBuffer& buffer) const {
|
||||
Serialization::save(buffer, profile);
|
||||
Serialization::save(buffer, variables);
|
||||
}
|
||||
void MaterialNode::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
void MaterialNode::load(ArchiveBuffer& buffer) {
|
||||
Serialization::load(buffer, profile);
|
||||
Serialization::load(buffer, variables);
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
#include "Asset/TextureAsset.h"
|
||||
#include "Containers/Map.h"
|
||||
#include "Math/Math.h"
|
||||
#include "Asset/TextureAsset.h"
|
||||
#include "MinimalEngine.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
enum class ExpressionType
|
||||
{
|
||||
|
||||
namespace Seele {
|
||||
enum class ExpressionType {
|
||||
UNKNOWN,
|
||||
FLOAT,
|
||||
FLOAT2,
|
||||
@@ -16,24 +15,21 @@ enum class ExpressionType
|
||||
TEXTURE,
|
||||
SAMPLER,
|
||||
};
|
||||
struct ExpressionInput
|
||||
{
|
||||
struct ExpressionInput {
|
||||
std::string source;
|
||||
ExpressionType type = ExpressionType::UNKNOWN;
|
||||
void save(ArchiveBuffer& buffer) const;
|
||||
void load(ArchiveBuffer& buffer);
|
||||
};
|
||||
struct ExpressionOutput
|
||||
{
|
||||
struct ExpressionOutput {
|
||||
std::string name;
|
||||
ExpressionType type = ExpressionType::UNKNOWN;
|
||||
void save(ArchiveBuffer& buffer) const;
|
||||
void load(ArchiveBuffer& buffer);
|
||||
};
|
||||
DECLARE_REF(ShaderExpression);
|
||||
class ShaderExpression
|
||||
{
|
||||
public:
|
||||
class ShaderExpression {
|
||||
public:
|
||||
Map<std::string, ExpressionInput> inputs;
|
||||
ExpressionOutput output;
|
||||
std::string key;
|
||||
@@ -48,8 +44,7 @@ public:
|
||||
DEFINE_REF(ShaderExpression)
|
||||
|
||||
DECLARE_NAME_REF(Gfx, DescriptorSet)
|
||||
struct ShaderParameter : public ShaderExpression
|
||||
{
|
||||
struct ShaderParameter : public ShaderExpression {
|
||||
uint32 byteOffset = 0;
|
||||
uint32 binding = 0;
|
||||
ShaderParameter() {}
|
||||
@@ -64,8 +59,7 @@ struct ShaderParameter : public ShaderExpression
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(ShaderParameter)
|
||||
struct FloatParameter : public ShaderParameter
|
||||
{
|
||||
struct FloatParameter : public ShaderParameter {
|
||||
static constexpr uint64 IDENTIFIER = 0x01;
|
||||
float data = 0.0f;
|
||||
FloatParameter() {}
|
||||
@@ -78,8 +72,7 @@ struct FloatParameter : public ShaderParameter
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(FloatParameter)
|
||||
struct VectorParameter : public ShaderParameter
|
||||
{
|
||||
struct VectorParameter : public ShaderParameter {
|
||||
static constexpr uint64 IDENTIFIER = 0x02;
|
||||
Vector data = Vector();
|
||||
VectorParameter() {}
|
||||
@@ -92,8 +85,7 @@ struct VectorParameter : public ShaderParameter
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(VectorParameter)
|
||||
struct TextureParameter : public ShaderParameter
|
||||
{
|
||||
struct TextureParameter : public ShaderParameter {
|
||||
static constexpr uint64 IDENTIFIER = 0x04;
|
||||
PTextureAsset data = nullptr;
|
||||
TextureParameter() {}
|
||||
@@ -107,8 +99,7 @@ struct TextureParameter : public ShaderParameter
|
||||
};
|
||||
DEFINE_REF(TextureParameter)
|
||||
DECLARE_NAME_REF(Gfx, Sampler)
|
||||
struct SamplerParameter : public ShaderParameter
|
||||
{
|
||||
struct SamplerParameter : public ShaderParameter {
|
||||
static constexpr uint64 IDENTIFIER = 0x08;
|
||||
Gfx::OSampler data = nullptr;
|
||||
SamplerParameter() {}
|
||||
@@ -121,8 +112,7 @@ struct SamplerParameter : public ShaderParameter
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(SamplerParameter)
|
||||
struct CombinedTextureParameter : public ShaderParameter
|
||||
{
|
||||
struct CombinedTextureParameter : public ShaderParameter {
|
||||
static constexpr uint64 IDENTIFIER = 0x10;
|
||||
PTextureAsset data = nullptr;
|
||||
Gfx::OSampler sampler = nullptr;
|
||||
@@ -137,9 +127,7 @@ struct CombinedTextureParameter : public ShaderParameter
|
||||
};
|
||||
DEFINE_REF(CombinedTextureParameter)
|
||||
|
||||
|
||||
struct ConstantExpression : public ShaderExpression
|
||||
{
|
||||
struct ConstantExpression : public ShaderExpression {
|
||||
static constexpr uint64 IDENTIFIER = 0x11;
|
||||
std::string expr;
|
||||
ConstantExpression();
|
||||
@@ -151,8 +139,7 @@ struct ConstantExpression : public ShaderExpression
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(ConstantExpression)
|
||||
struct AddExpression : public ShaderExpression
|
||||
{
|
||||
struct AddExpression : public ShaderExpression {
|
||||
static constexpr uint64 IDENTIFIER = 0x12;
|
||||
AddExpression();
|
||||
virtual ~AddExpression();
|
||||
@@ -162,8 +149,7 @@ struct AddExpression : public ShaderExpression
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(AddExpression)
|
||||
struct SubExpression : public ShaderExpression
|
||||
{
|
||||
struct SubExpression : public ShaderExpression {
|
||||
static constexpr uint64 IDENTIFIER = 0x13;
|
||||
SubExpression() {}
|
||||
virtual ~SubExpression() {}
|
||||
@@ -173,8 +159,7 @@ struct SubExpression : public ShaderExpression
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(SubExpression)
|
||||
struct MulExpression : public ShaderExpression
|
||||
{
|
||||
struct MulExpression : public ShaderExpression {
|
||||
static constexpr uint64 IDENTIFIER = 0x14;
|
||||
MulExpression() {}
|
||||
virtual ~MulExpression() {}
|
||||
@@ -184,12 +169,11 @@ struct MulExpression : public ShaderExpression
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(MulExpression)
|
||||
struct SwizzleExpression : public ShaderExpression
|
||||
{
|
||||
struct SwizzleExpression : public ShaderExpression {
|
||||
static constexpr uint64 IDENTIFIER = 0x15;
|
||||
StaticArray<int32, 4> comp = {-1, -1, -1, -1};
|
||||
SwizzleExpression() {}
|
||||
SwizzleExpression(StaticArray<int32,4> comp) : comp(std::move(comp)) {}
|
||||
SwizzleExpression(StaticArray<int32, 4> comp) : comp(std::move(comp)) {}
|
||||
virtual ~SwizzleExpression() {}
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
@@ -197,8 +181,7 @@ struct SwizzleExpression : public ShaderExpression
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
};
|
||||
DEFINE_REF(SwizzleExpression)
|
||||
struct SampleExpression : public ShaderExpression
|
||||
{
|
||||
struct SampleExpression : public ShaderExpression {
|
||||
static constexpr uint64 IDENTIFIER = 0x16;
|
||||
SampleExpression() {}
|
||||
virtual ~SampleExpression() {}
|
||||
@@ -209,8 +192,7 @@ struct SampleExpression : public ShaderExpression
|
||||
};
|
||||
DEFINE_REF(SampleExpression)
|
||||
|
||||
struct MaterialNode
|
||||
{
|
||||
struct MaterialNode {
|
||||
std::string profile;
|
||||
Map<std::string, std::string> variables;
|
||||
MaterialNode() {}
|
||||
@@ -218,20 +200,15 @@ struct MaterialNode
|
||||
void save(ArchiveBuffer& buffer) const;
|
||||
void load(ArchiveBuffer& buffer);
|
||||
};
|
||||
template<>
|
||||
void Serialization::save(ArchiveBuffer& buffer, const OShaderExpression& parameter)
|
||||
{
|
||||
template <> void Serialization::save(ArchiveBuffer& buffer, const OShaderExpression& parameter) {
|
||||
Serialization::save(buffer, parameter->getIdentifier());
|
||||
parameter->save(buffer);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialization::load(ArchiveBuffer& buffer, OShaderExpression& parameter)
|
||||
{
|
||||
template <> void Serialization::load(ArchiveBuffer& buffer, OShaderExpression& parameter) {
|
||||
uint64 identifier = 0;
|
||||
Serialization::load(buffer, identifier);
|
||||
switch (identifier)
|
||||
{
|
||||
switch (identifier) {
|
||||
case FloatParameter::IDENTIFIER:
|
||||
parameter = new FloatParameter();
|
||||
break;
|
||||
@@ -271,20 +248,15 @@ void Serialization::load(ArchiveBuffer& buffer, OShaderExpression& parameter)
|
||||
parameter->load(buffer);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialization::save(ArchiveBuffer& buffer, const OShaderParameter& parameter)
|
||||
{
|
||||
template <> void Serialization::save(ArchiveBuffer& buffer, const OShaderParameter& parameter) {
|
||||
Serialization::save(buffer, parameter->getIdentifier());
|
||||
parameter->save(buffer);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Serialization::load(ArchiveBuffer& buffer, OShaderParameter& parameter)
|
||||
{
|
||||
template <> void Serialization::load(ArchiveBuffer& buffer, OShaderParameter& parameter) {
|
||||
uint64 identifier = 0;
|
||||
Serialization::load(buffer, identifier);
|
||||
switch (identifier)
|
||||
{
|
||||
switch (identifier) {
|
||||
case FloatParameter::IDENTIFIER:
|
||||
parameter = new FloatParameter();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user