Redo of render paths

This commit is contained in:
Dynamitos
2020-06-02 11:46:18 +02:00
parent bb5b48698a
commit 356e6058fe
121 changed files with 3890 additions and 572 deletions
+66 -9
View File
@@ -1,5 +1,7 @@
#include "Material.h"
#include "Asset/AssetRegistry.h"
#include <nlohmann/json.hpp>
#include <sstream>
using namespace Seele;
using json = nlohmann::json;
@@ -9,29 +11,84 @@ Material::Material()
}
Material::Material(const std::string& directory, const std::string& name)
: FileAsset(directory, name)
: MaterialAsset(directory, name)
{
}
Material::Material(const std::string& fullPath)
: FileAsset(fullPath)
{
: MaterialAsset(fullPath)
{
}
Material::~Material()
{
}
void Material::compile()
{
auto& stream = getReadStream();
stream.seekg(0);
json j;
stream >> j;
std::cout << j["test"] << std::endl;
}
std::stringstream codeStream;
materialName = j["name"].get<std::string>();
std::string profile = j["profile"].get<std::string>();
codeStream << "import LightEnv;" << std::endl;
codeStream << "import Material;" << std::endl;
codeStream << "import BRDF;" << std::endl;
codeStream << "import InputGeometry;" << std::endl;
Gfx::PGraphicsPipeline Material::getPipeline()
{
return pipeline;
codeStream << "struct " << materialName << ": IMaterial {" << std::endl;
for(auto param : j["params"].items())
{
std::string type = param.value()["type"].get<std::string>();
auto default = param.value().find("default");
if(type.compare("float") == 0)
{
PFloatParameter p = new FloatParameter();
if(default != param.value().end())
{
p->defaultValue = std::stof(default.value().get<std::string>());
}
parameters.add(p);
}
else if(type.compare("float3") == 0)
{
PVectorParameter p = new VectorParameter();
if(default != param.value().end())
{
p->defaultValue = parseVector(default.value().get<std::string>().c_str());
}
parameters.add(p);
}
else if(type.compare("Texture2D") == 0)
{
PTextureParameter p = new TextureParameter();
if(default != param.value().end())
{
}
parameters.add(p);
}
else if(type.compare("SamplerState") == 0)
{
PSamplerParameter p = new SamplerParameter();
parameters.add(p);
}
else
{
std::cout << "Error unsupported parameter type" << std::endl;
}
codeStream << type << " " << param.key();
}
codeStream << "typedef " << profile << " BRDF;" << std::endl;
codeStream << profile << " prepare(MaterialPixelParameter geometry){" << std::endl;
codeStream << profile << " result;" << std::endl;
for(auto c : j["code"].items())
{
codeStream << c.value().get<std::string>() << std::endl;
}
codeStream << "}};" << std::endl;
}