Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/gpencil/gpencil_draw_utils.c
| Show First 20 Lines • Show All 408 Lines • ▼ Show 20 Lines | static void set_wireframe_color(Object *ob, | ||||
| /* if solid, the alpha must be set to alpha */ | /* if solid, the alpha must be set to alpha */ | ||||
| if (stl->shgroups[id].shading_type[0] == OB_SOLID) { | if (stl->shgroups[id].shading_type[0] == OB_SOLID) { | ||||
| stl->shgroups[id].wire_color[3] = 1.0f; | stl->shgroups[id].wire_color[3] = 1.0f; | ||||
| } | } | ||||
| } | } | ||||
| /* create shading group for filling */ | /* create shading group for filling */ | ||||
| static DRWShadingGroup *gpencil_shgroup_fill_create(GPENCIL_Data *vedata, | static DRWShadingGroup *gpencil_shgroup_fill_create(GPENCIL_e_data *e_data, | ||||
| GPENCIL_Data *vedata, | |||||
| DRWPass *pass, | DRWPass *pass, | ||||
| GPUShader *shader, | GPUShader *shader, | ||||
| Object *ob, | Object *ob, | ||||
| float (*obmat)[4], | float (*obmat)[4], | ||||
| bGPdata *gpd, | bGPdata *gpd, | ||||
| bGPDlayer *gpl, | bGPDlayer *gpl, | ||||
| MaterialGPencilStyle *gp_style, | MaterialGPencilStyle *gp_style, | ||||
| int id, | int id, | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | else { | ||||
| stl->shgroups[id].texture_clamp = gp_style->flag & GP_STYLE_COLOR_TEX_CLAMP ? 1 : 0; | stl->shgroups[id].texture_clamp = gp_style->flag & GP_STYLE_COLOR_TEX_CLAMP ? 1 : 0; | ||||
| DRW_shgroup_uniform_int(grp, "texture_clamp", &stl->shgroups[id].texture_clamp, 1); | DRW_shgroup_uniform_int(grp, "texture_clamp", &stl->shgroups[id].texture_clamp, 1); | ||||
| BKE_image_release_ibuf(image, ibuf, NULL); | BKE_image_release_ibuf(image, ibuf, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* if no texture defined, need a blank texture to avoid errors in draw manager */ | /* if no texture defined, need a blank texture to avoid errors in draw manager */ | ||||
| DRW_shgroup_uniform_texture(grp, "myTexture", stl->g_data->gpencil_blank_texture); | DRW_shgroup_uniform_texture(grp, "myTexture", e_data->gpencil_blank_texture); | ||||
| stl->shgroups[id].texture_clamp = 0; | stl->shgroups[id].texture_clamp = 0; | ||||
| DRW_shgroup_uniform_int(grp, "texture_clamp", &stl->shgroups[id].texture_clamp, 1); | DRW_shgroup_uniform_int(grp, "texture_clamp", &stl->shgroups[id].texture_clamp, 1); | ||||
| } | } | ||||
| return grp; | return grp; | ||||
| } | } | ||||
| /* check if some onion is enabled */ | /* check if some onion is enabled */ | ||||
| bool gpencil_onion_active(bGPdata *gpd) | bool gpencil_onion_active(bGPdata *gpd) | ||||
| { | { | ||||
| for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| if (gpl->onion_flag & GP_LAYER_ONIONSKIN) { | if (gpl->onion_flag & GP_LAYER_ONIONSKIN) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* create shading group for strokes */ | /* create shading group for strokes */ | ||||
| DRWShadingGroup *gpencil_shgroup_stroke_create(GPENCIL_Data *vedata, | DRWShadingGroup *gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data, | ||||
| GPENCIL_Data *vedata, | |||||
| DRWPass *pass, | DRWPass *pass, | ||||
| GPUShader *shader, | GPUShader *shader, | ||||
| Object *ob, | Object *ob, | ||||
| float (*obmat)[4], | float (*obmat)[4], | ||||
| bGPdata *gpd, | bGPdata *gpd, | ||||
| bGPDlayer *gpl, | bGPDlayer *gpl, | ||||
| bGPDstroke *gps, | bGPDstroke *gps, | ||||
| MaterialGPencilStyle *gp_style, | MaterialGPencilStyle *gp_style, | ||||
| ▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | else { | ||||
| DRW_shgroup_uniform_bool_copy( | DRW_shgroup_uniform_bool_copy( | ||||
| grp, "myTexturePremultiplied", (image->alpha_mode == IMA_ALPHA_PREMUL)); | grp, "myTexturePremultiplied", (image->alpha_mode == IMA_ALPHA_PREMUL)); | ||||
| BKE_image_release_ibuf(image, ibuf, NULL); | BKE_image_release_ibuf(image, ibuf, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* if no texture defined, need a blank texture to avoid errors in draw manager */ | /* if no texture defined, need a blank texture to avoid errors in draw manager */ | ||||
| DRW_shgroup_uniform_texture(grp, "myTexture", stl->g_data->gpencil_blank_texture); | DRW_shgroup_uniform_texture(grp, "myTexture", e_data->gpencil_blank_texture); | ||||
| } | } | ||||
| return grp; | return grp; | ||||
| } | } | ||||
| /* create shading group for points */ | /* create shading group for points */ | ||||
| static DRWShadingGroup *gpencil_shgroup_point_create(GPENCIL_Data *vedata, | static DRWShadingGroup *gpencil_shgroup_point_create(GPENCIL_e_data *e_data, | ||||
| GPENCIL_Data *vedata, | |||||
| DRWPass *pass, | DRWPass *pass, | ||||
| GPUShader *shader, | GPUShader *shader, | ||||
| Object *ob, | Object *ob, | ||||
| float (*obmat)[4], | float (*obmat)[4], | ||||
| bGPdata *gpd, | bGPdata *gpd, | ||||
| bGPDlayer *gpl, | bGPDlayer *gpl, | ||||
| bGPDstroke *gps, | bGPDstroke *gps, | ||||
| MaterialGPencilStyle *gp_style, | MaterialGPencilStyle *gp_style, | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | else { | ||||
| DRW_shgroup_uniform_bool_copy( | DRW_shgroup_uniform_bool_copy( | ||||
| grp, "myTexturePremultiplied", (image->alpha_mode == IMA_ALPHA_PREMUL)); | grp, "myTexturePremultiplied", (image->alpha_mode == IMA_ALPHA_PREMUL)); | ||||
| BKE_image_release_ibuf(image, ibuf, NULL); | BKE_image_release_ibuf(image, ibuf, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* if no texture defined, need a blank texture to avoid errors in draw manager */ | /* if no texture defined, need a blank texture to avoid errors in draw manager */ | ||||
| DRW_shgroup_uniform_texture(grp, "myTexture", stl->g_data->gpencil_blank_texture); | DRW_shgroup_uniform_texture(grp, "myTexture", e_data->gpencil_blank_texture); | ||||
| } | } | ||||
| return grp; | return grp; | ||||
| } | } | ||||
| /* add fill vertex info */ | /* add fill vertex info */ | ||||
| static void gpencil_add_fill_vertexdata(GpencilBatchCache *cache, | static void gpencil_add_fill_vertexdata(GpencilBatchCache *cache, | ||||
| Object *ob, | Object *ob, | ||||
| ▲ Show 20 Lines • Show All 677 Lines • ▼ Show 20 Lines | if ((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) { | ||||
| static float unit_mat[4][4] = { | static float unit_mat[4][4] = { | ||||
| {1.0, 0.0, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 0.0, 1.0}}; | {1.0, 0.0, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 0.0, 1.0}}; | ||||
| /* if only one point, don't need to draw buffer because the user has no time to see it */ | /* if only one point, don't need to draw buffer because the user has no time to see it */ | ||||
| if (gpd->runtime.sbuffer_used > 1) { | if (gpd->runtime.sbuffer_used > 1) { | ||||
| if ((gp_style) && (gp_style->mode == GP_STYLE_MODE_LINE)) { | if ((gp_style) && (gp_style->mode == GP_STYLE_MODE_LINE)) { | ||||
| stl->g_data->shgrps_drawing_stroke = gpencil_shgroup_stroke_create( | stl->g_data->shgrps_drawing_stroke = gpencil_shgroup_stroke_create( | ||||
| e_data, | |||||
| vedata, | vedata, | ||||
| psl->drawing_pass, | psl->drawing_pass, | ||||
| e_data->gpencil_stroke_sh, | e_data->gpencil_stroke_sh, | ||||
| NULL, | NULL, | ||||
| unit_mat, | unit_mat, | ||||
| gpd, | gpd, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| Show All 9 Lines | if ((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) { | ||||
| else { | else { | ||||
| /* Disable stencil for this type */ | /* Disable stencil for this type */ | ||||
| DRW_shgroup_state_disable(stl->g_data->shgrps_drawing_stroke, | DRW_shgroup_state_disable(stl->g_data->shgrps_drawing_stroke, | ||||
| DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL); | DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| stl->g_data->shgrps_drawing_stroke = gpencil_shgroup_point_create( | stl->g_data->shgrps_drawing_stroke = gpencil_shgroup_point_create( | ||||
| e_data, | |||||
| vedata, | vedata, | ||||
| psl->drawing_pass, | psl->drawing_pass, | ||||
| e_data->gpencil_point_sh, | e_data->gpencil_point_sh, | ||||
| NULL, | NULL, | ||||
| unit_mat, | unit_mat, | ||||
| gpd, | gpd, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| ▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | if (i >= GPENCIL_MAX_SHGROUPS) { | ||||
| break; | break; | ||||
| } | } | ||||
| float(*obmat)[4] = (!cache_ob->is_dup_ob) ? gpf->runtime.parent_obmat : cache_ob->obmat; | float(*obmat)[4] = (!cache_ob->is_dup_ob) ? gpf->runtime.parent_obmat : cache_ob->obmat; | ||||
| switch (elm->type) { | switch (elm->type) { | ||||
| case eGpencilBatchGroupType_Stroke: { | case eGpencilBatchGroupType_Stroke: { | ||||
| const int len = elm->vertex_idx - start_stroke; | const int len = elm->vertex_idx - start_stroke; | ||||
| shgrp = gpencil_shgroup_stroke_create(vedata, | shgrp = gpencil_shgroup_stroke_create(e_data, | ||||
| vedata, | |||||
| stroke_pass, | stroke_pass, | ||||
| e_data->gpencil_stroke_sh, | e_data->gpencil_stroke_sh, | ||||
| ob, | ob, | ||||
| obmat, | obmat, | ||||
| gpd, | gpd, | ||||
| gpl, | gpl, | ||||
| gps, | gps, | ||||
| gp_style, | gp_style, | ||||
| Show All 21 Lines | switch (elm->type) { | ||||
| } | } | ||||
| stl->storage->shgroup_id++; | stl->storage->shgroup_id++; | ||||
| start_stroke = elm->vertex_idx; | start_stroke = elm->vertex_idx; | ||||
| break; | break; | ||||
| } | } | ||||
| case eGpencilBatchGroupType_Point: { | case eGpencilBatchGroupType_Point: { | ||||
| const int len = elm->vertex_idx - start_point; | const int len = elm->vertex_idx - start_point; | ||||
| shgrp = gpencil_shgroup_point_create(vedata, | shgrp = gpencil_shgroup_point_create(e_data, | ||||
| vedata, | |||||
| stroke_pass, | stroke_pass, | ||||
| e_data->gpencil_point_sh, | e_data->gpencil_point_sh, | ||||
| ob, | ob, | ||||
| obmat, | obmat, | ||||
| gpd, | gpd, | ||||
| gpl, | gpl, | ||||
| gps, | gps, | ||||
| gp_style, | gp_style, | ||||
| Show All 10 Lines | switch (elm->type) { | ||||
| } | } | ||||
| stl->storage->shgroup_id++; | stl->storage->shgroup_id++; | ||||
| start_point = elm->vertex_idx; | start_point = elm->vertex_idx; | ||||
| break; | break; | ||||
| } | } | ||||
| case eGpencilBatchGroupType_Fill: { | case eGpencilBatchGroupType_Fill: { | ||||
| const int len = elm->vertex_idx - start_fill; | const int len = elm->vertex_idx - start_fill; | ||||
| shgrp = gpencil_shgroup_fill_create(vedata, | shgrp = gpencil_shgroup_fill_create(e_data, | ||||
| vedata, | |||||
| stroke_pass, | stroke_pass, | ||||
| e_data->gpencil_fill_sh, | e_data->gpencil_fill_sh, | ||||
| ob, | ob, | ||||
| obmat, | obmat, | ||||
| gpd, | gpd, | ||||
| gpl, | gpl, | ||||
| gp_style, | gp_style, | ||||
| stl->storage->shgroup_id, | stl->storage->shgroup_id, | ||||
| ▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines | |||||