Compositor: Implemenet Posterize node for new CPU compositor
Reference #125968.
This commit is contained in:
@@ -4,6 +4,6 @@
|
||||
|
||||
void node_composite_posterize(vec4 color, float steps, out vec4 result)
|
||||
{
|
||||
steps = clamp(steps, 2.0, 1024.0);
|
||||
result = vec4(floor(color.rgb * steps) / steps, color.a);
|
||||
float sanitized_steps = clamp(steps, 2.0, 1024.0);
|
||||
result = vec4(floor(color.rgb * sanitized_steps) / sanitized_steps, color.a);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* \ingroup cmpnodes
|
||||
*/
|
||||
|
||||
#include "BLI_math_base.hh"
|
||||
#include "BLI_math_vector.hh"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
|
||||
#include "FN_multi_function_builder.hh"
|
||||
@@ -57,10 +59,12 @@ static ShaderNode *get_compositor_shader_node(DNode node)
|
||||
|
||||
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
|
||||
{
|
||||
/* Not yet implemented. Return zero. */
|
||||
static auto function = mf::build::SI2_SO<float4, float, float4>(
|
||||
"Posterize",
|
||||
[](const float4 & /*color*/, const float /*steps*/) -> float4 { return float4(0.0f); },
|
||||
[](const float4 &color, const float steps) -> float4 {
|
||||
const float sanitized_steps = math::clamp(steps, 2.0f, 1024.0f);
|
||||
return float4(math::floor(color.xyz() * sanitized_steps) / sanitized_steps, color.w);
|
||||
},
|
||||
mf::build::exec_presets::SomeSpanOrSingle<0>());
|
||||
builder.set_matching_fn(function);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user