1
1
Fork 0

MaterialX: Implement Gradient Texture node. #28

Merged
Bogdan Nagirniak merged 6 commits from Vasyl-Pidhirskyi/blender:BLEN-550 into matx-export-material 2023-09-21 09:31:28 +02:00
Collaborator

Purpose

Add support for Gradient Texture node.

Technical steps

Implemented Gradient Texture node according to existing Blender's implementation,
Fixed dotproduct, added to_type argument to be able to specify output type of node while using arithmetic method.

### Purpose Add support for Gradient Texture node. ### Technical steps Implemented Gradient Texture node according to existing Blender's implementation, Fixed dotproduct, added `to_type` argument to be able to specify output type of node while using `arithmetic` method.
Vasyl Pidhirskyi added 1 commit 2023-09-20 10:08:51 +02:00
Vasyl Pidhirskyi requested review from Brian Savery (AMD) 2023-09-20 10:09:15 +02:00
Vasyl Pidhirskyi requested review from Bogdan Nagirniak 2023-09-20 10:09:15 +02:00
Brian Savery (AMD) was assigned by Vasyl Pidhirskyi 2023-09-20 10:09:25 +02:00
Georgiy Markelov was assigned by Vasyl Pidhirskyi 2023-09-20 10:09:25 +02:00
Bogdan Nagirniak was assigned by Vasyl Pidhirskyi 2023-09-20 10:09:26 +02:00
Vasyl Pidhirskyi self-assigned this 2023-09-20 10:09:26 +02:00
Vasyl Pidhirskyi added 1 commit 2023-09-20 12:04:23 +02:00
Bogdan Nagirniak requested changes 2023-09-20 13:35:34 +02:00
@ -150,0 +170,4 @@
case SHD_BLEND_EASING:
res = vector.extract(0).clamp(val(0.0f), val(1.0f));
res_1 = res * res;
res = (val(3.0f) * res_1 - val(2.0f) * res_1 * res);
Collaborator

seems can be simplified to
res = res * res * (val(3.0f) - val(2.0f) * res)

seems can be simplified to `res = res * res * (val(3.0f) - val(2.0f) * res)`
Vasyl-Pidhirskyi marked this conversation as resolved
@ -150,0 +180,4 @@
break;
case SHD_BLEND_QUADRATIC_SPHERE:
res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", vector}, {"in2", vector}}).sqrt();
res = (val(0.999999f) - res).max(val(0.0f));
Collaborator

Why not 1.0f? Need comment why 0.999999f is used instead of 1.0f

Why not 1.0f? Need comment why 0.999999f is used instead of 1.0f
Author
Collaborator

It's made according to Blender's implementation.

          /* Bias a little bit for the case where input is a unit length vector,
           * to get exactly zero instead of a small random value depending
           * on float precision. */
          const float r = std::max(0.999999f - math::length(vector[i]), 0.0f);
It's made according to Blender's implementation. ``` /* Bias a little bit for the case where input is a unit length vector, * to get exactly zero instead of a small random value depending * on float precision. */ const float r = std::max(0.999999f - math::length(vector[i]), 0.0f); ```
Author
Collaborator

Added comment

Added comment
Vasyl-Pidhirskyi marked this conversation as resolved
@ -150,0 +187,4 @@
res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", vector}, {"in2", vector}}).sqrt();
res = (val(0.999999f) - res).max(val(0.0f));
break;
}
Collaborator

add default: BLI_assert_unreachable()

add `default: BLI_assert_unreachable()`
Vasyl-Pidhirskyi marked this conversation as resolved
Bogdan Nagirniak requested changes 2023-09-20 13:49:37 +02:00
@ -150,0 +179,4 @@
res = vector.extract(1).atan2(vector.extract(0)) / (val(float(M_PI * 2.0f))) + val(0.5f);
break;
case SHD_BLEND_QUADRATIC_SPHERE:
res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", vector}, {"in2", vector}}).sqrt();
Collaborator

use res = res.dotproduct(res).sqrt()

use `res = res.dotproduct(res).sqrt()`
Vasyl-Pidhirskyi marked this conversation as resolved
Vasyl Pidhirskyi added 1 commit 2023-09-20 16:47:03 +02:00
Vasyl Pidhirskyi added 1 commit 2023-09-20 17:09:26 +02:00
a9e919f44c Review comments - utilized `dotproduct` method.
Fixed dotproduct, added `to_type` argument to be able to specify output type of node while using `arithmetic` method.
Vasyl Pidhirskyi requested review from Bogdan Nagirniak 2023-09-20 17:35:46 +02:00
Vasyl Pidhirskyi added 1 commit 2023-09-20 17:52:42 +02:00
Brian Savery (AMD) approved these changes 2023-09-20 23:01:25 +02:00
Vasyl Pidhirskyi added 1 commit 2023-09-21 08:02:32 +02:00
9ccafcfe67 Simplified formula.
Removed comments.
Bogdan Nagirniak approved these changes 2023-09-21 09:30:33 +02:00
Bogdan Nagirniak left a comment
Collaborator

Looks good

Looks good
Bogdan Nagirniak merged commit 886b414a7c into matx-export-material 2023-09-21 09:31:28 +02:00
Sign in to join this conversation.
No Label
No Milestone
3 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#28
No description provided.