Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/gpencil')
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_cache_utils.c12
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_data.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c27
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_render.c1
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_shader_fx.c8
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl32
7 files changed, 43 insertions, 41 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 2b811f1d52e..8a4134ec8ea 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -106,7 +106,7 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob)
copy_v3_v3(tgp_ob->plane_mat[3], center);
/* Add to corresponding list if is in front. */
- if (ob->dtx & OB_DRAWXRAY) {
+ if (ob->dtx & OB_DRAW_IN_FRONT) {
BLI_LINKS_APPEND(&pd->tobjects_infront, tgp_ob);
}
else {
@@ -159,7 +159,7 @@ void gpencil_object_cache_sort(GPENCIL_PrivateData *pd)
}
}
- /* Join both lists, adding infront. */
+ /* Join both lists, adding in front. */
if (pd->tobjects_infront.first != NULL) {
if (pd->tobjects.last != NULL) {
pd->tobjects.last->next = pd->tobjects_infront.first;
@@ -258,15 +258,17 @@ GPENCIL_tLayer *gpencil_layer_cache_add(GPENCIL_PrivateData *pd,
{
bGPdata *gpd = (bGPdata *)ob->data;
- const bool is_in_front = (ob->dtx & OB_DRAWXRAY);
+ const bool is_in_front = (ob->dtx & OB_DRAW_IN_FRONT);
const bool is_screenspace = (gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS) != 0;
const bool overide_vertcol = (pd->v3d_color_type != -1);
const bool is_vert_col_mode = (pd->v3d_color_type == V3D_SHADING_VERTEX_COLOR) ||
GPENCIL_VERTEX_MODE(gpd) || pd->is_render;
bool is_masked = (gpl->flag & GP_LAYER_USE_MASK) && !BLI_listbase_is_empty(&gpl->mask_layers);
- float vert_col_opacity = (overide_vertcol) ? (is_vert_col_mode ? 1.0f : 0.0f) :
- gpl->vertex_paint_opacity;
+ float vert_col_opacity = (overide_vertcol) ?
+ (is_vert_col_mode ? pd->vertex_paint_opacity : 0.0f) :
+ pd->is_render ? gpl->vertex_paint_opacity :
+ pd->vertex_paint_opacity;
/* Negate thickness sign to tag that strokes are in screen space.
* Convert to world units (by default, 1 meter = 2000 px). */
float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / GPENCIL_PIXEL_FACTOR);
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
index 6e6b35e19ca..ed443b2c73f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
@@ -63,7 +63,7 @@ static struct GPUTexture *gpencil_image_texture_get(Image *image, bool *r_alpha_
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
if (ibuf != NULL && ibuf->rect != NULL) {
- gpu_tex = GPU_texture_from_blender(image, &iuser, ibuf, GL_TEXTURE_2D);
+ gpu_tex = BKE_image_get_gpu_texture(image, &iuser, ibuf);
*r_alpha_premult = (image->alpha_mode == IMA_ALPHA_PREMUL);
}
BKE_image_release_ibuf(image, ibuf, lock);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 495de7ef10b..dbad226099e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -224,6 +224,7 @@ void GPENCIL_cache_init(void *ved)
const bool is_fade_layer = ((!hide_overlay) && (!pd->is_render) &&
(draw_ctx->v3d->gp_flag & V3D_GP_FADE_NOACTIVE_LAYERS));
pd->fade_layer_opacity = (is_fade_layer) ? draw_ctx->v3d->overlay.gpencil_fade_layer : -1.0f;
+ pd->vertex_paint_opacity = draw_ctx->v3d->overlay.gpencil_vertex_paint_opacity;
/* Fade GPencil Objects. */
const bool is_fade_object = ((!hide_overlay) && (!pd->is_render) &&
(draw_ctx->v3d->gp_flag & V3D_GP_FADE_OBJECTS) &&
@@ -383,7 +384,7 @@ static void gpencil_drawcall_flush(gpIterPopulateData *iter)
}
/* Group drawcalls that are consecutive and with the same type. Reduces GPU driver overhead. */
-static void gp_drawcall_add(
+static void gpencil_drawcall_add(
gpIterPopulateData *iter, struct GPUBatch *geom, bool instancing, int v_first, int v_count)
{
#if DISABLE_BATCHING
@@ -413,7 +414,7 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
bGPDstroke *gps,
void *thunk);
-static void gp_sbuffer_cache_populate(gpIterPopulateData *iter)
+static void gpencil_sbuffer_cache_populate(gpIterPopulateData *iter)
{
iter->do_sbuffer_call = DRAW_NOW;
/* In order to draw the sbuffer stroke correctly mixed with other strokes,
@@ -450,7 +451,7 @@ static void gpencil_layer_cache_populate(bGPDlayer *gpl,
gpencil_drawcall_flush(iter);
if (iter->do_sbuffer_call) {
- gp_sbuffer_cache_populate(iter);
+ gpencil_sbuffer_cache_populate(iter);
}
else {
iter->do_sbuffer_call = !pd->do_fast_drawing && (gpd == pd->sbuffer_gpd) &&
@@ -492,8 +493,10 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
(!iter->pd->simplify_fill) && ((gps->flag & GP_STROKE_NOFILL) == 0);
bool only_lines = gpl && gpf && gpl->actframe != gpf && iter->pd->use_multiedit_lines_only;
+ bool hide_onion = gpl && gpf && gpf->runtime.onion_id != 0 &&
+ ((gp_style->flag & GP_MATERIAL_HIDE_ONIONSKIN) != 0);
- if (hide_material || (!show_stroke && !show_fill) || only_lines) {
+ if (hide_material || (!show_stroke && !show_fill) || only_lines || hide_onion) {
return;
}
@@ -522,12 +525,6 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", tex_stroke);
iter->tex_stroke = tex_stroke;
}
-
- /* TODO(fclem): This is a quick workaround but
- * ideally we should have this as a permanent bind. */
- const bool is_masked = iter->tgp_ob->layers.last->mask_bits != NULL;
- GPUTexture **mask_tex = (is_masked) ? &iter->pd->mask_tx : &iter->pd->dummy_tx;
- DRW_shgroup_uniform_texture_ref(iter->grp, "gpMaskTexture", mask_tex);
}
bool do_sbuffer = (iter->do_sbuffer_call == DRAW_NOW);
@@ -537,7 +534,7 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
DRW_cache_gpencil_fills_get(iter->ob, iter->pd->cfra);
int vfirst = gps->runtime.fill_start * 3;
int vcount = gps->tot_triangles * 3;
- gp_drawcall_add(iter, geom, false, vfirst, vcount);
+ gpencil_drawcall_add(iter, geom, false, vfirst, vcount);
}
if (show_stroke) {
@@ -547,13 +544,13 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
int vfirst = gps->runtime.stroke_start - 1;
/* Include "potential" cyclic vertex and start adj vertex (see shader). */
int vcount = gps->totpoints + 1 + 1;
- gp_drawcall_add(iter, geom, true, vfirst, vcount);
+ gpencil_drawcall_add(iter, geom, true, vfirst, vcount);
}
iter->stroke_index_last = gps->runtime.stroke_start + gps->totpoints + 1;
}
-static void gp_sbuffer_cache_populate_fast(GPENCIL_Data *vedata, gpIterPopulateData *iter)
+static void gpencil_sbuffer_cache_populate_fast(GPENCIL_Data *vedata, gpIterPopulateData *iter)
{
bGPdata *gpd = (bGPdata *)iter->ob->data;
if (gpd != iter->pd->sbuffer_gpd) {
@@ -630,13 +627,13 @@ void GPENCIL_cache_populate(void *ved, Object *ob)
gpencil_drawcall_flush(&iter);
if (iter.do_sbuffer_call) {
- gp_sbuffer_cache_populate(&iter);
+ gpencil_sbuffer_cache_populate(&iter);
}
gpencil_vfx_cache_populate(vedata, ob, iter.tgp_ob);
if (pd->do_fast_drawing) {
- gp_sbuffer_cache_populate_fast(vedata, &iter);
+ gpencil_sbuffer_cache_populate_fast(vedata, &iter);
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index cedd75af813..7baca28dca3 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -363,6 +363,8 @@ typedef struct GPENCIL_PrivateData {
float xray_alpha;
/* Mask invert uniform. */
int mask_invert;
+ /* Vertex Paint opacity. */
+ float vertex_paint_opacity;
} GPENCIL_PrivateData;
/* geometry batch cache functions */
diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c
index bb91bdbe396..4748858a6a8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_render.c
+++ b/source/blender/draw/engines/gpencil/gpencil_render.c
@@ -235,6 +235,7 @@ static void GPENCIL_render_result_combined(struct RenderLayer *rl,
BLI_rcti_size_y(rect),
4,
0,
+ GPU_DATA_FLOAT,
rp->rect);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index 7ce7a726bb7..cf6e78f4702 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -262,6 +262,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
mul_v3_m4v3(ob_center, persmat, ob->obmat[3]);
mul_v3_fl(ob_center, 1.0f / w);
+ const bool use_antialiasing = ((fx->flag & FX_PIXEL_FILTER_NEAREST) == 0);
+
/* Convert to uvs. */
mul_v2_fl(ob_center, 0.5f);
add_v2_fl(ob_center, 0.5f);
@@ -285,7 +287,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
DRW_shgroup_uniform_vec2_copy(grp, "targetPixelSize", pixsize_uniform);
DRW_shgroup_uniform_vec2_copy(grp, "targetPixelOffset", ob_center);
DRW_shgroup_uniform_vec2_copy(grp, "accumOffset", (float[2]){pixel_size[0], 0.0f});
- DRW_shgroup_uniform_int_copy(grp, "sampCount", (pixel_size[0] / vp_size_inv[0] > 3.0) ? 2 : 1);
+ int samp_count = (pixel_size[0] / vp_size_inv[0] > 3.0) ? 2 : 1;
+ DRW_shgroup_uniform_int_copy(grp, "sampCount", use_antialiasing ? samp_count : 0);
DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
}
@@ -294,7 +297,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
grp = gpencil_vfx_pass_create("Fx Pixelize Y", state, iter, sh);
DRW_shgroup_uniform_vec2_copy(grp, "targetPixelSize", pixsize_uniform);
DRW_shgroup_uniform_vec2_copy(grp, "accumOffset", (float[2]){0.0f, pixel_size[1]});
- DRW_shgroup_uniform_int_copy(grp, "sampCount", (pixel_size[1] / vp_size_inv[1] > 3.0) ? 2 : 1);
+ int samp_count = (pixel_size[1] / vp_size_inv[1] > 3.0) ? 2 : 1;
+ DRW_shgroup_uniform_int_copy(grp, "sampCount", use_antialiasing ? samp_count : 0);
DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
}
}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
index 1e75f6dd5bb..36fe9df9e5a 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
@@ -137,24 +137,20 @@ void blend_mode_output(
}
}
-#ifdef GPU_VERTEX_SHADER
-# define IN_OUT out
-#else
-# define IN_OUT in
-#endif
-
-/* Shader interface. */
-IN_OUT vec4 finalColorMul;
-IN_OUT vec4 finalColorAdd;
-IN_OUT vec3 finalPos;
-IN_OUT vec2 finalUvs;
-noperspective IN_OUT float strokeThickness;
-noperspective IN_OUT float strokeHardeness;
-flat IN_OUT vec2 strokeAspect;
-flat IN_OUT vec2 strokePt1;
-flat IN_OUT vec2 strokePt2;
-flat IN_OUT int matFlag;
-flat IN_OUT float depth;
+IN_OUT ShaderStageInterface
+{
+ vec4 finalColorMul;
+ vec4 finalColorAdd;
+ vec3 finalPos;
+ vec2 finalUvs;
+ noperspective float strokeThickness;
+ noperspective float strokeHardeness;
+ flat vec2 strokeAspect;
+ flat vec2 strokePt1;
+ flat vec2 strokePt2;
+ flat int matFlag;
+ flat float depth;
+};
#ifdef GPU_FRAGMENT_SHADER