Outlines: Make Xray outlines 2px thick instead of 3px
authorClément Foucault <foucault.clem@gmail.com>
Mon, 11 Jun 2018 16:03:50 +0000 (18:03 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Mon, 11 Jun 2018 16:04:00 +0000 (18:04 +0200)
source/blender/draw/modes/object_mode.c
source/blender/draw/modes/shaders/object_outline_detect_frag.glsl

index 0c8c466..7671278 100644 (file)
@@ -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);
index 45bbdb1..9a7856e 100644 (file)
@@ -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;