32 return fminf(fmaxf(
v, 0.0f), 1.0f);
44 const float smooth =
t *
t * (3.0f - 2.0f *
t);
55 const float inner,
const float w,
62 const float q_u = 0.5f * u * u - (2.0f / 3.0f) * u * u * u + 0.25f * u * u * u * u;
63 const float q_i = 0.5f * inner * inner - (2.0f / 3.0f) * inner * inner * inner
64 + 0.25f * inner * inner * inner * inner;
65 return base + (q_u - q_i) / (w * w);
70 const float s2 = s * s;
71 const float s3 = s2 * s;
72 const float s4 = s2 * s2;
73 const float s5 = s4 * s;
74 const float delta = w * (inner * (s - s3 + 0.5f * s4)
75 + w * (0.5f * s2 - 0.75f * s4 + 0.4f * s5));
81 const float l_u = 0.5f * u * u - (1.0f / 3.0f) * u * u * u;
82 const float l_i = 0.5f * inner * inner - (1.0f / 3.0f) * inner * inner * inner;
83 return base + (l_u - l_i) / w;
95 if(!dab || norm2 >= 1.0f)
return 0.0f;
99 const float radius = sqrtf(norm2);
100 if(radius < 0.5f)
return 1.0f - 6.0f * norm2 + 6.0f * norm2 * radius;
101 const float inv_r = 1.0f - radius;
102 return 2.0f * inv_r * inv_r * inv_r;
106 if(hardness >= 1.0f - 1e-6f)
return 1.0f;
108 const float min_inner = 0.5f / fmaxf(dab->
radius, 0.5f);
110 const float radius = sqrtf(norm2);
111 if(radius <= inner)
return 1.0f;
123 if(!dab)
return 0.0f;
125 if(u <= 0.0f)
return 0.0f;
129 if(u <= 0.5f)
return 0.5f * u * u - 1.5f * u * u * u * u + 1.2f * u * u * u * u * u;
130 const float u2 = u * u;
131 const float u3 = u2 * u;
132 const float u4 = u2 * u2;
133 const float u5 = u4 * u;
134 return u2 - 2.0f * u3 + 1.5f * u4 - 0.4f * u5 - 0.0125f;
138 if(hardness >= 1.0f - 1e-6f)
return 0.5f * u * u;
139 const float min_inner = 0.5f / fmaxf(dab->
radius, 0.5f);
141 if(u <= inner)
return 0.5f * u * u;
142 const float w = fmaxf(1.0f - inner, 1e-6f);
143 const float base = 0.5f * inner * inner;
Dab-level brush rasterization API for drawlayer.
@ DT_DRAWLAYER_BRUSH_SHAPE_SIGMOIDAL
Definition brush.h:44
@ DT_DRAWLAYER_BRUSH_SHAPE_GAUSSIAN
Definition brush.h:42
@ DT_DRAWLAYER_BRUSH_SHAPE_LINEAR
Definition brush.h:41
@ DT_DRAWLAYER_BRUSH_SHAPE_QUADRATIC
Definition brush.h:43
static float dt_drawlayer_brush_profile_eval(const dt_drawlayer_brush_dab_t *dab, const float norm2)
Evaluate normalized brush profile at squared normalized radius.
Definition brush_profile.h:93
static float dt_drawlayer_brush_mass_primitive_eval(const dt_drawlayer_brush_dab_t *dab, const float u_in)
Evaluate radial mass primitive from center to normalized radius u_in.
Definition brush_profile.h:121
static float dt_drawlayer_brush_profile_clamp01(const float v)
Clamp scalar value to [0, 1].
Definition brush_profile.h:30
static float dt_drawlayer_brush_transition_mass_primitive_eval(const int shape, const float u, const float inner, const float w, const float base)
Evaluate integrated mass primitive of transition zone by shape.
Definition brush_profile.h:54
static float dt_drawlayer_brush_transition_profile_eval(const int shape, const float t, const float inv_t)
Evaluate normalized edge-falloff transition profile by shape.
Definition brush_profile.h:36
const float delta
Definition colorspaces_inline_conversions.h:722
const int t
Definition iop_profile.h:227
static const float v
Definition iop_profile.h:223
Fully resolved input dab descriptor.
Definition brush.h:66
float radius
Definition brush.h:71
int shape
Definition brush.h:84
float hardness
Definition brush.h:81