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:
authorClément Foucault <foucault.clem@gmail.com>2019-12-02 16:35:43 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-12-02 16:35:49 +0300
commit014eb69cf858036816d12a4b92ffe6681978b683 (patch)
tree05fc4a16f57c6855d5ad209a009a09aa1f8b55d1
parent3e241af3aec2bf03b0b558ca419ceb08d394a239 (diff)
Overlay Engine: Make thickwires (linesize > 1.0) using the Wire AA pass
This fixes the limitation of OSX not allowing glLineWidth with size > 1.0. This however only fix the viewport wire drawing.
-rw-r--r--source/blender/draw/engines/overlay/overlay_antialiasing.c7
-rw-r--r--source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl19
-rw-r--r--source/blender/draw/intern/DRW_render.h2
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c19
4 files changed, 27 insertions, 20 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_antialiasing.c b/source/blender/draw/engines/overlay/overlay_antialiasing.c
index 54a598633fb..569d47bf3a2 100644
--- a/source/blender/draw/engines/overlay/overlay_antialiasing.c
+++ b/source/blender/draw/engines/overlay/overlay_antialiasing.c
@@ -80,8 +80,9 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata)
return;
}
+ bool need_wire_expansion = (G_draw.block.sizePixel > 1.0f);
/* TODO Get real userpref option and remove MSAA buffer. */
- pd->antialiasing.enabled = dtxl->multisample_color != NULL;
+ pd->antialiasing.enabled = (dtxl->multisample_color != NULL) || need_wire_expansion;
/* Use default view */
pd->view_default = (DRWView *)DRW_view_default_get();
@@ -124,11 +125,15 @@ void OVERLAY_antialiasing_cache_init(OVERLAY_Data *vedata)
DRWShadingGroup *grp;
if (pd->antialiasing.enabled) {
+ /* TODO Get real userpref option and remove MSAA buffer. */
+ const bool do_smooth_lines = (dtxl->multisample_color != NULL);
+
DRW_PASS_CREATE(psl->antialiasing_ps, DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL);
sh = OVERLAY_shader_antialiasing();
grp = DRW_shgroup_create(sh, psl->antialiasing_ps);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+ DRW_shgroup_uniform_bool_copy(grp, "doSmoothLines", do_smooth_lines);
DRW_shgroup_uniform_texture_ref(grp, "depthTex", &dtxl->depth);
DRW_shgroup_uniform_texture_ref(grp, "colorTex", &txl->overlay_color_tx);
DRW_shgroup_uniform_texture_ref(grp, "lineTex", &txl->overlay_line_tx);
diff --git a/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl b/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl
index 98f69abe89f..46a2afc42fd 100644
--- a/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl
+++ b/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl
@@ -2,6 +2,7 @@
uniform sampler2D colorTex;
uniform sampler2D depthTex;
uniform sampler2D lineTex;
+uniform bool doSmoothLines;
in vec2 uvs;
@@ -26,11 +27,23 @@ out vec4 fragColor;
*/
float line_coverage(float distance_to_line, float line_kernel_size)
{
- return smoothstep(LINE_SMOOTH_END, LINE_SMOOTH_START, abs(distance_to_line) - line_kernel_size);
+ if (doSmoothLines) {
+ return smoothstep(
+ LINE_SMOOTH_END, LINE_SMOOTH_START, abs(distance_to_line) - line_kernel_size);
+ }
+ else {
+ return step(-0.5, line_kernel_size - abs(distance_to_line));
+ }
}
vec4 line_coverage(vec4 distance_to_line, float line_kernel_size)
{
- return smoothstep(LINE_SMOOTH_END, LINE_SMOOTH_START, abs(distance_to_line) - line_kernel_size);
+ if (doSmoothLines) {
+ return smoothstep(
+ LINE_SMOOTH_END, LINE_SMOOTH_START, abs(distance_to_line) - line_kernel_size);
+ }
+ else {
+ return step(-0.5, line_kernel_size - abs(distance_to_line));
+ }
}
vec2 decode_line_dir(vec2 dir)
@@ -79,7 +92,7 @@ void neighbor_blend(
void main()
{
ivec2 center_texel = ivec2(gl_FragCoord.xy);
- const float line_kernel = 0.0;
+ float line_kernel = sizePixel * 0.5 - 0.5;
fragColor = texelFetch(colorTex, center_texel, 0);
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 40f4da7e870..27b43ee8c17 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -350,7 +350,7 @@ typedef enum {
DRW_STATE_LOGIC_INVERT = (1 << 26),
DRW_STATE_SHADOW_OFFSET = (1 << 27),
DRW_STATE_CLIP_PLANES = (1 << 28),
- DRW_STATE_WIRE_SMOOTH = (1 << 29),
+ // DRW_STATE_WIRE_SMOOTH = (1 << 29), /* UNUSED */
DRW_STATE_FIRST_VERTEX_CONVENTION = (1 << 30),
/** DO NOT USE. Assumed always enabled. Only used internally. */
DRW_STATE_PROGRAM_POINT_SIZE = (1u << 31),
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 02667ad9d4a..9d14b77119f 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -230,21 +230,6 @@ void drw_state_set(DRWState state)
}
}
- /* Wire Width */
- {
- int test;
- if ((test = CHANGED_TO(DRW_STATE_WIRE_SMOOTH))) {
- if (test == 1) {
- GPU_line_width(2.0f);
- GPU_line_smooth(true);
- }
- else {
- GPU_line_width(1.0f);
- GPU_line_smooth(false);
- }
- }
- }
-
/* Blending (all buffer) */
{
int test;
@@ -453,7 +438,11 @@ void DRW_state_reset(void)
{
DRW_state_reset_ex(DRW_STATE_DEFAULT);
+ /* Should stay constant during the whole rendering. */
GPU_point_size(5);
+ GPU_line_smooth(false);
+ /* Bypass U.pixelsize factor. */
+ glLineWidth(1.0f);
/* Reset blending function */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);