Simplifying error handling for KRMaterial json parsing.
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
KRMaterial member name refactoring
This commit is contained in:
@@ -45,7 +45,7 @@ using namespace simdjson;
|
|||||||
namespace simdjson
|
namespace simdjson
|
||||||
{
|
{
|
||||||
template <typename builder_type>
|
template <typename builder_type>
|
||||||
void tag_invoke(serialize_tag, builder_type& builder, const KRMaterial::TransformedTexture& texture)
|
void tag_invoke(serialize_tag, builder_type& builder, const KRMaterial::TextureMap& texture)
|
||||||
{
|
{
|
||||||
builder.start_object();
|
builder.start_object();
|
||||||
builder.template append_key_value<"texture">(texture.texture.getName());
|
builder.template append_key_value<"texture">(texture.texture.getName());
|
||||||
@@ -60,7 +60,7 @@ void tag_invoke(serialize_tag, builder_type& builder, const KRMaterial::Transfor
|
|||||||
|
|
||||||
} // namespace simdjson
|
} // namespace simdjson
|
||||||
|
|
||||||
simdjson::error_code KRMaterial::TransformedTexture::parse(simdjson::ondemand::value &val)
|
simdjson::error_code KRMaterial::TextureMap::parse(simdjson::ondemand::value &val)
|
||||||
{
|
{
|
||||||
ondemand::object obj;
|
ondemand::object obj;
|
||||||
auto error = val.get_object().get(obj);
|
auto error = val.get_object().get(obj);
|
||||||
@@ -101,6 +101,12 @@ KRMaterial::KRMaterial(KRContext& context, std::string name, mimir::Block* data)
|
|||||||
simdjson::ondemand::parser parser;
|
simdjson::ondemand::parser parser;
|
||||||
simdjson::ondemand::document doc;
|
simdjson::ondemand::document doc;
|
||||||
|
|
||||||
|
auto tryJson = [](simdjson::error_code error) {
|
||||||
|
if (error != simdjson::EMPTY) {
|
||||||
|
// TODO - Report and handle error
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
char* str = (char*)data->getStart();
|
char* str = (char*)data->getStart();
|
||||||
OutputDebugStringA("\n\n----====----\n");
|
OutputDebugStringA("\n\n----====----\n");
|
||||||
@@ -143,20 +149,9 @@ KRMaterial::KRMaterial(KRContext& context, std::string name, mimir::Block* data)
|
|||||||
// TODO - Report and handle error
|
// TODO - Report and handle error
|
||||||
}
|
}
|
||||||
|
|
||||||
error = jsonRoot["alphaCutoff"].get(m_alphaCutoff);
|
tryJson(jsonRoot["alphaCutoff"].get(m_alphaCutoff));
|
||||||
if (error != simdjson::EMPTY) {
|
tryJson(jsonRoot["ior"].get(m_ior));
|
||||||
// TODO - Report and handle error
|
tryJson(jsonRoot["dispersion"].get(m_dispersion));
|
||||||
}
|
|
||||||
|
|
||||||
error = jsonRoot["ior"].get(m_ior);
|
|
||||||
if (error != simdjson::EMPTY) {
|
|
||||||
// TODO - Report and handle error
|
|
||||||
}
|
|
||||||
|
|
||||||
error = jsonRoot["dispersion"].get(m_dispersion);
|
|
||||||
if (error != simdjson::EMPTY) {
|
|
||||||
// TODO - Report and handle error
|
|
||||||
}
|
|
||||||
|
|
||||||
m_shadingModel = KRMATERIAL_SHADING_MODEL_PBR;
|
m_shadingModel = KRMATERIAL_SHADING_MODEL_PBR;
|
||||||
std::string_view shadingModelText;
|
std::string_view shadingModelText;
|
||||||
@@ -179,17 +174,11 @@ KRMaterial::KRMaterial(KRContext& context, std::string name, mimir::Block* data)
|
|||||||
simdjson::ondemand::value mapVal;
|
simdjson::ondemand::value mapVal;
|
||||||
error = baseColorObj["map"].get(mapVal);
|
error = baseColorObj["map"].get(mapVal);
|
||||||
if (error == simdjson::SUCCESS) {
|
if (error == simdjson::SUCCESS) {
|
||||||
error = m_baseColorTexture.parse(mapVal);
|
tryJson(m_baseColorMap.parse(mapVal));
|
||||||
if (error != simdjson::EMPTY) {
|
|
||||||
// TODO - Report and handle error
|
|
||||||
}
|
|
||||||
} else if (error != simdjson::EMPTY) {
|
} else if (error != simdjson::EMPTY) {
|
||||||
// TODO - Report and handle error
|
// TODO - Report and handle error
|
||||||
}
|
}
|
||||||
error = baseColorObj["factor"].get<Vector4>().get(m_baseColorFactor);
|
tryJson(baseColorObj["factor"].get<Vector4>().get(m_baseColorFactor));
|
||||||
if (error != simdjson::EMPTY) {
|
|
||||||
// TODO - Report and handle error
|
|
||||||
}
|
|
||||||
} else if (error != simdjson::EMPTY) {
|
} else if (error != simdjson::EMPTY) {
|
||||||
// TODO - Report and handle error
|
// TODO - Report and handle error
|
||||||
}
|
}
|
||||||
@@ -208,7 +197,7 @@ std::string KRMaterial::getExtension()
|
|||||||
|
|
||||||
bool KRMaterial::needsVertexTangents()
|
bool KRMaterial::needsVertexTangents()
|
||||||
{
|
{
|
||||||
return m_normalTexture.texture.isSet();
|
return m_normalMap.texture.isSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRMaterial::save(Block& data)
|
bool KRMaterial::save(Block& data)
|
||||||
@@ -249,7 +238,7 @@ bool KRMaterial::save(Block& data)
|
|||||||
sb.append_colon();
|
sb.append_colon();
|
||||||
|
|
||||||
sb.start_object();
|
sb.start_object();
|
||||||
sb.append_key_value<"map">(m_baseColorTexture);
|
sb.append_key_value<"map">(m_baseColorMap);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"factor">(m_baseColorFactor);
|
sb.append_key_value<"factor">(m_baseColorFactor);
|
||||||
sb.end_object();
|
sb.end_object();
|
||||||
@@ -260,7 +249,7 @@ bool KRMaterial::save(Block& data)
|
|||||||
sb.append_colon();
|
sb.append_colon();
|
||||||
|
|
||||||
sb.start_object();
|
sb.start_object();
|
||||||
sb.append_key_value<"map">(m_normalTexture);
|
sb.append_key_value<"map">(m_normalMap);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"scale">(m_normalScale);
|
sb.append_key_value<"scale">(m_normalScale);
|
||||||
sb.end_object();
|
sb.end_object();
|
||||||
@@ -271,7 +260,7 @@ bool KRMaterial::save(Block& data)
|
|||||||
sb.append_colon();
|
sb.append_colon();
|
||||||
|
|
||||||
sb.start_object();
|
sb.start_object();
|
||||||
sb.append_key_value<"map">(m_emissiveTexture);
|
sb.append_key_value<"map">(m_emissiveMap);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"factor">(m_emissiveFactor);
|
sb.append_key_value<"factor">(m_emissiveFactor);
|
||||||
sb.end_object();
|
sb.end_object();
|
||||||
@@ -284,7 +273,7 @@ bool KRMaterial::save(Block& data)
|
|||||||
sb.append_colon();
|
sb.append_colon();
|
||||||
|
|
||||||
sb.start_object();
|
sb.start_object();
|
||||||
sb.append_key_value<"map">(m_occlusionTexture);
|
sb.append_key_value<"map">(m_occlusionMap);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"strength">(m_occlusionStrength);
|
sb.append_key_value<"strength">(m_occlusionStrength);
|
||||||
sb.end_object();
|
sb.end_object();
|
||||||
@@ -295,7 +284,7 @@ bool KRMaterial::save(Block& data)
|
|||||||
sb.append_colon();
|
sb.append_colon();
|
||||||
|
|
||||||
sb.start_object();
|
sb.start_object();
|
||||||
sb.append_key_value<"map">(m_metalicRoughness);
|
sb.append_key_value<"map">(m_metalicMap);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"metalicFactor">(m_metalicFactor);
|
sb.append_key_value<"metalicFactor">(m_metalicFactor);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
@@ -308,7 +297,7 @@ bool KRMaterial::save(Block& data)
|
|||||||
sb.append_colon();
|
sb.append_colon();
|
||||||
|
|
||||||
sb.start_object();
|
sb.start_object();
|
||||||
sb.append_key_value<"map">(m_anisotropyTexture);
|
sb.append_key_value<"map">(m_anisotropyMap);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"strength">(m_anisotropyStrength);
|
sb.append_key_value<"strength">(m_anisotropyStrength);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
@@ -321,11 +310,11 @@ bool KRMaterial::save(Block& data)
|
|||||||
sb.append_colon();
|
sb.append_colon();
|
||||||
|
|
||||||
sb.start_object();
|
sb.start_object();
|
||||||
sb.append_key_value<"map">(m_clearcoatTexture);
|
sb.append_key_value<"map">(m_clearcoatMap);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"factor">(m_clearcoatFactor);
|
sb.append_key_value<"factor">(m_clearcoatFactor);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"roughnessMap">(m_clearcoatTexture);
|
sb.append_key_value<"roughnessMap">(m_clearcoatMap);
|
||||||
sb.append_comma();
|
sb.append_comma();
|
||||||
sb.append_key_value<"roughnessFactor">(m_anisotropyRotation);
|
sb.append_key_value<"roughnessFactor">(m_anisotropyRotation);
|
||||||
sb.end_object();
|
sb.end_object();
|
||||||
@@ -483,15 +472,15 @@ void KRMaterial::getResourceBindings(std::list<KRResourceBinding*>& bindings)
|
|||||||
{
|
{
|
||||||
KRResource::getResourceBindings(bindings);
|
KRResource::getResourceBindings(bindings);
|
||||||
|
|
||||||
bindings.push_back(&m_baseColorTexture.texture);
|
bindings.push_back(&m_baseColorMap.texture);
|
||||||
bindings.push_back(&m_normalTexture.texture);
|
bindings.push_back(&m_normalMap.texture);
|
||||||
bindings.push_back(&m_emissiveTexture.texture);
|
bindings.push_back(&m_emissiveMap.texture);
|
||||||
bindings.push_back(&m_occlusionTexture.texture);
|
bindings.push_back(&m_occlusionMap.texture);
|
||||||
bindings.push_back(&m_metalicRoughness.texture);
|
bindings.push_back(&m_metalicMap.texture);
|
||||||
bindings.push_back(&m_anisotropyTexture.texture);
|
bindings.push_back(&m_anisotropyMap.texture);
|
||||||
bindings.push_back(&m_clearcoatTexture.texture);
|
bindings.push_back(&m_clearcoatMap.texture);
|
||||||
bindings.push_back(&m_clearcoatRoughnessTexture.texture);
|
bindings.push_back(&m_clearcoatRoughnessMap.texture);
|
||||||
bindings.push_back(&m_clearcoatNormalTexture.texture);
|
bindings.push_back(&m_clearcoatNormalMap.texture);
|
||||||
bindings.push_back(&m_specularTexture.texture);
|
bindings.push_back(&m_specularTexture.texture);
|
||||||
bindings.push_back(&m_specularColorTexture.texture);
|
bindings.push_back(&m_specularColorTexture.texture);
|
||||||
bindings.push_back(&m_thicknessTexture.texture);
|
bindings.push_back(&m_thicknessTexture.texture);
|
||||||
@@ -502,40 +491,40 @@ kraken_stream_level KRMaterial::getStreamLevel()
|
|||||||
{
|
{
|
||||||
kraken_stream_level stream_level = kraken_stream_level::STREAM_LEVEL_IN_HQ;
|
kraken_stream_level stream_level = kraken_stream_level::STREAM_LEVEL_IN_HQ;
|
||||||
|
|
||||||
if (m_baseColorTexture.texture.isBound()) {
|
if (m_baseColorMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_baseColorTexture.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_baseColorMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_normalTexture.texture.isBound()) {
|
if (m_normalMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_normalTexture.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_normalMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_occlusionTexture.texture.isBound()) {
|
if (m_occlusionMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_occlusionTexture.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_occlusionMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_metalicRoughness.texture.isBound()) {
|
if (m_metalicMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_metalicRoughness.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_metalicMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_anisotropyTexture.texture.isBound()) {
|
if (m_anisotropyMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_anisotropyTexture.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_anisotropyMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_clearcoatTexture.texture.isBound()) {
|
if (m_clearcoatMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_clearcoatTexture.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_clearcoatMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_clearcoatTexture.texture.isBound()) {
|
if (m_clearcoatMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_clearcoatTexture.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_clearcoatMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_clearcoatRoughnessTexture.texture.isBound()) {
|
if (m_clearcoatRoughnessMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_clearcoatRoughnessTexture.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_clearcoatRoughnessMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_clearcoatNormalTexture.texture.isBound()) {
|
if (m_clearcoatNormalMap.texture.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_clearcoatNormalTexture.texture.get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_clearcoatNormalMap.texture.get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_specularTexture.texture.isBound()) {
|
if (m_specularTexture.texture.isBound()) {
|
||||||
@@ -561,8 +550,8 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
|
|||||||
Vector2 default_offset = Vector2::Zero();
|
Vector2 default_offset = Vector2::Zero();
|
||||||
|
|
||||||
bool bHasReflection = m_roughnessFactor > 0.f;
|
bool bHasReflection = m_roughnessFactor > 0.f;
|
||||||
bool bDiffuseMap = m_baseColorTexture.texture.isBound() && ri.camera->settings.bEnableDiffuseMap;
|
bool bDiffuseMap = m_baseColorMap.texture.isBound() && ri.camera->settings.bEnableDiffuseMap;
|
||||||
bool bNormalMap = m_normalTexture.texture.isBound() && ri.camera->settings.bEnableNormalMap;
|
bool bNormalMap = m_normalMap.texture.isBound() && ri.camera->settings.bEnableNormalMap;
|
||||||
bool bSpecMap = false;
|
bool bSpecMap = false;
|
||||||
bool bReflectionMap = false;
|
bool bReflectionMap = false;
|
||||||
bool bReflectionCubeMap = false;
|
bool bReflectionCubeMap = false;
|
||||||
@@ -584,13 +573,13 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
|
|||||||
info.bReflectionMap = bReflectionMap;
|
info.bReflectionMap = bReflectionMap;
|
||||||
info.bReflectionCubeMap = bReflectionCubeMap;
|
info.bReflectionCubeMap = bReflectionCubeMap;
|
||||||
info.bLightMap = bLightMap;
|
info.bLightMap = bLightMap;
|
||||||
info.bDiffuseMapScale = m_baseColorTexture.scale != default_scale && bDiffuseMap;
|
info.bDiffuseMapScale = m_baseColorMap.scale != default_scale && bDiffuseMap;
|
||||||
info.bSpecMapScale = false;
|
info.bSpecMapScale = false;
|
||||||
info.bNormalMapScale = m_normalTexture.scale != default_scale && bNormalMap;
|
info.bNormalMapScale = m_normalMap.scale != default_scale && bNormalMap;
|
||||||
info.bReflectionMapScale = false;
|
info.bReflectionMapScale = false;
|
||||||
info.bDiffuseMapOffset = false;
|
info.bDiffuseMapOffset = false;
|
||||||
info.bSpecMapOffset = false;
|
info.bSpecMapOffset = false;
|
||||||
info.bNormalMapOffset = m_normalTexture.offset != default_offset && bNormalMap;
|
info.bNormalMapOffset = m_normalMap.offset != default_offset && bNormalMap;
|
||||||
info.bReflectionMapOffset = false;
|
info.bReflectionMapOffset = false;
|
||||||
info.bAlphaTest = bAlphaTest;
|
info.bAlphaTest = bAlphaTest;
|
||||||
info.rasterMode = bAlphaBlend ? RasterMode::kAlphaBlend : RasterMode::kOpaque;
|
info.rasterMode = bAlphaBlend ? RasterMode::kAlphaBlend : RasterMode::kOpaque;
|
||||||
@@ -634,7 +623,7 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bDiffuseMap) {
|
if (bDiffuseMap) {
|
||||||
pShader->setImageBinding("diffuseTexture", m_baseColorTexture.texture.get(), getContext().getSamplerManager()->DEFAULT_WRAPPING_SAMPLER);
|
pShader->setImageBinding("diffuseTexture", m_baseColorMap.texture.get(), getContext().getSamplerManager()->DEFAULT_WRAPPING_SAMPLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bSpecMap) {
|
if (bSpecMap) {
|
||||||
@@ -642,7 +631,7 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bNormalMap) {
|
if (bNormalMap) {
|
||||||
pShader->setImageBinding("normalTexture", m_normalTexture.texture.get(), getContext().getSamplerManager()->DEFAULT_WRAPPING_SAMPLER);
|
pShader->setImageBinding("normalTexture", m_normalMap.texture.get(), getContext().getSamplerManager()->DEFAULT_WRAPPING_SAMPLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bReflectionCubeMap) {
|
if (bReflectionCubeMap) {
|
||||||
@@ -677,22 +666,22 @@ bool KRMaterial::getShaderValue(ShaderValue value, hydra::Vector2* output) const
|
|||||||
{
|
{
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case ShaderValue::diffusetexture_scale:
|
case ShaderValue::diffusetexture_scale:
|
||||||
*output = m_baseColorTexture.scale;
|
*output = m_baseColorMap.scale;
|
||||||
return true;
|
return true;
|
||||||
case ShaderValue::speculartexture_scale:
|
case ShaderValue::speculartexture_scale:
|
||||||
*output = m_specularColorTexture.scale;
|
*output = m_specularColorTexture.scale;
|
||||||
return true;
|
return true;
|
||||||
case ShaderValue::normaltexture_scale:
|
case ShaderValue::normaltexture_scale:
|
||||||
*output = m_normalTexture.scale;
|
*output = m_normalMap.scale;
|
||||||
return true;
|
return true;
|
||||||
case ShaderValue::diffusetexture_offset:
|
case ShaderValue::diffusetexture_offset:
|
||||||
*output = m_baseColorTexture.offset;
|
*output = m_baseColorMap.offset;
|
||||||
return true;
|
return true;
|
||||||
case ShaderValue::speculartexture_offset:
|
case ShaderValue::speculartexture_offset:
|
||||||
*output = m_specularColorTexture.offset;
|
*output = m_specularColorTexture.offset;
|
||||||
return true;
|
return true;
|
||||||
case ShaderValue::normaltexture_offset:
|
case ShaderValue::normaltexture_offset:
|
||||||
*output = m_normalTexture.offset;
|
*output = m_normalMap.offset;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
KRMATERIAL_SHADING_MODEL_PBR
|
KRMATERIAL_SHADING_MODEL_PBR
|
||||||
} shading_model_type;
|
} shading_model_type;
|
||||||
|
|
||||||
struct TransformedTexture
|
struct TextureMap
|
||||||
{
|
{
|
||||||
KRTextureBinding texture;
|
KRTextureBinding texture;
|
||||||
int texCoord{ 0 };
|
int texCoord{ 0 };
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
hydra::Vector2 offset{ 0.f, 0.f };
|
hydra::Vector2 offset{ 0.f, 0.f };
|
||||||
float rotation{ 0.f };
|
float rotation{ 0.f };
|
||||||
|
|
||||||
TransformedTexture(KRTexture::texture_usage_t usage)
|
TextureMap(KRTexture::texture_usage_t usage)
|
||||||
: texture{ usage }
|
: texture{ usage }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -90,8 +90,8 @@ public:
|
|||||||
KRMaterial(KRContext& context, std::string name, mimir::Block* data);
|
KRMaterial(KRContext& context, std::string name, mimir::Block* data);
|
||||||
virtual ~KRMaterial();
|
virtual ~KRMaterial();
|
||||||
|
|
||||||
virtual std::string getExtension();
|
virtual std::string getExtension() override;
|
||||||
virtual bool save(mimir::Block& data);
|
virtual bool save(mimir::Block& data) override;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void setAmbientMap(std::string texture_name, hydra::Vector2 texture_scale, hydra::Vector2 texture_offset);
|
void setAmbientMap(std::string texture_name, hydra::Vector2 texture_scale, hydra::Vector2 texture_offset);
|
||||||
@@ -123,15 +123,15 @@ public:
|
|||||||
virtual void getResourceBindings(std::list<KRResourceBinding*>& bindings) override;
|
virtual void getResourceBindings(std::list<KRResourceBinding*>& bindings) override;
|
||||||
|
|
||||||
// --- Serialized Material Attributes ---
|
// --- Serialized Material Attributes ---
|
||||||
TransformedTexture m_baseColorTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_BASE_COLOR };
|
TextureMap m_baseColorMap{ KRTexture::TEXTURE_USAGE_MATERIAL_BASE_COLOR };
|
||||||
hydra::Vector4 m_baseColorFactor{ 1.f, 1.f, 1.f, 1.f };
|
hydra::Vector4 m_baseColorFactor{ 1.f, 1.f, 1.f, 1.f };
|
||||||
TransformedTexture m_normalTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_NORMAL };
|
TextureMap m_normalMap{ KRTexture::TEXTURE_USAGE_MATERIAL_NORMAL };
|
||||||
float m_normalScale{ 1.f };
|
float m_normalScale{ 1.f };
|
||||||
TransformedTexture m_emissiveTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_EMISSIVE };
|
TextureMap m_emissiveMap{ KRTexture::TEXTURE_USAGE_MATERIAL_EMISSIVE };
|
||||||
hydra::Vector3 m_emissiveFactor{ 0.f, 0.f, 0.f };
|
hydra::Vector3 m_emissiveFactor{ 0.f, 0.f, 0.f };
|
||||||
TransformedTexture m_occlusionTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_OCCLUSION };
|
TextureMap m_occlusionMap{ KRTexture::TEXTURE_USAGE_MATERIAL_OCCLUSION };
|
||||||
float m_occlusionStrength{ 1.f };
|
float m_occlusionStrength{ 1.f };
|
||||||
TransformedTexture m_metalicRoughness{ KRTexture::TEXTURE_USAGE_MATERIAL_METALIC_ROUGHNESS };
|
TextureMap m_metalicMap{ KRTexture::TEXTURE_USAGE_MATERIAL_METALIC_ROUGHNESS };
|
||||||
float m_metalicFactor{ 1.f };
|
float m_metalicFactor{ 1.f };
|
||||||
float m_roughnessFactor{ 1.f };
|
float m_roughnessFactor{ 1.f };
|
||||||
alpha_mode_type m_alphaMode{ KRMATERIAL_ALPHA_MODE_OPAQUE };
|
alpha_mode_type m_alphaMode{ KRMATERIAL_ALPHA_MODE_OPAQUE };
|
||||||
@@ -140,29 +140,29 @@ public:
|
|||||||
float m_ior{ 1.5f };
|
float m_ior{ 1.5f };
|
||||||
shading_model_type m_shadingModel = { KRMATERIAL_SHADING_MODEL_PBR };
|
shading_model_type m_shadingModel = { KRMATERIAL_SHADING_MODEL_PBR };
|
||||||
|
|
||||||
TransformedTexture m_anisotropyTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_ANISOTROPY };
|
TextureMap m_anisotropyMap{ KRTexture::TEXTURE_USAGE_MATERIAL_ANISOTROPY };
|
||||||
float m_anisotropyStrength{ 0.f };
|
float m_anisotropyStrength{ 0.f };
|
||||||
float m_anisotropyRotation{ 0.f };
|
float m_anisotropyRotation{ 0.f };
|
||||||
|
|
||||||
TransformedTexture m_clearcoatTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_CLEARCOAT };
|
TextureMap m_clearcoatMap{ KRTexture::TEXTURE_USAGE_MATERIAL_CLEARCOAT };
|
||||||
float m_clearcoatFactor{ 0.f };
|
float m_clearcoatFactor{ 0.f };
|
||||||
TransformedTexture m_clearcoatRoughnessTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_CLEARCOAT_ROUGHNESS };
|
TextureMap m_clearcoatRoughnessMap{ KRTexture::TEXTURE_USAGE_MATERIAL_CLEARCOAT_ROUGHNESS };
|
||||||
float m_clearcoatRoughnessFactor{ 0.f };
|
float m_clearcoatRoughnessFactor{ 0.f };
|
||||||
TransformedTexture m_clearcoatNormalTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_CLEARCOAT_NORMAL };
|
TextureMap m_clearcoatNormalMap{ KRTexture::TEXTURE_USAGE_MATERIAL_CLEARCOAT_NORMAL };
|
||||||
|
|
||||||
float m_dispersion{ 0.f };
|
float m_dispersion{ 0.f };
|
||||||
|
|
||||||
TransformedTexture m_specularTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_SPECULAR };
|
TextureMap m_specularTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_SPECULAR };
|
||||||
float m_specularFactor{ 1.f };
|
float m_specularFactor{ 1.f };
|
||||||
TransformedTexture m_specularColorTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_SPECULAR_COLOR };
|
TextureMap m_specularColorTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_SPECULAR_COLOR };
|
||||||
hydra::Vector3 m_specularColorFactor{ 1.f, 1.f, 1.f };
|
hydra::Vector3 m_specularColorFactor{ 1.f, 1.f, 1.f };
|
||||||
|
|
||||||
TransformedTexture m_thicknessTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_THICKNESS };
|
TextureMap m_thicknessTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_THICKNESS };
|
||||||
float m_thicknessFactor{ 0.f };
|
float m_thicknessFactor{ 0.f };
|
||||||
float m_attenuationDistance{ std::numeric_limits<float>::max() };
|
float m_attenuationDistance{ std::numeric_limits<float>::max() };
|
||||||
hydra::Vector3 m_attenuationColor{ 1.f, 1.f, 1.f };
|
hydra::Vector3 m_attenuationColor{ 1.f, 1.f, 1.f };
|
||||||
|
|
||||||
TransformedTexture m_transmissionTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_TRANSMISSION };
|
TextureMap m_transmissionTexture{ KRTexture::TEXTURE_USAGE_MATERIAL_TRANSMISSION };
|
||||||
float m_transmissionFactor = 0.f;
|
float m_transmissionFactor = 0.f;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -273,17 +273,17 @@ KRMaterial* KRMaterialManager::loadMtl(Block* data)
|
|||||||
if (strcmp(szSymbol[0], "map_ka") == 0) {
|
if (strcmp(szSymbol[0], "map_ka") == 0) {
|
||||||
// pMaterial->setAmbientMap(szSymbol[1], texture_scale, texture_offset); // TODO - Map to modern material attributes. (Eg, unlit?)
|
// pMaterial->setAmbientMap(szSymbol[1], texture_scale, texture_offset); // TODO - Map to modern material attributes. (Eg, unlit?)
|
||||||
} else if (strcmp(szSymbol[0], "map_kd") == 0) {
|
} else if (strcmp(szSymbol[0], "map_kd") == 0) {
|
||||||
pMaterial->m_baseColorTexture.texture.set(szSymbol[1]);
|
pMaterial->m_baseColorMap.texture.set(szSymbol[1]);
|
||||||
pMaterial->m_baseColorTexture.scale = texture_scale;
|
pMaterial->m_baseColorMap.scale = texture_scale;
|
||||||
pMaterial->m_baseColorTexture.offset = texture_offset;
|
pMaterial->m_baseColorMap.offset = texture_offset;
|
||||||
} else if (strcmp(szSymbol[0], "map_ks") == 0) {
|
} else if (strcmp(szSymbol[0], "map_ks") == 0) {
|
||||||
pMaterial->m_specularColorTexture.texture.set(szSymbol[1]);
|
pMaterial->m_specularColorTexture.texture.set(szSymbol[1]);
|
||||||
pMaterial->m_specularColorTexture.scale = texture_scale;
|
pMaterial->m_specularColorTexture.scale = texture_scale;
|
||||||
pMaterial->m_specularColorTexture.offset = texture_offset;
|
pMaterial->m_specularColorTexture.offset = texture_offset;
|
||||||
} else if (strcmp(szSymbol[0], "map_normal") == 0) {
|
} else if (strcmp(szSymbol[0], "map_normal") == 0) {
|
||||||
pMaterial->m_normalTexture.texture.set(szSymbol[1]);
|
pMaterial->m_normalMap.texture.set(szSymbol[1]);
|
||||||
pMaterial->m_normalTexture.scale = texture_scale;
|
pMaterial->m_normalMap.scale = texture_scale;
|
||||||
pMaterial->m_normalTexture.offset = texture_offset;
|
pMaterial->m_normalMap.offset = texture_offset;
|
||||||
} else if (strcmp(szSymbol[0], "map_reflection") == 0) {
|
} else if (strcmp(szSymbol[0], "map_reflection") == 0) {
|
||||||
// pMaterial->setReflectionMap(szSymbol[1], texture_scale, texture_offset); // TODO - Map to modern material attributes.
|
// pMaterial->setReflectionMap(szSymbol[1], texture_scale, texture_offset); // TODO - Map to modern material attributes.
|
||||||
} else if (strcmp(szSymbol[0], "map_reflectioncube") == 0) {
|
} else if (strcmp(szSymbol[0], "map_reflectioncube") == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user