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>2020-03-26 17:36:15 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-03-26 17:55:16 +0300
commite000dcb8490880d6d49aa91588c457612685e9f1 (patch)
treea1872556d19a2751455ab803cb13d00318ee63b8 /source/blender/draw/engines/overlay/overlay_shader.c
parent458f50ba73bcd233176f9afadc3273acf05e4f53 (diff)
Overlay: Wireframe: New method to avoid zfighting with geometry
This new method is only enabled if Overlay Smooth Wire is enabled. This method gives really nice results but has some downside: - Require a depth copy or loose the ability to write wire depth to the depth buffer and have correct depth ordering of wires. This patch use the former, with its associated cost. - Require some depth sampling and prevent early depth test (i.e: has some performance impact). - Has some relatively minor instability with geometry that are perpendicular to the view and intersecting with other geometry. Pros: - Compared to a fullpass approach this is surely going to have less performance impact and much higher quality. - Removes the additional vertex offset. (see T74961) - Fixes all half edges z-fighting. {F8428014} {F8428015} Reviewed By: brecht Differential Revision: https://developer.blender.org/D7233
Diffstat (limited to 'source/blender/draw/engines/overlay/overlay_shader.c')
-rw-r--r--source/blender/draw/engines/overlay/overlay_shader.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c
index 0b2f98294ec..8b70a0982af 100644
--- a/source/blender/draw/engines/overlay/overlay_shader.c
+++ b/source/blender/draw/engines/overlay/overlay_shader.c
@@ -192,7 +192,7 @@ typedef struct OVERLAY_Shaders {
GPUShader *volume_velocity_needle_sh;
GPUShader *volume_velocity_sh;
GPUShader *wireframe_select;
- GPUShader *wireframe;
+ GPUShader *wireframe[2];
GPUShader *xray_fade;
} OVERLAY_Shaders;
@@ -1372,24 +1372,29 @@ GPUShader *OVERLAY_shader_wireframe_select(void)
return sh_data->wireframe_select;
}
-GPUShader *OVERLAY_shader_wireframe(void)
+GPUShader *OVERLAY_shader_wireframe(bool custom_bias)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg];
OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
- if (!sh_data->wireframe) {
- sh_data->wireframe = GPU_shader_create_from_arrays({
+ if (!sh_data->wireframe[custom_bias]) {
+ sh_data->wireframe[custom_bias] = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_view_lib_glsl,
datatoc_common_globals_lib_glsl,
datatoc_gpu_shader_common_obinfos_lib_glsl,
datatoc_wireframe_vert_glsl,
NULL},
- .frag = (const char *[]){datatoc_common_view_lib_glsl, datatoc_wireframe_frag_glsl, NULL},
- .defs = (const char *[]){sh_cfg->def, NULL},
+ .frag = (const char *[]){datatoc_common_view_lib_glsl,
+ datatoc_common_globals_lib_glsl,
+ datatoc_wireframe_frag_glsl,
+ NULL},
+ .defs = (const char *[]){sh_cfg->def,
+ custom_bias ? "#define CUSTOM_DEPTH_BIAS\n" : NULL,
+ NULL},
});
}
- return sh_data->wireframe;
+ return sh_data->wireframe[custom_bias];
}
GPUShader *OVERLAY_shader_xray_fade(void)