93 const int mode =
data->filter_type;
101 float orig_color[3], final_color[4], hsv_color[3];
103 float brightness, contrast, gain, delta,
offset;
113 final_color[3] = orig_data.
col[3];
117 float fill_color_rgba[4];
119 fill_color_rgba[3] = 1.0f;
128 hsv_color[0] = fmod((hsv_color[0] +
fabs(
fade)) -
hue, 1);
134 if (hsv_color[1] > 0.001f) {
135 hsv_color[1] =
clamp_f(hsv_color[1] +
fade * hsv_color[1], 0.0f, 1.0f);
144 hsv_color[2] =
clamp_f(hsv_color[2] +
fade, 0.0f, 1.0f);
148 orig_color[0] =
clamp_f(orig_color[0] +
fade, 0.0f, 1.0f);
152 orig_color[1] =
clamp_f(orig_color[1] +
fade, 0.0f, 1.0f);
156 orig_color[2] =
clamp_f(orig_color[2] +
fade, 0.0f, 1.0f);
163 delta = contrast / 2.0f;
164 gain = 1.0f - delta * 2.0f;
166 offset = gain * (brightness + delta);
167 for (
int i = 0; i < 3; i++) {
168 final_color[i] =
clamp_f(gain * orig_color[i] +
offset, 0.0f, 1.0f);
175 delta = contrast / 2.0f;
176 gain = 1.0f - delta * 2.0f;
178 gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON);
179 offset = gain * (brightness - delta);
183 offset = gain * (brightness + delta);
185 for (
int i = 0; i < 3; i++) {
186 final_color[i] =
clamp_f(gain * orig_color[i] +
offset, 0.0f, 1.0f);
191 float smooth_color[4];
201 bool copy_alpha =
col[3] == smooth_color[3];
204 float delta_color[4];
217 CLAMP4(final_color, 0.0f, 1.0f);
221 final_color[3] = smooth_color[3];
239 totvert,
sizeof(
float) * 4,
"ss->filter_cache->pre_smoothed_color");
242 for (
int i = 0; i < totvert; i++) {
246 for (
int iteration = 0; iteration < 2; iteration++) {
247 for (
int i = 0; i < totvert; i++) {
248 float avg[4] = {0.0f, 0.0f, 0.0f, 0.0f};
292 const float len =
event->prev_press_xy[0] -
event->xy[0];
293 filter_strength = filter_strength * -
len * 0.001f;
299 if (filter_strength < 0.0 && !ss->filter_cache->pre_smoothed_color) {
308 .filter_strength = filter_strength,
309 .filter_fill_color = fill_color,
335 if (use_automasking) {
373 ot->
name =
"Filter Color";
374 ot->
idname =
"SCULPT_OT_color_filter";
375 ot->
description =
"Applies a filter to modify the active color attribute";
387 ot->
srna,
"strength", 1.0f, -10.0f, 10.0f,
"Strength",
"Filter strength", -10.0f, 10.0f);
390 ot->
srna,
"fill_color", 3,
NULL, 0.0f, FLT_MAX,
"Fill Color",
"", 0.0f, 1.0f);
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
General operations, lookup, etc. for blender objects.
void BKE_sculpt_update_object_for_edit(struct Depsgraph *depsgraph, struct Object *ob_orig, bool need_pmap, bool need_mask, bool is_paint_tool)
#define SCULPT_FACE_SET_NONE
void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
A BVH for high poly meshes.
#define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode)
void BKE_pbvh_node_mark_update_color(PBVHNode *node)
PBVHType BKE_pbvh_type(const PBVH *pbvh)
#define BKE_pbvh_vertex_iter_end
void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings, bool use_threading, int totnode)
MINLINE float clamp_f(float value, float min, float max)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
MINLINE void mul_v4_fl(float r[4], float f)
MINLINE void add_v4_v4(float r[4], const float a[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], float t)
MINLINE void sub_v4_v4(float r[4], const float a[4])
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
#define CLAMP4(vec, b, c)
struct Depsgraph Depsgraph
@ V3D_SHADING_VERTEX_COLOR
void ED_paint_tool_update_sticky_shading_color(struct bContext *C, struct Object *ob)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its hue
const Depsgraph * depsgraph
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
ccl_device_inline float2 fabs(const float2 &a)
CCL_NAMESPACE_BEGIN ccl_device float fade(float t)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
float RNA_float_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
int SCULPT_vertex_count_get(SculptSession *ss)
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter)
void SCULPT_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node, SculptUndoType type)
bool SCULPT_cursor_geometry_info_update(bContext *C, SculptCursorGeometryInfo *out, const float mval[2], bool use_sampled_normal)
void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags)
void SCULPT_vertex_color_set(SculptSession *ss, int index, const float color[4])
void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags)
void SCULPT_vertex_color_get(const SculptSession *ss, int index, float r_color[4])
bool SCULPT_mode_poll(bContext *C)
bool SCULPT_handles_colors_report(SculptSession *ss, ReportList *reports)
float SCULPT_automasking_factor_get(AutomaskingCache *automasking, SculptSession *ss, int vert)
AutomaskingCache * SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object *ob)
bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br)
static int sculpt_color_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void color_filter_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
@ COLOR_FILTER_BRIGHTNESS
@ COLOR_FILTER_SATURATION
static void sculpt_color_presmooth_init(SculptSession *ss)
void SCULPT_OT_color_filter(struct wmOperatorType *ot)
static int sculpt_color_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static EnumPropertyItem prop_color_filter_types[]
void SCULPT_filter_cache_init(bContext *C, Object *ob, Sculpt *sd, const int undo_type)
void SCULPT_filter_cache_free(SculptSession *ss)
void SCULPT_undo_push_begin(struct Object *ob, const char *name)
void SCULPT_undo_push_end(struct Object *ob)
#define SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN(ss, v_index, neighbor_iterator)
#define SCULPT_VERTEX_NEIGHBORS_ITER_END(neighbor_iterator)
void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], int index)
AutomaskingCache * automasking
float(* pre_smoothed_color)[4]
struct SculptSession * sculpt
struct MeshElemMap * pmap
struct FilterCache * filter_cache
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)