Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2018-04-18 14:53:22 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2018-04-18 14:53:22 +0300
commit8a71c139d8b651bf30547236ffc0a2067d45c4d5 (patch)
treed4be5703d26d7d8117d4d3266b3d4cdba345a10f /source/blender/draw
parenta091da7ffad137c114139dd59db79b2d7fbd8006 (diff)
parent9b338e802805bb7dbf981512923d6a1f343fbaa8 (diff)
Merge branch 'blender2.8' into blender2.8-workbench
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h11
-rw-r--r--source/blender/draw/modes/object_mode.c17
-rw-r--r--source/blender/draw/modes/shaders/object_outline_detect_frag.glsl35
3 files changed, 39 insertions, 24 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index cec0c2f4bf9..2b328ccbda2 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -41,17 +41,10 @@ typedef struct WORKBENCH_PassList {
struct DRWPass *solid_pass;
} WORKBENCH_PassList;
-typedef struct WORKBENCH_FrameBufferList {
-} WORKBENCH_FrameBufferList;
-
-typedef struct WORKBENCH_TextureList {
-} WORKBENCH_TextureList;
-
-
typedef struct WORKBENCH_Data {
void *engine_type;
- WORKBENCH_FrameBufferList *fbl;
- WORKBENCH_TextureList *txl;
+ DRWViewportEmptyList *fbl;
+ DRWViewportEmptyList *txl;
WORKBENCH_PassList *psl;
WORKBENCH_StorageList *stl;
} WORKBENCH_Data;
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 720a547f8f8..7868e8a8232 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -886,6 +886,8 @@ static void OBJECT_cache_init(void *vedata)
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
OBJECT_PrivateData *g_data;
+ /* TODO : use dpi setting for enabling the second pass */
+ const bool do_outline_expand = false;
if (!stl->g_data) {
/* Alloc transient pointers */
@@ -968,15 +970,17 @@ static void OBJECT_cache_init(void *vedata)
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_expand);
DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_blur_tx);
- DRW_shgroup_uniform_bool(grp, "doExpand", &bTrue, 1);
+ DRW_shgroup_uniform_bool(grp, "doExpand", (do_outline_expand) ? &bTrue : &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
psl->outlines_bleed = DRW_pass_create("Outlines Bleed Pass", state);
- grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed);
- DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx);
- DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
- DRW_shgroup_call_add(grp, quad, NULL);
+ if (do_outline_expand) {
+ grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed);
+ DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx);
+ DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
}
{
@@ -984,9 +988,10 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_resolve = DRW_pass_create("Outlines Resolve Pass", state);
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
+ GPUTexture **outline_tx = (do_outline_expand) ? &e_data.outlines_blur_tx : &e_data.outlines_color_tx;
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_aa_sh, psl->outlines_resolve);
- DRW_shgroup_uniform_texture_ref(grp, "outlineBluredColor", &e_data.outlines_blur_tx);
+ DRW_shgroup_uniform_texture_ref(grp, "outlineBluredColor", outline_tx);
DRW_shgroup_uniform_vec2(grp, "rcpDimensions", e_data.inv_viewport_size, 1);
DRW_shgroup_call_add(grp, quad, NULL);
}
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 dc457100d1c..771b6bcdc2e 100644
--- a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
@@ -40,8 +40,8 @@ void main()
#ifdef GL_ARB_texture_gather
vec2 texel_size = 1.0 / vec2(textureSize(outlineId, 0).xy);
- vec2 uv1 = floor(gl_FragCoord.xy) * texel_size - texel_size;
- vec2 uv2 = floor(gl_FragCoord.xy) * texel_size;
+ vec2 uv1 = ceil(gl_FragCoord.xy) * texel_size - texel_size;
+ vec2 uv2 = ceil(gl_FragCoord.xy) * texel_size;
/* Samples order is CW starting from top left. */
uvec4 tmp1 = textureGather(outlineId, uv1);
@@ -52,19 +52,36 @@ void main()
#else
uvec4 id;
uint ref_id = texelFetch(outlineId, texel, 0).r;
- id.x = texelFetchOffset(outlineId, texel, 0, ivec2( 1, 0)).r;
- id.y = texelFetchOffset(outlineId, texel, 0, ivec2( 0, 1)).r;
- id.z = texelFetchOffset(outlineId, texel, 0, ivec2(-1, 0)).r;
- id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 0, -1)).r;
+ id.x = texelFetchOffset(outlineId, texel, 0, ivec2(-1, 0)).r;
+ id.y = texelFetchOffset(outlineId, texel, 0, ivec2( 0, -1)).r;
+ id.z = texelFetchOffset(outlineId, texel, 0, ivec2( 0, 1)).r;
+ id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 1, 0)).r;
#endif
- float ref_depth = texelFetch(outlineDepth, texel, 0).r;
- float scene_depth = texelFetch(sceneDepth, texel, 0).r;
+ bool outline = any(notEqual(id, uvec4(ref_id)));
+
+ ivec2 depth_texel = texel;
+ /* If texel is an outline but has no valid id ...
+ * replace id and depth texel by a valid one.
+ * This keeps the outline thickness consistent everywhere. */
+ if (ref_id == 0u && outline) {
+ depth_texel = (id.x != 0u) ? texel + ivec2(-1, 0) : depth_texel;
+ depth_texel = (id.y != 0u) ? texel + ivec2( 0, -1) : depth_texel;
+ depth_texel = (id.z != 0u) ? texel + ivec2( 0, 1) : depth_texel;
+ depth_texel = (id.w != 0u) ? texel + ivec2( 1, 0) : depth_texel;
+
+ ref_id = (id.x != 0u) ? id.x : ref_id;
+ ref_id = (id.y != 0u) ? id.y : ref_id;
+ ref_id = (id.z != 0u) ? id.z : ref_id;
+ ref_id = (id.w != 0u) ? id.w : ref_id;
+ }
+
+ float ref_depth = texelFetch(outlineDepth, depth_texel, 0).r;
+ float scene_depth = texelFetch(sceneDepth, depth_texel, 0).r;
/* Avoid bad cases of zfighting for occlusion only. */
const float epsilon = 3.0 / 8388608.0;
bool occluded = (ref_depth > scene_depth + epsilon);
- bool outline = any(notEqual(id, uvec4(ref_id)));
FragColor = convert_id_to_color(int(ref_id));
FragColor.a *= (occluded) ? alphaOcclu : 1.0;