diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-06-11 19:03:50 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-06-11 19:04:00 +0300 |
commit | 1f1ca7447637e8a5216358346698ad8f5f5ba328 (patch) | |
tree | 2292cb78fa8ec9590974edf89dd5a9c2a9255922 /source | |
parent | 638590078c716c65ed0e9c4a0cbcff60c46a98e2 (diff) |
Outlines: Make Xray outlines 2px thick instead of 3px
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 13 | ||||
-rw-r--r-- | source/blender/draw/modes/shaders/object_outline_detect_frag.glsl | 6 |
2 files changed, 18 insertions, 1 deletions
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; |