MaterialX: Implement export of Input nodes #20

Merged
Bogdan Nagirniak merged 26 commits from Vasyl-Pidhirskyi/blender:BLEN-530 into matx-export-material 2023-09-15 19:55:37 +02:00
Collaborator

Purpose

Add support for Input nodes.

Technical steps

Implemented get_value_default, get_output_default.
Fixed type conversion issue. Now type is converted even if a node is already in the graph.

Added:

  • RGB
  • Value

Partially implemented:

  • Geometry
  • Object Info
  • Texture Coordinate
  • UVMap
  • Color Attribute
  • Wireframe

Not implemented:

  • Ambient Occlusion
  • Attribute
  • Bevel
  • Camera Data
  • Fresnel
  • Curves Info
  • Layer Weight
  • Particle Info
  • Point Info
  • Tangent
### Purpose Add support for Input nodes. ### Technical steps Implemented get_value_default, get_output_default. Fixed type conversion issue. Now type is converted even if a node is already in the graph. Added: * RGB * Value Partially implemented: * Geometry * Object Info * Texture Coordinate * UVMap * Color Attribute * Wireframe Not implemented: * Ambient Occlusion * Attribute * Bevel * Camera Data * Fresnel * Curves Info * Layer Weight * Particle Info * Point Info * Tangent
Vasyl Pidhirskyi added 19 commits 2023-09-13 15:05:31 +02:00
Vasyl Pidhirskyi requested review from Brian Savery (AMD) 2023-09-13 15:05:58 +02:00
Vasyl Pidhirskyi requested review from Bogdan Nagirniak 2023-09-13 15:05:58 +02:00
Brian Savery (AMD) was assigned by Vasyl Pidhirskyi 2023-09-13 15:06:06 +02:00
Georgiy Markelov was assigned by Vasyl Pidhirskyi 2023-09-13 15:06:07 +02:00
Bogdan Nagirniak was assigned by Vasyl Pidhirskyi 2023-09-13 15:06:07 +02:00
Vasyl Pidhirskyi self-assigned this 2023-09-13 15:06:07 +02:00
Bogdan Nagirniak requested changes 2023-09-13 17:34:44 +02:00
@ -53,2 +55,4 @@
private:
NodeItem get_input_default(const bNodeSocket &socket, NodeItem::Type to_type);
NodeItem get_output_default(const bNodeSocket &socket);
NodeItem get_value_default(const bNodeSocket &socket);
Collaborator

use one function here instead of 3 get_default(const bNodeSocket &socket, NodeItem::Type to_type)

