[Bf-blender-cvs] [f933f605373] temp-greasepencil-vfx: Add samples parameter to Rim FX

Antonio Vazquez noreply at git.blender.org
Wed Jul 4 09:10:55 CEST 2018


Commit: f933f60537368885f709efd8c2aaf3dd9d63bb30
Author: Antonio Vazquez
Date:   Wed Jul 4 09:10:46 2018 +0200
Branches: temp-greasepencil-vfx
https://developer.blender.org/rBf933f60537368885f709efd8c2aaf3dd9d63bb30

Add samples parameter to Rim FX

Also improvements in drawing.

===================================================================

M	release/scripts/startup/bl_ui/properties_data_shaderfx.py
M	source/blender/draw/engines/gpencil/gpencil_shader_fx.c
M	source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_resolve_frag.glsl
M	source/blender/makesdna/DNA_shader_fx_types.h
M	source/blender/makesrna/intern/rna_shader_fx.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_shaderfx.py b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
index abc70c3c92c..dc4a4e5447a 100644
--- a/release/scripts/startup/bl_ui/properties_data_shaderfx.py
+++ b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
@@ -102,8 +102,8 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
         layout.prop(fx, "rim_color")
         layout.prop(fx, "mask_color")
         layout.prop(fx, "mode")
-        if fx.mode != 'NORMAL':
-            layout.prop(fx, "blur")
+        layout.prop(fx, "blur")
+        layout.prop(fx, "samples")
 
     def FX_SWIRL(self, layout, fx):
         layout.prop(fx, "object", text="Object")
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index a385a044b13..46f39a93ff4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -403,7 +403,6 @@ static void DRW_gpencil_fx_rim(
 	DRW_shgroup_uniform_texture_ref(fx_shgrp_b, "strokeColor", &e_data->input_color_tx);
 	DRW_shgroup_uniform_texture_ref(fx_shgrp_b, "strokeDepth", &e_data->input_depth_tx);
 	DRW_shgroup_uniform_texture_ref(fx_shgrp_b, "strokeMask", &e_data->temp_mask_tx_rim);
-	DRW_shgroup_uniform_int(fx_shgrp_b, "mode", &fxd->mode, 1);
 	DRW_shgroup_uniform_int(fx_shgrp_b, "blur", &fxd->blur[0], 2);
 
 	DRW_shgroup_uniform_vec3(fx_shgrp_b, "loc", &ob->loc[0], 1);
@@ -695,50 +694,70 @@ static void draw_gpencil_rim_passes(struct GPENCIL_e_data *e_data,
 						fxd->runtime.fx_sh, fxd->runtime.fx_sh);
 
 	/* resolve */
-	GPU_framebuffer_bind(fbl->temp_fb_b);
-	GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
+	if ((fxd->samples == 0) || ((bx == 0) && (by == 0))) {
+		e_data->input_depth_tx = e_data->temp_depth_tx_rim;
+		e_data->input_color_tx = e_data->temp_color_tx_rim;
 
-	/* horizontal (always) */
-	fxd->blur[0] = bx;
-	fxd->blur[1] = 0;
+		GPU_framebuffer_bind(fbl->temp_fb_a);
+		GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
+		DRW_draw_pass(psl->mix_pass_noblend);
 
-	e_data->input_depth_tx = e_data->temp_depth_tx_rim;
-	e_data->input_color_tx = e_data->temp_color_tx_rim;
+	}
+	else {
+		for (int x = 0; x < fxd->samples; x++) {
+			GPU_framebuffer_bind(fbl->temp_fb_b);
+			GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
 
-	DRW_draw_pass_subset(psl->fx_shader_pass_blend,
-						fxd->runtime.fx_sh_b, fxd->runtime.fx_sh_b);
-	/* copy pass from b to a for ping-pong frame buffers */
-	e_data->input_depth_tx = e_data->temp_depth_tx_b;
-	e_data->input_color_tx = e_data->temp_color_tx_b;
+			/* horizontal (always) */
+			fxd->blur[0] = bx;
+			fxd->blur[1] = 0;
 
-	GPU_framebuffer_bind(fbl->temp_fb_a);
-	GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
-	DRW_draw_pass(psl->mix_pass_noblend);
+			/* only the first loop must use the original rim output textures */
+			if (x == 0) {
+				e_data->input_depth_tx = e_data->temp_depth_tx_rim;
+				e_data->input_color_tx = e_data->temp_color_tx_rim;
+			}
+			else {
+				e_data->input_depth_tx = e_data->temp_depth_tx_a;
+				e_data->input_color_tx = e_data->temp_color_tx_a;
+			}
 
-	/* vertical if blur */
-	if (by > 0) {
-		GPU_framebuffer_bind(fbl->temp_fb_b);
-		GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
+			DRW_draw_pass_subset(psl->fx_shader_pass_blend,
+				fxd->runtime.fx_sh_b, fxd->runtime.fx_sh_b);
+			/* copy pass from b to a for ping-pong frame buffers */
+			e_data->input_depth_tx = e_data->temp_depth_tx_b;
+			e_data->input_color_tx = e_data->temp_color_tx_b;
 
-		fxd->blur[0] = 0;
-		fxd->blur[1] = by;
+			GPU_framebuffer_bind(fbl->temp_fb_a);
+			GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
+			DRW_draw_pass(psl->mix_pass_noblend);
 
-		e_data->input_depth_tx = e_data->temp_depth_tx_a;
-		e_data->input_color_tx = e_data->temp_color_tx_a;
+			/* vertical if blur */
+			if (by > 0) {
+				GPU_framebuffer_bind(fbl->temp_fb_b);
+				GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
 
-		DRW_draw_pass_subset(psl->fx_shader_pass_blend,
-			fxd->runtime.fx_sh_b, fxd->runtime.fx_sh_b);
+				fxd->blur[0] = 0;
+				fxd->blur[1] = by;
 
-		fxd->blur[0] = bx;
-		fxd->blur[1] = by;
+				e_data->input_depth_tx = e_data->temp_depth_tx_a;
+				e_data->input_color_tx = e_data->temp_color_tx_a;
 
-		/* copy pass from b to a for ping-pong frame buffers */
-		e_data->input_depth_tx = e_data->temp_depth_tx_b;
-		e_data->input_color_tx = e_data->temp_color_tx_b;
+				DRW_draw_pass_subset(psl->fx_shader_pass_blend,
+					fxd->runtime.fx_sh_b, fxd->runtime.fx_sh_b);
 
-		GPU_framebuffer_bind(fbl->temp_fb_a);
-		GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
-		DRW_draw_pass(psl->mix_pass_noblend);
+				fxd->blur[0] = bx;
+				fxd->blur[1] = by;
+
+				/* copy pass from b to a for ping-pong frame buffers */
+				e_data->input_depth_tx = e_data->temp_depth_tx_b;
+				e_data->input_color_tx = e_data->temp_color_tx_b;
+
+				GPU_framebuffer_bind(fbl->temp_fb_a);
+				GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
+				DRW_draw_pass(psl->mix_pass_noblend);
+			}
+		}
 	}
 }
 
diff --git a/source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_resolve_frag.glsl b/source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_resolve_frag.glsl
index 1adaa1cfad3..cbb8a72bc39 100644
--- a/source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_resolve_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_resolve_frag.glsl
@@ -8,13 +8,10 @@ uniform sampler2D strokeColor;
 uniform sampler2D strokeDepth;
 uniform sampler2D strokeMask;
 
-uniform int mode;
 uniform int blur[2];
 
 out vec4 FragColor;
 
-#define MODE_NORMAL   0
-
 uniform vec3 loc;
 uniform float pixsize;   /* rv3d->pixsize */
 uniform float pixelsize; /* U.pixelsize */
@@ -60,8 +57,7 @@ void main()
 	
 	gl_FragDepth = stroke_depth;
 	/* add blur */
-	if ((mode != MODE_NORMAL) && (mask_pixel.r > 0)) {
-		//if ((blur[0] > 0) || (blur[1] > 0))
+	if (mask_pixel.r > 0) {
 		outcolor = get_blur(uv.xy, dx, dy);
 	}
 	
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index 4b896e1f844..601c6ee2d4c 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -153,6 +153,8 @@ typedef struct RimShaderFxData {
 	float mask_rgb[3];
 	int   mode;
 	int   blur[2];
+	int   samples;
+	char pad[4];
 	ShaderFxData_runtime runtime;
 } RimShaderFxData;
 
diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index ecde9d5b09d..c7633b0e01b 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -372,6 +372,14 @@ static void rna_def_shader_fx_rim(BlenderRNA *brna)
 	RNA_def_property_range(prop, 0, INT_MAX);
 	RNA_def_property_ui_text(prop, "Blur", "Number of pixels for bluring rim (set to 0 to disable)");
 	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
+
+	prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "samples");
+	RNA_def_property_range(prop, 0, 32);
+	RNA_def_property_ui_range(prop, 0, 32, 2, -1);
+	RNA_def_property_int_default(prop, 4);
+	RNA_def_property_ui_text(prop, "Samples", "Number of Blur Samples (zero, disable blur)");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
 }
 
 static void rna_def_shader_fx_swirl(BlenderRNA *brna)



More information about the Bf-blender-cvs mailing list