[Bf-blender-cvs] [1f1ca744763] blender2.8 greasepencil-object hair_guides hair_guides_grooming soc-2018-npr temp-dynamic-overrides temp-eeveelightcache temp-greasepencil-object-stacksplit temp-udim-images: Outlines: Make Xray outlines 2px thick instead of 3px

Clément Foucault noreply at git.blender.org
Fri Jun 15 18:03:05 CEST 2018


Commit: 1f1ca7447637e8a5216358346698ad8f5f5ba328
Author: Clément Foucault
Date:   Mon Jun 11 18:03:50 2018 +0200
Branches: blender2.8 greasepencil-object hair_guides hair_guides_grooming soc-2018-npr temp-dynamic-overrides temp-eeveelightcache temp-greasepencil-object-stacksplit temp-udim-images
https://developer.blender.org/rB1f1ca7447637e8a5216358346698ad8f5f5ba328

Outlines: Make Xray outlines 2px thick instead of 3px

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

M	source/blender/draw/modes/object_mode.c
M	source/blender/draw/modes/shaders/object_outline_detect_frag.glsl

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

diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 0c8c4664f70..76712783cb1 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -256,6 +256,7 @@ static struct {
 	GPUShader *outline_resolve_sh;
 	GPUShader *outline_resolve_aa_sh;
 	GPUShader *outline_detect_sh;
+	GPUShader *outline_detect_wire_sh;
 	GPUShader *outline_fade_sh;
 
 	/* regular shaders */
@@ -364,6 +365,14 @@ static void OBJECT_engine_init(void *vedata)
 		            datatoc_common_globals_lib_glsl,
 		            "#extension GL_ARB_texture_gather : enable\n");
 
+		e_data.outline_detect_wire_sh = DRW_shader_create_with_lib(
+		            datatoc_common_fullscreen_vert_glsl, NULL,
+		            datatoc_object_outline_detect_frag_glsl,
+		            datatoc_common_globals_lib_glsl,
+		            "#define WIRE\n"
+		            "#extension GL_ARB_texture_gather : enable\n");
+
+
 		e_data.outline_fade_sh = DRW_shader_create_fullscreen(datatoc_object_outline_expand_frag_glsl, NULL);
 
 		/* Empty images */
@@ -592,6 +601,7 @@ static void OBJECT_engine_free(void)
 	DRW_SHADER_FREE_SAFE(e_data.outline_resolve_sh);
 	DRW_SHADER_FREE_SAFE(e_data.outline_resolve_aa_sh);
 	DRW_SHADER_FREE_SAFE(e_data.outline_detect_sh);
+	DRW_SHADER_FREE_SAFE(e_data.outline_detect_wire_sh);
 	DRW_SHADER_FREE_SAFE(e_data.outline_fade_sh);
 	DRW_SHADER_FREE_SAFE(e_data.object_empty_image_sh);
 	DRW_SHADER_FREE_SAFE(e_data.object_empty_image_wire_sh);
@@ -926,7 +936,8 @@ static void OBJECT_cache_init(void *vedata)
 
 		psl->outlines_search = DRW_pass_create("Outlines Detect Pass", state);
 
-		DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_detect_sh, psl->outlines_search);
+		GPUShader *sh = (xray_enabled) ? e_data.outline_detect_wire_sh : e_data.outline_detect_sh;
+		DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->outlines_search);
 		DRW_shgroup_uniform_texture_ref(grp, "outlineId", &e_data.outlines_id_tx);
 		DRW_shgroup_uniform_texture_ref(grp, "outlineDepth", &e_data.outlines_depth_tx);
 		DRW_shgroup_uniform_texture_ref(grp, "sceneDepth", &dtxl->depth);
diff --git a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
index 45bbdb18340..9a7856ecb13 100644
--- a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
@@ -51,6 +51,12 @@ void main()
 	id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 1,  0)).r;
 #endif
 
+#ifdef WIRE
+	/* We want only 2px outlines. */
+	/* TODO optimize, don't sample if we don't need to. */
+	id.xy = uvec2(ref_id);
+#endif
+
 	bool outline = any(notEqual(id, uvec4(ref_id)));
 
 	ivec2 depth_texel = texel;



More information about the Bf-blender-cvs mailing list