17#ifdef DEBUG_PIXEL_NODES
51 &paint_mode_settings, &ob, &r_image_data->
image, &r_image_data->
image_user);
63 pixel_offset =
int(image_pixel_position.y) * image_buffer->
x +
int(image_pixel_position.x);
95 pixel_offset =
int(image_pixel_position.y) * image_buffer->
x +
int(image_pixel_position.x);
107 static_cast<const uchar *
>(
static_cast<const void *
>(
128 const float2 &barycentric_weight)
130 const int3 &
verts = vert_tris[tri_index];
131 const float3 weights(barycentric_weight.x,
132 barycentric_weight.y,
133 1.0f - barycentric_weight.x - barycentric_weight.y);
136 vert_positions[
verts[0]],
137 vert_positions[
verts[1]],
138 vert_positions[
verts[2]],
161 positions[i] = start + delta * i;
166 ImageBuffer image_accessor_;
170 const char *last_used_color_space_ =
nullptr;
181 bool pixels_painted =
false;
182 for (
int x = 0; x < pixel_row.
num_pixels; x++) {
183 float4 color = image_accessor_.read_pixel(image_buffer);
184 float4 paint_color = brush_color_ * factors[
x];
187#ifdef DEBUG_PIXEL_NODES
189 paint_color[0] *= 0.5f;
190 paint_color[1] *= 0.5f;
191 paint_color[2] *= 0.5f;
196 buffer_color *= brush.
alpha;
198 image_accessor_.write_pixel(image_buffer, color);
199 pixels_painted =
true;
201 image_accessor_.next_pixel();
203 return pixels_painted;
208 const char *to_colorspace = image_accessor_.get_colorspace_name(image_buffer);
209 if (last_used_color_space_ == to_colorspace) {
218 brush_color_[3] = 1.0f;
223 from_colorspace, to_colorspace);
226 last_used_color_space_ = to_colorspace;
237 const Bounds<float3> brush_bounds(location - radius, location + radius);
277#ifdef DEBUG_PIXEL_NODES
280 brush_color[0] =
float(
hash & 255) / 255.0f;
281 brush_color[1] =
float((
hash >> 8) & 255) / 255.0f;
282 brush_color[2] =
float((
hash >> 16) & 255) / 255.0f;
289 brush_color[3] = 1.0f;
296 bool pixels_updated =
false;
304 if (image_buffer ==
nullptr) {
316 if (!brush_test[pixel_row.uv_primitive_index]) {
320 pixel_positions.
resize(pixel_row.num_pixels);
336 bool pixels_painted =
false;
338 pixels_painted = kernel_float4.
paint(brush, pixel_row, factors, image_buffer);
341 pixels_painted = kernel_byte4.
paint(brush, pixel_row, factors, image_buffer);
344 if (pixels_painted) {
345 tile_data.mark_dirty(pixel_row);
350 pixels_updated |= tile_data.flags.dirty;
360 ImBuf *ibuf,
int x,
int y,
int w,
int h,
int *tx,
int *ty,
int *tw,
int *th)
362 int srcx = 0, srcy = 0;
381 int tilex, tiley, tilew, tileh;
384 tile_undo.region.xmin,
385 tile_undo.region.ymin,
392 for (
int ty = tiley; ty <= tileh; ty++) {
393 for (
int tx = tilex; tx <= tilew; tx++) {
414 ImBuf *tmpibuf =
nullptr;
420 if (image_buffer ==
nullptr) {
424 push_undo(node_data, image, image_user, image_tile, *image_buffer, &tmpibuf);
477 *r_image_user =
nullptr;
484 *r_image = image_data.
image;
491 if (!
U.experimental.use_sculpt_texture_paint) {
530 bke::pbvh::pixels::mark_image_dirty(nodes[i], *image_data.
image, *image_data.
image_user);
const float * BKE_brush_secondary_color_get(const Scene *scene, const Paint *paint, const Brush *brush)
const float * BKE_brush_color_get(const Scene *scene, const Paint *paint, const Brush *brush)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
bool BKE_paint_canvas_image_get(PaintModeSettings *settings, Object *ob, Image **r_image, ImageUser **r_image_user)
A BVH for high poly meshes.
BLI_INLINE unsigned int BLI_hash_int(unsigned int k)
#define LISTBASE_FOREACH(type, var, list)
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
bool isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
#define POINTER_AS_UINT(i)
Object is a sort of wrapper for general info.
void * ED_image_paint_tile_push(PaintTileMap *paint_tile_map, Image *image, ImBuf *ibuf, ImBuf **tmpibuf, ImageUser *iuser, int x_tile, int y_tile, unsigned short **r_mask, bool **r_valid, bool use_thread_lock, bool find_prev)
PaintTileMap * ED_image_paint_tile_map_get()
#define ED_IMAGE_UNDO_TILE_BITS
ColormanageProcessor * IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace)
const char * IMB_colormanagement_role_colorspace_name_get(int role)
@ COLOR_ROLE_SCENE_LINEAR
void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor)
const char * IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4])
const char * IMB_colormanagement_get_float_colorspace(ImBuf *ibuf)
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
void IMB_blend_color_float(float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
constexpr int64_t size() const
constexpr IndexRange index_range() const
void resize(const int64_t new_size)
void fill(const T &value) const
Span< NodeT > nodes() const
float4 read_pixel(ImBuf *image_buffer) const
const char * get_colorspace_name(ImBuf *image_buffer)
void write_pixel(ImBuf *image_buffer, const float4 pixel_data) const
void set_image_position(ImBuf *image_buffer, ushort2 image_pixel_position)
const char * get_colorspace_name(ImBuf *image_buffer)
float4 read_pixel(ImBuf *image_buffer) const
void set_image_position(ImBuf *image_buffer, ushort2 image_pixel_position)
void write_pixel(ImBuf *image_buffer, const float4 pixel_data) const
bool paint(const Brush &brush, const PackedPixelRow &pixel_row, const Span< float > factors, ImBuf *image_buffer)
void init_brush_color(ImBuf *image_buffer, float in_brush_color[3])
void foreach_index(Fn &&fn) const
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
const Depsgraph * depsgraph
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void IMB_freeImBuf(ImBuf *)
ccl_global const KernelWorkTile * tile
pbvh::Tree * pbvh_get(Object &object)
NodeData & node_data_get(blender::bke::pbvh::Node &node)
void copy_pixels(blender::bke::pbvh::Tree &pbvh, Image &image, ImageUser &image_user, image::TileNumber tile_number)
void collect_dirty_tiles(blender::bke::pbvh::Node &node, Vector< image::TileNumber > &r_dirty_tiles)
PBVHData & data_get(blender::bke::pbvh::Tree &pbvh)
Span< float3 > vert_positions_eval(const Depsgraph &depsgraph, const Object &object_orig)
static void fix_non_manifold_seam_bleeding(bke::pbvh::Tree &pbvh, Image &image, ImageUser &image_user, Span< TileNumber > tile_numbers_to_fix)
static float3 calc_pixel_position(const Span< float3 > vert_positions, const Span< int3 > vert_tris, const int tri_index, const float2 &barycentric_weight)
static void do_paint_pixels(const Scene &scene, const Depsgraph &depsgraph, Object &object, const Paint &paint, const Brush &brush, ImageData image_data, bke::pbvh::Node &node)
static BitVector init_uv_primitives_brush_test(SculptSession &ss, const Span< int3 > vert_tris, const Span< UVPrimitivePaintInput > uv_primitives, const Span< float3 > positions)
static void calc_pixel_row_positions(const Span< float3 > vert_positions, const Span< int3 > vert_tris, const Span< UVPrimitivePaintInput > uv_primitives, const PackedPixelRow &pixel_row, const MutableSpan< float3 > positions)
static void push_undo(const NodeData &node_data, Image &image, ImageUser &image_user, const image::ImageTileWrapper &image_tile, ImBuf &image_buffer, ImBuf **tmpibuf)
static void undo_region_tiles(ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th)
static void do_push_undo_tile(Image &image, ImageUser &image_user, bke::pbvh::Node &node)
void calc_brush_strength_factors(const StrokeCache &cache, const Brush &brush, Span< float > distances, MutableSpan< float > factors)
void apply_hardness_to_distances(float radius, float hardness, MutableSpan< float > distances)
void filter_distances_with_radius(float radius, Span< float > distances, MutableSpan< float > factors)
void calc_brush_distances(const SculptSession &ss, Span< float3 > vert_positions, Span< int > vert_indices, eBrushFalloffShape falloff_shape, MutableSpan< float > r_distances)
void scale_factors(MutableSpan< float > factors, float strength)
void calc_brush_texture_factors(const SculptSession &ss, const Brush &brush, Span< float3 > vert_positions, Span< int > vert_indices, MutableSpan< float > factors)
void min_max(const T &value, T &min, T &max)
bool SCULPT_paint_image_canvas_get(PaintModeSettings &paint_mode_settings, Object &ob, Image **r_image, ImageUser **r_image_user)
Get the image canvas for painting on the given object.
void SCULPT_do_paint_brush_image(const Scene &scene, const Depsgraph &depsgraph, PaintModeSettings &paint_mode_settings, const Sculpt &sd, Object &ob, const blender::IndexMask &node_mask)
bool SCULPT_use_image_paint_brush(PaintModeSettings &settings, Object &ob)
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
blender::ed::sculpt_paint::StrokeCache * cache
blender::float3 cursor_location
TileNumber get_tile_number() const
Vector< UDIMTileUndo > undo_regions
struct blender::bke::pbvh::pixels::NodeData::@53 flags
Vector< UVPrimitivePaintInput > uv_primitives
Vector< UDIMTilePixels > tiles
ushort2 start_image_coordinate
ushort uv_primitive_index
float2 start_barycentric_coord
static bool init_active_image(Object &ob, ImageData *r_image_data, PaintModeSettings &paint_mode_settings)