Adding combined image samplers
This commit is contained in:
@@ -121,6 +121,23 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
||||
parameters.add(p->key);
|
||||
expressions.add(std::move(p));
|
||||
}
|
||||
else if (type.compare("Sampler2D") == 0)
|
||||
{
|
||||
OCombinedTextureParameter p = new CombinedTextureParameter(param.key(), 0, bindingCounter);
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{ .binding = bindingCounter++, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER, });
|
||||
p->sampler = graphics->createSampler({});
|
||||
if (defaultValue != param.value().end())
|
||||
{
|
||||
std::string defaultString = defaultValue.value().get<std::string>();
|
||||
p->data = AssetRegistry::findTexture(defaultString);
|
||||
}
|
||||
if (p->data == nullptr)
|
||||
{
|
||||
p->data = AssetRegistry::findTexture(""); // this will return placeholder texture
|
||||
}
|
||||
parameters.add(p->key);
|
||||
expressions.add(std::move(p));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error unsupported parameter type" << std::endl;
|
||||
@@ -206,7 +223,10 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
||||
OSampleExpression p = new SampleExpression();
|
||||
std::string name = fmt::format("{0}", key++);
|
||||
p->key = name;
|
||||
p->inputs["texture"].source = referenceExpression(obj["texture"]);
|
||||
if (obj.contains("texture"))
|
||||
{
|
||||
p->inputs["texture"].source = referenceExpression(obj["texture"]);
|
||||
}
|
||||
p->inputs["sampler"].source = referenceExpression(obj["sampler"]);
|
||||
p->inputs["coords"].source = referenceExpression(obj["coords"]);
|
||||
expressions.add(std::move(p));
|
||||
|
||||
@@ -77,18 +77,13 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
|
||||
});
|
||||
matCode["params"]["diffuseTexture"] =
|
||||
{
|
||||
{"type", "Texture2D"},
|
||||
{"type", "Sampler2D"},
|
||||
{"default", fmt::format("{0}/{1}", importPath, texFilename.string())}
|
||||
};
|
||||
matCode["params"]["diffuseSampler"] =
|
||||
{
|
||||
{"type", "Sampler"}
|
||||
};
|
||||
matCode["code"].push_back(
|
||||
{
|
||||
{ "exp", "Sample" },
|
||||
{ "texture", "diffuseTexture" },
|
||||
{ "sampler", "diffuseSampler" },
|
||||
{ "sampler", "diffuseTexture" },
|
||||
{ "coords", "input.texCoords"}
|
||||
}
|
||||
);
|
||||
@@ -122,18 +117,13 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
|
||||
});
|
||||
matCode["params"]["normalTexture"] =
|
||||
{
|
||||
{"type", "Texture2D"},
|
||||
{"type", "Sampler2D"},
|
||||
{"default", fmt::format("{0}/{1}", importPath, texFilename.string())}
|
||||
};
|
||||
matCode["params"]["normalSampler"] =
|
||||
{
|
||||
{"type", "Sampler"}
|
||||
};
|
||||
matCode["code"].push_back(
|
||||
{
|
||||
{ "exp", "Sample" },
|
||||
{ "texture", "normalTexture" },
|
||||
{ "sampler", "normalSampler" },
|
||||
{ "sampler", "normalTexture" },
|
||||
{ "coords", "input.texCoords" }
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user