Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image_2d.c
| Show First 20 Lines • Show All 413 Lines • ▼ Show 20 Lines | static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, | ||||
| rctf tex_mapping = painter->tex_mapping; | rctf tex_mapping = painter->tex_mapping; | ||||
| struct ImagePool *pool = painter->pool; | struct ImagePool *pool = painter->pool; | ||||
| bool use_color_correction = painter->cache.use_color_correction; | bool use_color_correction = painter->cache.use_color_correction; | ||||
| bool use_float = painter->cache.use_float; | bool use_float = painter->cache.use_float; | ||||
| bool is_texbrush = painter->cache.is_texbrush; | bool is_texbrush = painter->cache.is_texbrush; | ||||
| int x, y, thread = 0; | int x, y, thread = 0; | ||||
| float brush_rgb[3]; | float brush_rgba[4]; | ||||
| /* allocate image buffer */ | /* allocate image buffer */ | ||||
| ImBuf *ibuf = IMB_allocImBuf(size, size, 32, (use_float) ? IB_rectfloat : IB_rect); | ImBuf *ibuf = IMB_allocImBuf(size, size, 32, (use_float) ? IB_rectfloat : IB_rect); | ||||
| /* get brush color */ | /* get brush color */ | ||||
| if (brush->imagepaint_tool == PAINT_TOOL_DRAW) { | if (brush->imagepaint_tool == PAINT_TOOL_DRAW) { | ||||
| paint_brush_color_get(scene, | paint_brush_color_get(scene, | ||||
| brush, | brush, | ||||
| use_color_correction, | use_color_correction, | ||||
| painter->cache.invert, | painter->cache.invert, | ||||
| distance, | distance, | ||||
| pressure, | pressure, | ||||
| brush_rgb, | brush_rgba, | ||||
| display); | display); | ||||
| } | } | ||||
| else { | else { | ||||
| brush_rgb[0] = 1.0f; | brush_rgba[0] = 1.0f; | ||||
| brush_rgb[1] = 1.0f; | brush_rgba[1] = 1.0f; | ||||
| brush_rgb[2] = 1.0f; | brush_rgba[2] = 1.0f; | ||||
| brush_rgba[3] = 1.0f; | |||||
| } | } | ||||
| /* fill image buffer */ | /* fill image buffer */ | ||||
| for (y = 0; y < size; y++) { | for (y = 0; y < size; y++) { | ||||
| for (x = 0; x < size; x++) { | for (x = 0; x < size; x++) { | ||||
| /* sample texture and multiply with brush color */ | /* sample texture and multiply with brush color */ | ||||
| float texco[3], rgba[4]; | float texco[3], rgba[4]; | ||||
| if (is_texbrush) { | if (is_texbrush) { | ||||
| brush_imbuf_tex_co(&tex_mapping, x, y, texco); | brush_imbuf_tex_co(&tex_mapping, x, y, texco); | ||||
| BKE_brush_sample_tex_3d(scene, brush, texco, rgba, thread, pool); | BKE_brush_sample_tex_3d(scene, brush, texco, rgba, thread, pool); | ||||
| /* TODO(sergey): Support texture paint color space. */ | /* TODO(sergey): Support texture paint color space. */ | ||||
| if (!use_float) { | if (!use_float) { | ||||
| IMB_colormanagement_scene_linear_to_display_v3(rgba, display); | IMB_colormanagement_scene_linear_to_display_v3(rgba, display); | ||||
| } | } | ||||
| mul_v3_v3(rgba, brush_rgb); | mul_v3_v3(rgba, brush_rgba); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(rgba, brush_rgb); | copy_v4_v4(rgba, brush_rgba); | ||||
| rgba[3] = 1.0f; | |||||
| } | } | ||||
| if (use_float) { | if (use_float) { | ||||
| /* write to float pixel */ | /* write to float pixel */ | ||||
| float *dstf = ibuf->rect_float + (y * size + x) * 4; | float *dstf = ibuf->rect_float + (y * size + x) * 4; | ||||
| mul_v3_v3fl(dstf, rgba, rgba[3]); /* premultiply */ | mul_v3_v3fl(dstf, rgba, rgba[3]); /* premultiply */ | ||||
| dstf[3] = rgba[3]; | dstf[3] = rgba[3]; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,524 Lines • Show Last 20 Lines | |||||