forked from blender/blender
MaterialX logging #7
@ -1010,7 +1010,7 @@ static void rna_def_render_engine(BlenderRNA *brna)
|
||||
prop = RNA_def_property(srna, "bl_use_materialx", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "type->flag", RE_USE_MATERIALX);
|
||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||
RNA_def_property_ui_text(prop, "Use Material", "Use MaterialX for exporting materials to Hydra");
|
||||
RNA_def_property_ui_text(prop, "Use MaterialX", "Use MaterialX for exporting materials to Hydra");
|
||||
|
||||
RNA_define_verify_sdna(true);
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ set(INC
|
||||
if(WITH_HYDRA)
|
||||
list(APPEND INC
|
||||
../../io/usd
|
||||
)
|
||||
../../../../intern/clog
|
||||
)
|
||||
add_definitions(-DWITH_HYDRA)
|
||||
endif()
|
||||
|
||||
@ -144,8 +145,6 @@ set(LIB
|
||||
)
|
||||
|
||||
if(WITH_MATERIALX)
|
||||
list(APPEND LIB MaterialXCore)
|
||||
list(APPEND LIB MaterialXFormat)
|
||||
list(APPEND SRC
|
||||
materialx/material.cc
|
||||
materialx/nodes/bsdf_principled.cc
|
||||
@ -161,6 +160,10 @@ if(WITH_MATERIALX)
|
||||
materialx/nodes/node_item.h
|
||||
materialx/nodes/node_parser.h
|
||||
)
|
||||
list(APPEND LIB
|
||||
MaterialXCore
|
||||
MaterialXFormat
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_FREESTYLE)
|
||||
|
@ -5,13 +5,18 @@
|
||||
#include "material.h"
|
||||
#include "nodes/node_parser.h"
|
||||
|
||||
#include <MaterialXCore/Node.h>
|
||||
#include <MaterialXFormat/XmlIo.h>
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "DNA_material_types.h"
|
||||
|
||||
#include "NOD_shader.h"
|
||||
|
||||
namespace blender::nodes::materialx {
|
||||
|
||||
CLG_LOGREF_DECLARE_GLOBAL(LOG_MATERIALX_SHADER, "materialx.shader");
|
||||
|
||||
static void export_nodegraph(MaterialX::GraphElement *graph,
|
||||
Depsgraph *depsgraph,
|
||||
Material *material)
|
||||
@ -48,7 +53,7 @@ MaterialX::DocumentPtr export_to_materialx(Depsgraph *depsgraph, Material *mater
|
||||
create_standard_surface(doc.get(), material);
|
||||
}
|
||||
std::string str = MaterialX::writeToXmlString(doc);
|
||||
printf("\nMaterial: %s\n%s\n", material->id.name, str.c_str());
|
||||
CLOG_INFO(LOG_MATERIALX_SHADER, 1, "Material: %s\n%s", material->id.name, str.c_str());
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,15 @@
|
||||
|
||||
#include <MaterialXCore/Document.h>
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "CLG_log.h"
|
||||
|
||||
struct Depsgraph;
|
||||
struct Material;
|
||||
|
||||
namespace blender::nodes::materialx {
|
||||
|
||||
extern struct CLG_LogRef *LOG_MATERIALX_SHADER;
|
||||
|
||||
MaterialX::DocumentPtr export_to_materialx(Depsgraph *depsgraph, Material *material);
|
||||
|
||||
} // namespace blender::nodes::materialx
|
||||
|
@ -3,16 +3,14 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "node_parser.h"
|
||||
#include "../material.h"
|
||||
|
||||
namespace blender::nodes::materialx {
|
||||
|
||||
NodeItem MathNodeParser::compute()
|
||||
{
|
||||
/* TODO: finish some math operations */
|
||||
|
||||
auto op = node->custom1;
|
||||
printf("%d\n", int(op));
|
||||
|
||||
NodeItem res = empty();
|
||||
|
||||
/* Single operand operations */
|
||||
@ -123,13 +121,13 @@ NodeItem MathNodeParser::compute()
|
||||
res = x.atan2(y);
|
||||
break;
|
||||
case NODE_MATH_SNAP:
|
||||
// res = ;
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unimplemented math operation %d", op);
|
||||
break;
|
||||
case NODE_MATH_PINGPONG:
|
||||
// res = ;
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unimplemented math operation %d", op);
|
||||
break;
|
||||
case NODE_MATH_FLOORED_MODULO:
|
||||
// res = ;
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unimplemented math operation %d", op);
|
||||
break;
|
||||
|
||||
default: {
|
||||
@ -137,7 +135,7 @@ NodeItem MathNodeParser::compute()
|
||||
NodeItem z = get_input_value(2);
|
||||
switch (op) {
|
||||
case NODE_MATH_WRAP:
|
||||
// res = ;
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unimplemented math operation %d", op);
|
||||
break;
|
||||
case NODE_MATH_COMPARE:
|
||||
res = z.if_else("<", (x - y).abs(), value(1.0f), value(0.0f));
|
||||
@ -146,10 +144,10 @@ NodeItem MathNodeParser::compute()
|
||||
res = x * y + z;
|
||||
break;
|
||||
case NODE_MATH_SMOOTH_MIN:
|
||||
// res = ;
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unimplemented math operation %d", op);
|
||||
break;
|
||||
case NODE_MATH_SMOOTH_MAX:
|
||||
// res = ;
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unimplemented math operation %d", op);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -3,6 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "node_item.h"
|
||||
#include "../material.h"
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_utildefines.h"
|
||||
@ -206,6 +207,9 @@ NodeItem NodeItem::dotproduct(const NodeItem &other) const
|
||||
auto v = value->asA<MaterialX::Vector4>();
|
||||
f = v[0] + v[1] + v[2] + v[3];
|
||||
}
|
||||
else {
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
d.value = MaterialX::Value::createValue(f);
|
||||
}
|
||||
return d;
|
||||
@ -228,6 +232,10 @@ NodeItem NodeItem::if_else(const std::string &condition,
|
||||
|
||||
NodeItem res = empty();
|
||||
if (type() != "float" || other.type() != "float") {
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER,
|
||||
"Incorrect condition types: %s, %s",
|
||||
type().c_str(),
|
||||
other.type().c_str());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,9 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "node_parser.h"
|
||||
#include "../material.h"
|
||||
|
||||
#include <BKE_node_runtime.hh>
|
||||
#include "BKE_node_runtime.hh"
|
||||
|
||||
namespace blender::nodes::materialx {
|
||||
|
||||
@ -82,7 +83,7 @@ NodeItem NodeParser::get_input_default(const bNodeSocket &socket)
|
||||
MaterialX::Color4(v[0], v[1], v[2], v[3]));
|
||||
} break;
|
||||
default: {
|
||||
// TODO log warn
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported socket type: %d", socket.type);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@ -127,7 +128,7 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket)
|
||||
parser = std::make_unique<TexImageNodeParser>(graph, depsgraph, material, in_node);
|
||||
break;
|
||||
default:
|
||||
// TODO: warning log
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported node: %s (%d)", in_node->name, in_node->type);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user