Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_cursor.c
| Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | static void load_tex_task_cb_ex(void *__restrict userdata, | ||||
| struct ImagePool *pool = data->pool; | struct ImagePool *pool = data->pool; | ||||
| const int size = data->size; | const int size = data->size; | ||||
| const float rotation = data->rotation; | const float rotation = data->rotation; | ||||
| const float radius = data->radius; | const float radius = data->radius; | ||||
| bool convert_to_linear = false; | bool convert_to_linear = false; | ||||
| struct ColorSpace *colorspace = NULL; | struct ColorSpace *colorspace = NULL; | ||||
| const int thread_id = BLI_task_parallel_thread_id(tls); | |||||
| if (mtex->tex && mtex->tex->type == TEX_IMAGE && mtex->tex->ima) { | if (mtex->tex && mtex->tex->type == TEX_IMAGE && mtex->tex->ima) { | ||||
| ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(mtex->tex->ima, &mtex->tex->iuser, pool); | ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(mtex->tex->ima, &mtex->tex->iuser, pool); | ||||
| /* For consistency, sampling always returns color in linear space. */ | /* For consistency, sampling always returns color in linear space. */ | ||||
| if (tex_ibuf && tex_ibuf->rect_float == NULL) { | if (tex_ibuf && tex_ibuf->rect_float == NULL) { | ||||
| convert_to_linear = true; | convert_to_linear = true; | ||||
| colorspace = tex_ibuf->rect_colorspace; | colorspace = tex_ibuf->rect_colorspace; | ||||
| } | } | ||||
| BKE_image_pool_release_ibuf(mtex->tex->ima, tex_ibuf, pool); | BKE_image_pool_release_ibuf(mtex->tex->ima, tex_ibuf, pool); | ||||
| Show All 27 Lines | if (ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL) || len <= 1.0f) { | ||||
| x = len * cosf(angle); | x = len * cosf(angle); | ||||
| y = len * sinf(angle); | y = len * sinf(angle); | ||||
| } | } | ||||
| if (col) { | if (col) { | ||||
| float rgba[4]; | float rgba[4]; | ||||
| paint_get_tex_pixel_col( | paint_get_tex_pixel_col(mtex, x, y, rgba, pool, thread_id, convert_to_linear, colorspace); | ||||
| mtex, x, y, rgba, pool, tls->thread_id, convert_to_linear, colorspace); | |||||
| buffer[index * 4] = rgba[0] * 255; | buffer[index * 4] = rgba[0] * 255; | ||||
| buffer[index * 4 + 1] = rgba[1] * 255; | buffer[index * 4 + 1] = rgba[1] * 255; | ||||
| buffer[index * 4 + 2] = rgba[2] * 255; | buffer[index * 4 + 2] = rgba[2] * 255; | ||||
| buffer[index * 4 + 3] = rgba[3] * 255; | buffer[index * 4 + 3] = rgba[3] * 255; | ||||
| } | } | ||||
| else { | else { | ||||
| float avg = paint_get_tex_pixel(mtex, x, y, pool, tls->thread_id); | float avg = paint_get_tex_pixel(mtex, x, y, pool, thread_id); | ||||
| avg += br->texture_sample_bias; | avg += br->texture_sample_bias; | ||||
| /* Clamp to avoid precision overflow. */ | /* Clamp to avoid precision overflow. */ | ||||
| CLAMP(avg, 0.0f, 1.0f); | CLAMP(avg, 0.0f, 1.0f); | ||||
| buffer[index] = 255 - (GLubyte)(255 * avg); | buffer[index] = 255 - (GLubyte)(255 * avg); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,461 Lines • Show Last 20 Lines | |||||