use one function here instead of 3 `get_default(const bNodeSocket &socket, NodeItem::Type to_type)`
BogdanNagirniak marked this conversation as resolved
@ -58,0 +64,4 @@
* res.set_input("coneangle", val(90.0f));
* res.set_input("maxdistance", maxdistance);
*/
NodeItem res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
Collaborator
NodeItem color = get_input_value("Color", NodeItem::Type::Color4);
NodeItem res = color;
``` NodeItem color = get_input_value("Color", NodeItem::Type::Color4); NodeItem res = color; ```
BogdanNagirniak marked this conversation as resolved
@ -80,0 +81,4 @@
{
/* TODO: some outputs expected be implemented within the next iteration (see nodedef
* <geompropvalue>) */
NodeItem res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
Collaborator

Start with NodeItem res = empty(); add check if (STREQ(socket_out_->name, "Color"))

Start with `NodeItem res = empty();` add check `if (STREQ(socket_out_->name, "Color"))`
BogdanNagirniak marked this conversation as resolved
@ -80,0 +85,4 @@
if (STREQ(socket_out_->name, "Vector")) {
res = val(MaterialX::Vector3(1.0f, 1.0f, 1.0f));
}
if (STREQ(socket_out_->name, "Factor")) {
Collaborator

else if

`else if`
BogdanNagirniak marked this conversation as resolved
@ -80,0 +90,4 @@
}
if (STREQ(socket_out_->name, "Alpha")) {
res = res.extract(3);
}
Collaborator

add

else {
BLI_assert_unreachable();
}
add ``` else { BLI_assert_unreachable(); } ```
BogdanNagirniak marked this conversation as resolved
@ -41,1 +41,4 @@
NODE_SHADER_MATERIALX_BEGIN
{
/* TODO: This node doesn't have an implementation in MaterialX 1.38.6.*/
Collaborator

NOTE instead TODO if there is no implementation in MatX. No need 1.38.6, just in MaterialX

`NOTE` instead `TODO` if there is no implementation in MatX. No need 1.38.6, just `in MaterialX`
BogdanNagirniak marked this conversation as resolved
@ -42,0 +42,4 @@
NODE_SHADER_MATERIALX_BEGIN
{
/* TODO: This node doesn't have an implementation in MaterialX 1.38.6.*/
return val(MaterialX::Vector3(1.0f, 1.0f, 1.0f));
Collaborator

return get_input_link("Normal", NodeItem::Type::Vector3);

`return get_input_link("Normal", NodeItem::Type::Vector3);`
BogdanNagirniak marked this conversation as resolved
@ -29,0 +36,4 @@
if (STREQ(socket_out_->name, "View Distance")) {
res = res.extract(2);
}
return res;
Collaborator

start from empty(), use else if

start from `empty()`, use `else if`
BogdanNagirniak marked this conversation as resolved
@ -61,0 +64,4 @@
CLG_LogRef *LOG_MATERIALX_SHADER = materialx::LOG_MATERIALX_SHADER;
NodeItem res = empty();
const char *output_name = socket_out_->name;
Collaborator

maybe std::string name = socket_out_->name ?

maybe std::string name = socket_out_->name ?
BogdanNagirniak marked this conversation as resolved
@ -37,0 +38,4 @@
{
/* TODO: This node doesn't have an implementation in MaterialX 1.38.6.*/
NodeItem res = val(MaterialX::Vector3(1.0f, 1.0f, 1.0f));
if (STREQ(socket_out_->name, "Index") || STREQ(socket_out_->name, "Random") ||
Collaborator

use std::string name = socket_out_->name and ELEM(name, ....)

use `std::string name = socket_out_->name` and `ELEM(name, ....)`
BogdanNagirniak marked this conversation as resolved
@ -25,0 +29,4 @@
if (STREQ(socket_out_->name, "Radius") || STREQ(socket_out_->name, "Random")) {
res = res.extract(2);
}
return res;
Collaborator

I think return get_output_default can be used here

I think `return get_output_default` can be used here
BogdanNagirniak marked this conversation as resolved
@ -74,0 +74,4 @@
NODE_SHADER_MATERIALX_BEGIN
{
/* TODO: Partially implemented, some nodes don't have an implementation in MaterialX 1.38.6.
* some outputs expected be implemented within the next iteration*/
Collaborator

This node I think has to be implemented in this PR

This node I think has to be implemented in this PR
BogdanNagirniak marked this conversation as resolved
@ -69,1 +69,4 @@
NODE_SHADER_MATERIALX_BEGIN
{
/* TODO: Partially implemented*/
Collaborator

I think it is implemented here, use NOTE that other properties of node are unsupported

I think it is implemented here, use NOTE that other properties of node are unsupported
BogdanNagirniak marked this conversation as resolved
@ -70,0 +71,4 @@
{
/* TODO: some output expected be implemented within the next iteration (see nodedef
* <geomcolor>)*/
NodeItem res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
Collaborator

start from empty()

start from empty()
BogdanNagirniak marked this conversation as resolved
Vasyl Pidhirskyi added 3 commits 2023-09-15 12:09:10 +02:00
Removerd to_type argument from get_output_default to avoid double conversion.
Revert texcoord node to Vector2 as far as Vector 3 returns black result.
Vasyl Pidhirskyi added 1 commit 2023-09-15 12:11:35 +02:00
Vasyl Pidhirskyi added 1 commit 2023-09-15 15:06:58 +02:00
Vasyl Pidhirskyi requested review from Bogdan Nagirniak 2023-09-15 15:23:32 +02:00
Bogdan Nagirniak requested changes 2023-09-15 18:12:31 +02:00
Bogdan Nagirniak left a comment
Collaborator

Node implementation is ok, small changes are required

Node implementation is ok, small changes are required
@ -142,7 +152,7 @@ NodeItem NodeParser::get_input_default(const bNodeSocket &socket, NodeItem::Type
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported socket type: %d", socket.type);
}
}
return res.convert(to_type);
Collaborator

I think this has to be reverted back, let to_type be here. It is always possible to use Type::Any

I think this has to be reverted back, let to_type be here. It is always possible to use Type::Any
Vasyl-Pidhirskyi marked this conversation as resolved
Vasyl Pidhirskyi added 1 commit 2023-09-15 19:34:00 +02:00
Bogdan Nagirniak approved these changes 2023-09-15 19:39:54 +02:00
Bogdan Nagirniak left a comment
Collaborator

Looks good

Looks good
Bogdan Nagirniak added 1 commit 2023-09-15 19:53:59 +02:00
Bogdan Nagirniak merged commit 3cdecebaf0 into matx-export-material 2023-09-15 19:55:37 +02:00
Sign in to join this conversation.
No Label
No Milestone
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: DagerD/blender#20
No description provided.