[Bf-blender-cvs] [984d5da9900] greasepencil-object: Restructure VFX Blur, add Samples and cleanup
Antonio Vazquez
noreply at git.blender.org
Fri Mar 30 16:39:38 CEST 2018
Commit: 984d5da99009aee83e9239a998389d17073cf95d
Author: Antonio Vazquez
Date: Fri Mar 30 13:47:34 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB984d5da99009aee83e9239a998389d17073cf95d
Restructure VFX Blur, add Samples and cleanup
Now, the number of defined passes is low and there is a new parameter to define number of samples.
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/draw/engines/gpencil/gpencil_vfx.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/modifiers/intern/MOD_gpencilblur.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 76ecf48435d..c4fe835de4c 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1876,6 +1876,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col = split.column()
col.label(text="Factor:")
col.prop(md, "factor", text="")
+ col.separator()
+ col.prop(md, "samples", text="Samples")
def GP_WAVE(self, layout, ob, md):
row = layout.row(align=True)
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 1809b0e9e36..3e8d58b96c9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -430,10 +430,7 @@ static void GPENCIL_cache_init(void *vedata)
/* VFX passes */
psl->vfx_wave_pass = DRW_pass_create("GPencil VFX Wave Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- psl->vfx_blur_pass_1 = DRW_pass_create("GPencil VFX Blur Pass 1", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- psl->vfx_blur_pass_2 = DRW_pass_create("GPencil VFX Blur Pass 2", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- psl->vfx_blur_pass_3 = DRW_pass_create("GPencil VFX Blur Pass 3", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- psl->vfx_blur_pass_4 = DRW_pass_create("GPencil VFX Blur Pass 4", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+ psl->vfx_blur_pass = DRW_pass_create("GPencil VFX Blur Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
psl->vfx_pixel_pass = DRW_pass_create("GPencil VFX Pixel Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
@@ -616,10 +613,11 @@ static void gpencil_draw_vfx_pass(DRWPass *vfxpass, DRWPass *copypass,
* vfx modifier. This use one pass more but allows to create a stack of vfx
* modifiers and add more modifiers in the future using the same structure.
*/
-static void gpencil_vfx_passes(void *vedata, tGPencilObjectCache *cache)
+static void gpencil_vfx_passes(int ob_idx, void *vedata, tGPencilObjectCache *cache)
{
float clearcol[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
@@ -639,28 +637,28 @@ static void gpencil_vfx_passes(void *vedata, tGPencilObjectCache *cache)
/* --------------
* Blur passes (use several passes to get better quality)
* --------------*/
- if (cache->vfx_blur_sh_1) {
- GPU_framebuffer_bind(fbl->vfx_fb_b);
- GPU_framebuffer_clear_color_depth(fbl->vfx_fb_b, clearcol, 1.0f);
- /* pass 1 */
- DRW_draw_pass_subset(psl->vfx_blur_pass_1,
- cache->vfx_blur_sh_1,
- cache->vfx_blur_sh_1);
- /* pass 2 */
- GPU_framebuffer_bind(fbl->vfx_fb_a);
- DRW_draw_pass_subset(psl->vfx_blur_pass_2,
- cache->vfx_blur_sh_2,
- cache->vfx_blur_sh_2);
- /* pass 3 */
- GPU_framebuffer_bind(fbl->vfx_fb_b);
- DRW_draw_pass_subset(psl->vfx_blur_pass_3,
- cache->vfx_blur_sh_3,
- cache->vfx_blur_sh_3);
- /* pass 4 */
- GPU_framebuffer_bind(fbl->vfx_fb_a);
- DRW_draw_pass_subset(psl->vfx_blur_pass_4,
- cache->vfx_blur_sh_4,
- cache->vfx_blur_sh_4);
+ if (cache->vfx_blur_sh) {
+ int samples = stl->vfx[ob_idx].vfx_blur.samples >= 2 ? stl->vfx[ob_idx].vfx_blur.samples : 2;
+
+ for (int b = 0; b < samples; b++) {
+ /* make a pin-pong change of framebuffer to acumulate */
+ if (b % 2 == 0) {
+ GPU_framebuffer_bind(fbl->vfx_fb_b);
+ if (b == 0) {
+ GPU_framebuffer_clear_color_depth(fbl->vfx_fb_b, clearcol, 1.0f);
+ }
+ e_data.input_depth_tx = e_data.vfx_depth_tx_a;
+ e_data.input_color_tx = e_data.vfx_color_tx_a;
+ }
+ else {
+ e_data.input_depth_tx = e_data.vfx_depth_tx_b;
+ e_data.input_color_tx = e_data.vfx_color_tx_b;
+ GPU_framebuffer_bind(fbl->vfx_fb_a);
+ }
+ DRW_draw_pass_subset(psl->vfx_blur_pass,
+ cache->vfx_blur_sh,
+ cache->vfx_blur_sh);
+ }
}
/* --------------
* Pixelate pass
@@ -830,7 +828,7 @@ static void GPENCIL_draw_scene(void *vedata)
*/
if ((cache->vfx_wave_sh) && (!stl->storage->simplify_vfx)) {
/* add vfx passes */
- gpencil_vfx_passes(vedata, cache);
+ gpencil_vfx_passes(i, vedata, cache);
e_data.input_depth_tx = e_data.vfx_depth_tx_a;
e_data.input_color_tx = e_data.vfx_color_tx_a;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 4881392ba97..6ff283082de 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -89,6 +89,7 @@ typedef struct GPencilVFXPixel {
typedef struct GPencilVFXBlur {
float x;
float y;
+ int samples;
} GPencilVFXBlur;
typedef struct GPencilVFXWave {
@@ -115,10 +116,7 @@ typedef struct tGPencilObjectCache {
int init_grp, end_grp;
DRWShadingGroup *vfx_wave_sh;
- DRWShadingGroup *vfx_blur_sh_1;
- DRWShadingGroup *vfx_blur_sh_2;
- DRWShadingGroup *vfx_blur_sh_3;
- DRWShadingGroup *vfx_blur_sh_4;
+ DRWShadingGroup *vfx_blur_sh;
DRWShadingGroup *vfx_pixel_sh;
@@ -211,10 +209,7 @@ typedef struct GPENCIL_PassList {
struct DRWPass *mix_pass_noblend;
struct DRWPass *vfx_copy_pass;
struct DRWPass *vfx_wave_pass;
- struct DRWPass *vfx_blur_pass_1;
- struct DRWPass *vfx_blur_pass_2;
- struct DRWPass *vfx_blur_pass_3;
- struct DRWPass *vfx_blur_pass_4;
+ struct DRWPass *vfx_blur_pass;
struct DRWPass *vfx_pixel_pass;
struct DRWPass *vfx_swirl_pass;
struct DRWPass *vfx_flip_pass;
diff --git a/source/blender/draw/engines/gpencil/gpencil_vfx.c b/source/blender/draw/engines/gpencil/gpencil_vfx.c
index ebfcb79e98a..1dbf169fe3e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_vfx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_vfx.c
@@ -163,47 +163,19 @@ static void DRW_gpencil_vfx_blur(
const float *viewport_size = DRW_viewport_size_get();
stl->vfx[ob_idx].vfx_blur.x = mmd->radius[0];
stl->vfx[ob_idx].vfx_blur.y = mmd->radius[1] * (viewport_size[1] / viewport_size[0]);
+ stl->vfx[ob_idx].vfx_blur.samples = mmd->samples;
struct Gwn_Batch *vfxquad = DRW_cache_fullscreen_quad_get();
- /* === Pass 1 === */
- vfx_shgrp = DRW_shgroup_create(e_data->gpencil_vfx_blur_sh, psl->vfx_blur_pass_1);
- ++stl->g_data->tot_sh;
- DRW_shgroup_call_add(vfx_shgrp, vfxquad, NULL);
- DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeColor", &e_data->vfx_color_tx_a);
- DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeDepth", &e_data->vfx_depth_tx_a);
- DRW_shgroup_uniform_float(vfx_shgrp, "blurx", &stl->vfx[ob_idx].vfx_blur.x, 1);
- DRW_shgroup_uniform_float(vfx_shgrp, "blury", &stl->vfx[ob_idx].vfx_blur.y, 1);
- cache->vfx_blur_sh_1 = vfx_shgrp;
- /* === Pass 2 === */
- vfx_shgrp = DRW_shgroup_create(e_data->gpencil_vfx_blur_sh, psl->vfx_blur_pass_2);
+ vfx_shgrp = DRW_shgroup_create(e_data->gpencil_vfx_blur_sh, psl->vfx_blur_pass);
++stl->g_data->tot_sh;
DRW_shgroup_call_add(vfx_shgrp, vfxquad, NULL);
- DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeColor", &e_data->vfx_color_tx_b);
- DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeDepth", &e_data->vfx_depth_tx_b);
+ DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeColor", &e_data->input_color_tx);
+ DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeDepth", &e_data->input_depth_tx);
DRW_shgroup_uniform_float(vfx_shgrp, "blurx", &stl->vfx[ob_idx].vfx_blur.x, 1);
DRW_shgroup_uniform_float(vfx_shgrp, "blury", &stl->vfx[ob_idx].vfx_blur.y, 1);
- cache->vfx_blur_sh_2 = vfx_shgrp;
+ cache->vfx_blur_sh = vfx_shgrp;
- /* === Pass 3 === */
- vfx_shgrp = DRW_shgroup_create(e_data->gpencil_vfx_blur_sh, psl->vfx_blur_pass_3);
- ++stl->g_data->tot_sh;
- DRW_shgroup_call_add(vfx_shgrp, vfxquad, NULL);
- DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeColor", &e_data->vfx_color_tx_a);
- DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeDepth", &e_data->vfx_depth_tx_a);
- DRW_shgroup_uniform_float(vfx_shgrp, "blurx", &stl->vfx[ob_idx].vfx_blur.x, 1);
- DRW_shgroup_uniform_float(vfx_shgrp, "blury", &stl->vfx[ob_idx].vfx_blur.y, 1);
- cache->vfx_blur_sh_3 = vfx_shgrp;
-
- /* === Pass 4 === */
- vfx_shgrp = DRW_shgroup_create(e_data->gpencil_vfx_blur_sh, psl->vfx_blur_pass_4);
- ++stl->g_data->tot_sh;
- DRW_shgroup_call_add(vfx_shgrp, vfxquad, NULL);
- DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeColor", &e_data->vfx_color_tx_b);
- DRW_shgroup_uniform_texture_ref(vfx_shgrp, "strokeDepth", &e_data->vfx_depth_tx_b);
- DRW_shgroup_uniform_float(vfx_shgrp, "blurx", &stl->vfx[ob_idx].vfx_blur.x, 1);
- DRW_shgroup_uniform_float(vfx_shgrp, "blury", &stl->vfx[ob_idx].vfx_blur.y, 1);
- cache->vfx_blur_sh_4 = vfx_shgrp;
}
/* Pixelate VFX */
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 49288e4ce00..ec7fd6d8b71 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1925,7 +1925,7 @@ typedef struct GpencilBlurModifierData {
ModifierData modifier;
int radius[2];
int flag; /* flags */
- char pad[4];
+ int samples;
} GpencilBlurModifierData;
typedef struct GpencilWaveModifierData {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index ad6ab4444ef..b55ee7d5244 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5849,6 +5849,12 @@ static void rna_def_modifier_gpencilblur(BlenderRNA *brna)
RNA_def_property_range(prop, 0, INT_MAX);
RNA_def_property_ui_text(prop, "Factor", "Factor of Blur");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "samples");
+ RNA_def_property_range(prop, 2, 32);
+ RNA_def_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list