[Bf-blender-cvs] [cd68ef48036] greasepencil-object: GP: Reorganize Draw Mode

Antonioya noreply at git.blender.org
Fri Feb 22 09:12:39 CET 2019


Commit: cd68ef480360ec739e7980795b4c312073c476c3
Author: Antonioya
Date:   Fri Feb 22 09:12:22 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rBcd68ef480360ec739e7980795b4c312073c476c3

GP: Reorganize Draw Mode

Now, the parameter only works with 3D space depth ordering. The Back and Front depths are incompatible with 3D Space mode.

Options are:
- Back
- Front
- 3D Space->2D Layers (default)
-3D Space->3D Space (new mode)

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

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index c0ce3ce961f..a910cbe823f 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -346,8 +346,10 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
         gpd = context.gpencil_data
         gpl = context.active_gpencil_layer
 
-        layout.prop(gpd, "draw_mode", text="Mode")
         layout.prop(gpd, "xray_mode", text="Depth Ordering")
+        if gpd.xray_mode == '3DSPACE':
+            layout.prop(gpd, "draw_mode", text="Mode")
+
         layout.prop(ob, "empty_display_size", text="Marker Size")
 
         col = layout.column(align=True)
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 300b1847936..68af24c4609 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1308,7 +1308,7 @@ static void DRW_gpencil_shgroups_create(
 	GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
 	GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
 	bGPdata *gpd = (bGPdata *)ob->data;
-	DRWPass *stroke_pass = (gpd->draw_mode == GP_DRAWMODE_3D) ? psl->stroke_pass_3d : psl->stroke_pass_2d;
+	DRWPass *stroke_pass = GPENCIL_3D_DRAWMODE(gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d;
 
 	GpencilBatchGroup *elm = NULL;
 	DRWShadingGroup *shgrp = NULL;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index b440decf716..69b495cfc6d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -707,7 +707,7 @@ static void gpencil_draw_pass_range(
 	}
 
 	DRW_draw_pass_subset(
-		(gpd->draw_mode == GP_DRAWMODE_3D) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
+		GPENCIL_3D_DRAWMODE(gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
 		init_shgrp, end_shgrp);
 
 	if ((!stl->storage->is_mat_preview) && (multi)) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 376c4993f42..e1caef689ca 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -452,4 +452,7 @@ void GPENCIL_render_to_image(void *vedata, struct RenderEngine *engine, struct R
 	} \
 }
 
+#define GPENCIL_3D_DRAWMODE(gpd) \
+	((gpd) && (gpd->draw_mode == GP_DRAWMODE_3D) && (gpd->xray_mode == GP_XRAY_3DSPACE))
+
 #endif /* __GPENCIL_ENGINE_H__ */
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
index 435d9583fb0..29803c7b3e2 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
@@ -140,7 +140,13 @@ void main()
 		gl_FragDepth = 0.000001;
 	}
 	else if (xraymode == GP_XRAY_3DSPACE) {
-		gl_FragDepth = gl_FragCoord.z;
+	/* if 3D mode, move slightly the fill to avoid z-fighting between stroke and fill on same stroke */
+		if (drawmode == GP_DRAWMODE_3D) {
+			gl_FragDepth = gl_FragCoord.z * 1.0001;
+		}
+		else {
+			gl_FragDepth = gl_FragCoord.z;
+		}
 	}
 	else if  (xraymode == GP_XRAY_BACK) {
 		gl_FragDepth = 0.999999;
@@ -149,8 +155,4 @@ void main()
 		gl_FragDepth = 0.000001;
 	}
 	
-	/* if 3D mode, move slightly the fill to avoid z-fighting between stroke and fill on same stroke */
-	if (drawmode == GP_DRAWMODE_3D) {
-		gl_FragDepth *= 1.0001;
-	}
 }



More information about the Bf-blender-cvs mailing list