Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_edit_uv.c
| Show First 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) { | ||||
| ((tile->tile_number - 1001) % 10), ((tile->tile_number - 1001) / 10), 0.0f}; | ((tile->tile_number - 1001) % 10), ((tile->tile_number - 1001) / 10), 0.0f}; | ||||
| DRW_text_cache_add( | DRW_text_cache_add( | ||||
| dt, tile_location, text, strlen(text), 10, 10, DRW_TEXT_CACHE_GLOBALSPACE, color); | dt, tile_location, text, strlen(text), 10, 10, DRW_TEXT_CACHE_GLOBALSPACE, color); | ||||
| } | } | ||||
| } | } | ||||
| if (pd->edit_uv.do_stencil_overlay) { | if (pd->edit_uv.do_stencil_overlay) { | ||||
| const Brush *brush = BKE_paint_brush(&ts->imapaint.paint); | const Brush *brush = BKE_paint_brush(&ts->imapaint.paint); | ||||
| Image *stencil_image = brush->clone.image; | |||||
| ImBuf *stencil_ibuf = BKE_image_acquire_ibuf(stencil_image, NULL, &pd->edit_uv.stencil_lock); | |||||
| if (stencil_ibuf == NULL) { | |||||
| pd->edit_uv.stencil_ibuf = NULL; | |||||
| pd->edit_uv.stencil_image = NULL; | |||||
| } | |||||
| else { | |||||
| DRW_PASS_CREATE(psl->edit_uv_stencil_ps, | DRW_PASS_CREATE(psl->edit_uv_stencil_ps, | ||||
| DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA_PREMUL); | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | | ||||
| DRW_STATE_BLEND_ALPHA_PREMUL); | |||||
| GPUShader *sh = OVERLAY_shader_edit_uv_stencil_image(); | GPUShader *sh = OVERLAY_shader_edit_uv_stencil_image(); | ||||
| GPUBatch *geom = DRW_cache_quad_get(); | GPUBatch *geom = DRW_cache_quad_get(); | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->edit_uv_stencil_ps); | DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->edit_uv_stencil_ps); | ||||
| Image *stencil_image = brush->clone.image; | |||||
| ImBuf *stencil_ibuf = BKE_image_acquire_ibuf(stencil_image, NULL, &pd->edit_uv.stencil_lock); | |||||
| pd->edit_uv.stencil_ibuf = stencil_ibuf; | pd->edit_uv.stencil_ibuf = stencil_ibuf; | ||||
| pd->edit_uv.stencil_image = stencil_image; | pd->edit_uv.stencil_image = stencil_image; | ||||
| GPUTexture *stencil_texture = BKE_image_get_gpu_texture(stencil_image, NULL, stencil_ibuf); | GPUTexture *stencil_texture = BKE_image_get_gpu_texture(stencil_image, NULL, stencil_ibuf); | ||||
| DRW_shgroup_uniform_texture(grp, "imgTexture", stencil_texture); | DRW_shgroup_uniform_texture(grp, "imgTexture", stencil_texture); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "imgPremultiplied", true); | DRW_shgroup_uniform_bool_copy(grp, "imgPremultiplied", true); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "imgAlphaBlend", true); | DRW_shgroup_uniform_bool_copy(grp, "imgAlphaBlend", true); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){1.0f, 1.0f, 1.0f, brush->clone.alpha}); | DRW_shgroup_uniform_vec4_copy( | ||||
| grp, "color", (float[4]){1.0f, 1.0f, 1.0f, brush->clone.alpha}); | |||||
| float size_image[2]; | float size_image[2]; | ||||
| BKE_image_get_size_fl(image, NULL, size_image); | BKE_image_get_size_fl(image, NULL, size_image); | ||||
| float size_stencil_image[2] = {stencil_ibuf->x, stencil_ibuf->y}; | float size_stencil_image[2] = {stencil_ibuf->x, stencil_ibuf->y}; | ||||
| float obmat[4][4]; | float obmat[4][4]; | ||||
| unit_m4(obmat); | unit_m4(obmat); | ||||
| obmat[3][1] = brush->clone.offset[1]; | obmat[3][1] = brush->clone.offset[1]; | ||||
| obmat[3][0] = brush->clone.offset[0]; | obmat[3][0] = brush->clone.offset[0]; | ||||
| obmat[0][0] = size_stencil_image[0] / size_image[0]; | obmat[0][0] = size_stencil_image[0] / size_image[0]; | ||||
| obmat[1][1] = size_stencil_image[1] / size_image[1]; | obmat[1][1] = size_stencil_image[1] / size_image[1]; | ||||
| DRW_shgroup_call_obmat(grp, geom, obmat); | DRW_shgroup_call_obmat(grp, geom, obmat); | ||||
| } | } | ||||
| } | |||||
| else { | else { | ||||
| pd->edit_uv.stencil_ibuf = NULL; | pd->edit_uv.stencil_ibuf = NULL; | ||||
| pd->edit_uv.stencil_image = NULL; | pd->edit_uv.stencil_image = NULL; | ||||
| } | } | ||||
| if (pd->edit_uv.do_mask_overlay) { | if (pd->edit_uv.do_mask_overlay) { | ||||
| const bool is_combined_overlay = pd->edit_uv.mask_overlay_mode == MASK_OVERLAY_COMBINED; | const bool is_combined_overlay = pd->edit_uv.mask_overlay_mode == MASK_OVERLAY_COMBINED; | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS; | ||||
| ▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines | |||||