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
Showing only changes of commit 7ce7d7058b - Show all commits

View File

@ -157,7 +157,6 @@ NODE_SHADER_MATERIALX_BEGIN
vector = texcoord_node();
}
NodeItem res = empty();
NodeItem res_1 = empty();
switch (gradient_type) {
case SHD_BLEND_LINEAR:
@ -169,8 +168,7 @@ NODE_SHADER_MATERIALX_BEGIN
break;
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);
res = res * res * (val(3.0f) - val(2.0f) * res);
break;
case SHD_BLEND_DIAGONAL:
Vasyl-Pidhirskyi marked this conversation as resolved
Review

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)`
res = (vector.extract(0) + vector.extract(1)) * val(0.5f);
@ -187,6 +185,8 @@ NODE_SHADER_MATERIALX_BEGIN
res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", vector}, {"in2", vector}}).sqrt();
res = (val(0.999999f) - res).max(val(0.0f));
break;
default:
BLI_assert_unreachable();
}
return res;
}