forked from blender/blender
MaterialX: Implement Gradient Texture node. #28
@ -179,12 +179,12 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
res = vector.extract(1).atan2(vector.extract(0)) / (val(float(M_PI * 2.0f))) + val(0.5f);
|
res = vector.extract(1).atan2(vector.extract(0)) / (val(float(M_PI * 2.0f))) + val(0.5f);
|
||||||
break;
|
break;
|
||||||
case SHD_BLEND_QUADRATIC_SPHERE:
|
case SHD_BLEND_QUADRATIC_SPHERE:
|
||||||
res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", vector}, {"in2", vector}});
|
res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", vector}, {"in2", vector}}).sqrt();
|
||||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
|
|||||||
res = (val(0.999999f) - res).max(val(0.0f));
|
res = (val(0.999999f) - res).max(val(0.0f));
|
||||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
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
Vasyl Pidhirskyi
commented
It's made according to Blender's implementation.
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);
```
Vasyl Pidhirskyi
commented
Added comment Added comment
|
|||||||
res = res * res;
|
res = res * res;
|
||||||
break;
|
break;
|
||||||
case SHD_BLEND_SPHERICAL:
|
case SHD_BLEND_SPHERICAL:
|
||||||
res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", vector}, {"in2", vector}});
|
res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", vector}, {"in2", vector}}).sqrt();
|
||||||
res = (val(0.999999f) - res).max(val(0.0f));
|
res = (val(0.999999f) - res).max(val(0.0f));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
add add `default: BLI_assert_unreachable()`
|
|||||||
|
Loading…
Reference in New Issue
Block a user
use
res = res.dotproduct(res).sqrt()