48 paint_mode_settings, ob, &r_image_data->
image, &r_image_data->
image_user);
67 pixel_offset = int(image_pixel_position.y) * image_buffer->
x + int(image_pixel_position.x);
77 return &image_buffer->
rect_float[pixel_offset * 4];
99 pixel_offset = int(image_pixel_position.y) * image_buffer->
x + int(image_pixel_position.x);
111 static_cast<const uchar *
>(
112 static_cast<const void *
>(&(image_buffer->
rect[pixel_offset]))));
119 static_cast<uchar *
>(
static_cast<void *
>(&image_buffer->
rect[pixel_offset])), pixel_data);
129 ImageBuffer image_accessor;
142 void *last_used_image_buffer_ptr =
nullptr;
143 const char *last_used_color_space =
nullptr;
152 init_brush_strength();
160 float3 pixel_pos = get_start_pixel_pos(triangle, pixel_row);
161 const float3 delta_pixel_pos = get_delta_pixel_pos(triangle, pixel_row, pixel_pos);
162 bool pixels_painted =
false;
164 if (!brush_test_fn(&test, pixel_pos)) {
165 pixel_pos += delta_pixel_pos;
166 image_accessor.next_pixel();
170 float4 color = image_accessor.read_pixel(image_buffer);
172 const float3 face_normal(0.0f, 0.0f, 0.0f);
173 const float mask = 0.0f;
179 buffer_color *= brush->
alpha;
181 image_accessor.write_pixel(image_buffer,
color);
182 pixels_painted =
true;
184 image_accessor.next_pixel();
185 pixel_pos += delta_pixel_pos;
187 return pixels_painted;
192 const char *to_colorspace = image_accessor.get_colorspace_name(image_buffer);
193 if (last_used_color_space == to_colorspace) {
204 brush_color[3] = 1.0f;
209 from_colorspace, to_colorspace);
212 last_used_color_space = to_colorspace;
216 void init_brush_strength()
220 void init_brush_test()
240 const float3 &start_pixel)
const
244 return result - start_pixel;
256 mvert[vert_indices[0]].co,
257 mvert[vert_indices[1]].co,
258 mvert[vert_indices[2]].co,
268 std::vector<bool> brush_test(triangles.
size());
277 for (
int triangle_index = 0; triangle_index < triangles.
size(); triangle_index++) {
281 float3 triangle_max_bounds(triangle_min_bounds);
282 for (
int i = 1; i < 3; i++) {
284 triangle_min_bounds.x =
min_ff(triangle_min_bounds.x,
pos.x);
285 triangle_min_bounds.y =
min_ff(triangle_min_bounds.y,
pos.y);
286 triangle_min_bounds.z =
min_ff(triangle_min_bounds.z,
pos.z);
287 triangle_max_bounds.x =
max_ff(triangle_max_bounds.x,
pos.x);
288 triangle_max_bounds.y =
max_ff(triangle_max_bounds.y,
pos.y);
289 triangle_max_bounds.z =
max_ff(triangle_max_bounds.z,
pos.z);
292 brush_min_bounds, brush_max_bounds, triangle_min_bounds, triangle_max_bounds);
317 bool pixels_updated =
false;
325 if (image_buffer ==
nullptr) {
340 bool pixels_painted =
false;
342 pixels_painted = kernel_float4.
paint(node_data.
triangles, pixel_row, image_buffer);
345 pixels_painted = kernel_byte4.
paint(node_data.
triangles, pixel_row, image_buffer);
348 if (pixels_painted) {
364 ImBuf *ibuf,
int x,
int y,
int w,
int h,
int *tx,
int *ty,
int *tw,
int *th)
366 int srcx = 0, srcy = 0;
385 int tilex, tiley, tilew, tileh;
396 for (
int ty = tiley; ty <= tileh; ty++) {
397 for (
int tx = tilex; tx <= tilew; tx++) {
425 ImBuf *tmpibuf =
nullptr;
426 ImageUser local_image_user = *image_user;
431 if (image_buffer ==
nullptr) {
435 push_undo(node_data, *
image, *image_user, image_tile, *image_buffer, &tmpibuf);
464 *r_image_user =
nullptr;
471 *r_image = image_data.
image;
478 if (!
U.experimental.use_sculpt_texture_paint) {
const float * BKE_brush_secondary_color_get(const struct Scene *scene, const struct Brush *brush)
const float * BKE_brush_color_get(const struct Scene *scene, const struct Brush *brush)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
General operations, lookup, etc. for materials.
bool BKE_paint_canvas_image_get(struct PaintModeSettings *settings, struct Object *ob, struct Image **r_image, struct ImageUser **r_image_user)
struct Brush * BKE_paint_brush(struct Paint *paint)
A BVH for high poly meshes.
void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings, bool use_threading, int totnode)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
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])
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)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
int BLI_task_parallel_thread_id(const TaskParallelTLS *tls)
Object is a sort of wrapper for general info.
struct PaintTileMap * ED_image_paint_tile_map_get(void)
void * ED_image_paint_tile_push(PaintTileMap *paint_tile_map, struct Image *image, struct ImBuf *ibuf, struct ImBuf **tmpibuf, struct ImageUser *iuser, int x_tile, int y_tile, unsigned short **r_mask, bool **r_valid, bool use_thread_lock, bool find_prev)
#define ED_IMAGE_UNDO_TILE_BITS
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
const char * IMB_colormanagement_get_rect_colorspace(struct ImBuf *ibuf)
struct ColormanageProcessor * IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace)
@ COLOR_ROLE_SCENE_LINEAR
void IMB_colormanagement_processor_free(struct ColormanageProcessor *cm_processor)
void IMB_colormanagement_processor_apply_v4(struct ColormanageProcessor *cm_processor, float pixel[4])
const char * IMB_colormanagement_role_colorspace_name_get(int role)
const char * IMB_colormanagement_get_float_colorspace(struct ImBuf *ibuf)
void IMB_rectclip(struct ImBuf *dbuf, const struct 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)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
const char * get_colorspace_name(ImBuf *image_buffer)
float4 read_pixel(ImBuf *image_buffer) const
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 Triangles &triangles, const PackedPixelRow &pixel_row, ImBuf *image_buffer)
PaintingKernel(SculptSession *ss, const Brush *brush, const int thread_id, const MVert *mvert)
void init_brush_color(ImBuf *image_buffer)
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
IconTextureDrawCall normal
ccl_global const KernelWorkTile * tile
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static bool barycentric_weights(const float v1[3], const float v2[3], const float v3[3], const float co[3], const float n[3], float w[3])
NodeData & BKE_pbvh_pixels_node_data_get(PBVHNode &node)
void BKE_pbvh_pixels_mark_image_dirty(PBVHNode &node, Image &image, ImageUser &image_user)
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 do_paint_pixels(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict tls)
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_mark_dirty_regions(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
static void do_push_undo_tile(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
static std::vector< bool > init_triangle_brush_test(SculptSession *ss, Triangles &triangles, const MVert *mvert)
thread_local int thread_id
SculptBrushTestFn SCULPT_brush_test_init_with_falloff_shape(SculptSession *ss, SculptBrushTest *test, char falloff_shape)
float SCULPT_brush_strength_factor(SculptSession *ss, const Brush *br, const float brush_point[3], const float len, const float vno[3], const float fno[3], const float mask, const int vertex_index, const int thread_id)
void SCULPT_brush_test_init(SculptSession *ss, SculptBrushTest *test)
MVert * SCULPT_mesh_deformed_mverts_get(SculptSession *ss)
static float brush_strength(const Sculpt *sd, const StrokeCache *cache, const float feather, const UnifiedPaintSettings *ups, const PaintModeSettings *UNUSED(paint_mode_settings))
bool(* SculptBrushTestFn)(SculptBrushTest *test, const float co[3])
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.
bool SCULPT_use_image_paint_brush(PaintModeSettings *settings, Object *ob)
void SCULPT_do_paint_brush_image(PaintModeSettings *paint_mode_settings, Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
struct SculptSession * sculpt
struct StrokeCache * cache
int get_tile_number() const
Vector< UDIMTileUndo > undo_regions
struct blender::bke::pbvh::pixels::NodeData::@58 flags
Vector< UDIMTilePixels > tiles
ushort2 start_image_coordinate
float2 start_barycentric_coord
TrianglePaintInput & get_paint_input(const int index)
Vector< PackedPixelRow > pixel_rows
void mark_dirty(const PackedPixelRow &pixel_row)
struct blender::bke::pbvh::pixels::UDIMTilePixels::@57 flags
static bool init_active_image(Object *ob, ImageData *r_image_data, PaintModeSettings *paint_mode_settings)