Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_paint.c
| Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) | ||||
| psl->paint_depth_ps = NULL; | psl->paint_depth_ps = NULL; | ||||
| switch (pd->ctx_mode) { | switch (pd->ctx_mode) { | ||||
| case CTX_MODE_POSE: | case CTX_MODE_POSE: | ||||
| case CTX_MODE_EDIT_MESH: | case CTX_MODE_EDIT_MESH: | ||||
| case CTX_MODE_PAINT_WEIGHT: { | case CTX_MODE_PAINT_WEIGHT: { | ||||
| opacity = is_edit_mode ? 1.0 : pd->overlay.weight_paint_mode_opacity; | opacity = is_edit_mode ? 1.0 : pd->overlay.weight_paint_mode_opacity; | ||||
| if (opacity > 0.0f) { | if (opacity > 0.0f) { | ||||
| state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL; | state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA; | ||||
| state |= pd->painting.alpha_blending ? DRW_STATE_BLEND_ALPHA : DRW_STATE_BLEND_MUL; | |||||
| DRW_PASS_CREATE(psl->paint_color_ps, state | pd->clipping_state); | DRW_PASS_CREATE(psl->paint_color_ps, state | pd->clipping_state); | ||||
| sh = OVERLAY_shader_paint_weight(); | const bool do_shading = draw_ctx->v3d->shading.type != OB_WIRE; | ||||
| sh = OVERLAY_shader_paint_weight(do_shading); | |||||
| pd->paint_surf_grp = grp = DRW_shgroup_create(sh, psl->paint_color_ps); | pd->paint_surf_grp = grp = DRW_shgroup_create(sh, psl->paint_color_ps); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "drawContours", draw_contours); | DRW_shgroup_uniform_bool_copy(grp, "drawContours", draw_contours); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "useAlphaBlend", pd->painting.alpha_blending); | |||||
| DRW_shgroup_uniform_float_copy(grp, "opacity", opacity); | DRW_shgroup_uniform_float_copy(grp, "opacity", opacity); | ||||
| DRW_shgroup_uniform_texture(grp, "colorramp", G_draw.weight_ramp); | DRW_shgroup_uniform_texture(grp, "colorramp", G_draw.weight_ramp); | ||||
| /* Arbitrary light to give a hint of the geometry behind the weights. */ | |||||
| if (do_shading) { | |||||
| float light_dir[3]; | |||||
| copy_v3_fl3(light_dir, 0.0f, 0.5f, 0.86602f); | |||||
| normalize_v3(light_dir); | |||||
| DRW_shgroup_uniform_vec3_copy(grp, "light_dir", light_dir); | |||||
| } | |||||
| if (pd->painting.alpha_blending) { | if (pd->painting.alpha_blending) { | ||||
| state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; | state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; | ||||
| DRW_PASS_CREATE(psl->paint_depth_ps, state | pd->clipping_state); | DRW_PASS_CREATE(psl->paint_depth_ps, state | pd->clipping_state); | ||||
| sh = OVERLAY_shader_depth_only(); | sh = OVERLAY_shader_depth_only(); | ||||
| pd->paint_depth_grp = DRW_shgroup_create(sh, psl->paint_depth_ps); | pd->paint_depth_grp = DRW_shgroup_create(sh, psl->paint_depth_ps); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | |||||
| void OVERLAY_paint_draw(OVERLAY_Data *vedata) | void OVERLAY_paint_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_StorageList *stl = vedata->stl; | OVERLAY_StorageList *stl = vedata->stl; | ||||
| OVERLAY_PrivateData *pd = stl->pd; | OVERLAY_PrivateData *pd = stl->pd; | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_FramebufferList *fbl = vedata->fbl; | OVERLAY_FramebufferList *fbl = vedata->fbl; | ||||
| DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | |||||
| if (DRW_state_is_fbo()) { | if (DRW_state_is_fbo()) { | ||||
| if (pd->painting.alpha_blending) { | |||||
| GPU_framebuffer_bind(pd->painting.in_front ? fbl->overlay_in_front_fb : | GPU_framebuffer_bind(pd->painting.in_front ? fbl->overlay_in_front_fb : | ||||
| fbl->overlay_default_fb); | fbl->overlay_default_fb); | ||||
| } | } | ||||
| else { | |||||
| /* Paint overlay needs final color because of multiply blend mode. */ | |||||
| GPU_framebuffer_bind(pd->painting.in_front ? dfbl->in_front_fb : dfbl->default_fb); | |||||
| } | |||||
| } | |||||
| if (psl->paint_depth_ps) { | if (psl->paint_depth_ps) { | ||||
| DRW_draw_pass(psl->paint_depth_ps); | DRW_draw_pass(psl->paint_depth_ps); | ||||
| } | } | ||||
| if (psl->paint_color_ps) { | if (psl->paint_color_ps) { | ||||
| DRW_draw_pass(psl->paint_color_ps); | DRW_draw_pass(psl->paint_color_ps); | ||||
| } | } | ||||
| if (psl->paint_overlay_ps) { | if (psl->paint_overlay_ps) { | ||||
| DRW_draw_pass(psl->paint_overlay_ps); | DRW_draw_pass(psl->paint_overlay_ps); | ||||
| } | } | ||||
| } | } | ||||