diff options
Diffstat (limited to 'source')
10 files changed, 47 insertions, 153 deletions
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index b7eaecb7ab6..f049fc87205 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -227,7 +227,6 @@ data_to_c_simple(engines/workbench/shaders/workbench_deferred_composite_frag.gls data_to_c_simple(engines/workbench/shaders/workbench_forward_composite_frag.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_forward_depth_frag.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl SRC) -data_to_c_simple(engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_object_outline_lib.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_prepass_vert.glsl SRC) data_to_c_simple(engines/workbench/shaders/workbench_prepass_frag.glsl SRC) diff --git a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl index 8908891d7e6..0b494aa019f 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl @@ -65,11 +65,11 @@ void fresnel(vec3 I, vec3 N, float ior, out float kr) // kt = 1 - kr; } -vec4 calculate_transparent_accum(vec4 premultiplied) { - float a = min(1.0, premultiplied.a) * 8.0 + 0.01; +float calculate_transparent_weight(float alpha) { + /* Eq 10 */ + float a = min(1.0, alpha) * 8.0 + 0.01; float b = -gl_FragCoord.z * 0.95 + 1.0; - float w = clamp(a * a * a * 1e8 * b * b * b, 1e-2, 3e2); - return premultiplied * w; + return alpha * clamp(a * a * a * 1e8 * b * b * b, 1e-2, 3e3); } vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat) diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl index f335e1a15bd..1d9f37274bd 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl @@ -2,9 +2,7 @@ out vec4 fragColor; uniform usampler2D objectId; uniform sampler2D transparentAccum; -#ifdef WORKBENCH_REVEALAGE_ENABLED uniform sampler2D transparentRevealage; -#endif uniform vec2 invertedViewportSize; layout(std140) uniform world_block { @@ -16,29 +14,24 @@ void main() ivec2 texel = ivec2(gl_FragCoord.xy); vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize; uint object_id = texelFetch(objectId, texel, 0).r; - vec4 transparent_accum = texelFetch(transparentAccum, texel, 0); -#ifdef WORKBENCH_REVEALAGE_ENABLED - float transparent_revealage = texelFetch(transparentRevealage, texel, 0).r; -#endif - vec4 color; - vec4 bg_color; + + /* Listing 4 */ + vec4 trans_accum = texelFetch(transparentAccum, texel, 0); + float trans_revealage = trans_accum.a; + trans_accum.a = texelFetch(transparentRevealage, texel, 0).r; #ifdef V3D_SHADING_OBJECT_OUTLINE float outline = calculate_object_outline(objectId, texel, object_id); #else /* V3D_SHADING_OBJECT_OUTLINE */ float outline = 1.0; #endif /* V3D_SHADING_OBJECT_OUTLINE */ - bg_color = vec4(background_color(world_data, uv_viewport.y), 0.0); - if (object_id == NO_OBJECT_ID) { - color = bg_color; - } else { -#ifdef WORKBENCH_REVEALAGE_ENABLED - color = vec4((transparent_accum.xyz / max(transparent_accum.a, EPSILON)) * (1.0 - transparent_revealage), 1.0); - color = mix(bg_color, color, clamp(1.0 - transparent_revealage, 0.0, 1.0)); -#else - color = vec4(transparent_accum.xyz / max(transparent_accum.a, EPSILON), 1.0); -#endif - } - - fragColor = vec4(mix(world_data.object_outline_color.rgb, color.xyz, outline), 1.0); + vec3 bg_color = background_color(world_data, uv_viewport.y); + + /* TODO: Bypass the whole shader if there is no xray pass and no outline pass. */ + vec3 trans_color = trans_accum.rgb / clamp(trans_accum.a, 1e-4, 5e4); + vec3 color = mix(trans_color, bg_color, trans_revealage); + + color = mix(world_data.object_outline_color.rgb, color, outline); + + fragColor = vec4(color, 1.0); } diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl index f1eacd281b1..53903a4af76 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl @@ -26,7 +26,7 @@ layout(std140) uniform material_block { }; layout(location=0) out vec4 transparentAccum; - +layout(location=1) out float revealageAccum; /* revealage actually stored in transparentAccum.a */ void main() { @@ -70,7 +70,13 @@ void main() vec3 shaded_color = diffuse_light * diffuse_color.rgb + specular_color; - vec4 premultiplied = vec4(shaded_color.rgb * alpha, alpha); - transparentAccum = calculate_transparent_accum(premultiplied); + /* Based on : + * McGuire and Bavoil, Weighted Blended Order-Independent Transparency, Journal of + * Computer Graphics Techniques (JCGT), vol. 2, no. 2, 122–141, 2013 + */ + /* Listing 4 */ + float weight = calculate_transparent_weight(alpha); + transparentAccum = vec4(shaded_color * weight, alpha); + revealageAccum = weight; } diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl deleted file mode 100644 index c591425b950..00000000000 --- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_revealage_frag.glsl +++ /dev/null @@ -1,7 +0,0 @@ -layout(location=0) out float transparentRevealage; -uniform float alpha = 0.5; -void main() -{ - transparentRevealage = alpha; -} - diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 3bc016e139b..8d67a936382 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -50,17 +50,13 @@ static struct { struct GPUShader *composite_sh_cache[MAX_SHADERS]; struct GPUShader *transparent_accum_sh_cache[MAX_SHADERS]; - struct GPUShader *transparent_revealage_sh; - struct GPUShader *transparent_revealage_hair_sh; struct GPUShader *object_outline_sh; struct GPUShader *object_outline_hair_sh; struct GPUShader *checker_depth_sh; struct GPUTexture *object_id_tx; /* ref only, not alloced */ struct GPUTexture *transparent_accum_tx; /* ref only, not alloced */ -#ifdef WORKBENCH_REVEALAGE_ENABLED struct GPUTexture *transparent_revealage_tx; /* ref only, not alloced */ -#endif struct GPUTexture *composite_buffer_tx; /* ref only, not alloced */ int next_object_id; float normal_world_matrix[3][3]; @@ -71,9 +67,6 @@ extern char datatoc_common_hair_lib_glsl[]; extern char datatoc_workbench_forward_composite_frag_glsl[]; extern char datatoc_workbench_forward_depth_frag_glsl[]; extern char datatoc_workbench_forward_transparent_accum_frag_glsl[]; -#ifdef WORKBENCH_REVEALAGE_ENABLED -extern char datatoc_workbench_forward_transparent_revealage_frag_glsl[]; -#endif extern char datatoc_workbench_data_lib_glsl[]; extern char datatoc_workbench_background_lib_glsl[]; extern char datatoc_workbench_checkerboard_depth_frag_glsl[]; @@ -127,22 +120,6 @@ static char *workbench_build_forward_transparent_accum_frag(void) return str; } -#ifdef WORKBENCH_REVEALAGE_ENABLED -static char *workbench_build_forward_transparent_revealage_frag(void) -{ - char *str = NULL; - - DynStr *ds = BLI_dynstr_new(); - - BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl); - BLI_dynstr_append(ds, datatoc_workbench_forward_transparent_revealage_frag_glsl); - - str = BLI_dynstr_get_cstring(ds); - BLI_dynstr_free(ds); - return str; -} -#endif - static char *workbench_build_forward_composite_frag(void) { char *str = NULL; @@ -310,17 +287,6 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) forward_vert, NULL, forward_depth_frag, defines_hair); -#ifdef WORKBENCH_REVEALAGE_ENABLED - char *forward_transparent_revealage_frag = workbench_build_forward_transparent_revealage_frag(); - e_data.transparent_revealage_sh = DRW_shader_create( - forward_vert, NULL, - forward_transparent_revealage_frag, defines); - e_data.transparent_revealage_hair_sh = DRW_shader_create( - forward_vert, NULL, - forward_transparent_revealage_frag, defines_hair); - MEM_freeN(forward_transparent_revealage_frag); -#endif - e_data.checker_depth_sh = DRW_shader_create_fullscreen( datatoc_workbench_checkerboard_depth_frag_glsl, NULL); MEM_freeN(forward_vert); @@ -337,63 +303,32 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) size[0], size[1], GPU_R32UI, &draw_engine_workbench_transparent); e_data.transparent_accum_tx = DRW_texture_pool_query_2D( size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_transparent); -#ifdef WORKBENCH_REVEALAGE_ENABLED e_data.transparent_revealage_tx = DRW_texture_pool_query_2D( size[0], size[1], GPU_R16F, &draw_engine_workbench_transparent); -#endif e_data.composite_buffer_tx = DRW_texture_pool_query_2D( size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_transparent); + GPU_framebuffer_ensure_config(&fbl->object_outline_fb, { GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx), }); + GPU_framebuffer_ensure_config(&fbl->transparent_accum_fb, { GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(e_data.transparent_accum_tx), - }); - -#ifdef WORKBENCH_REVEALAGE_ENABLED - GPU_framebuffer_ensure_config(&fbl->transparent_revealage_fb, { - GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(e_data.transparent_revealage_tx), }); -#endif GPU_framebuffer_ensure_config(&fbl->composite_fb, { GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx), }); - const float clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - DRW_stats_group_start("Clear Buffers"); - GPU_framebuffer_bind(fbl->transparent_accum_fb); - GPU_framebuffer_clear_color(fbl->transparent_accum_fb, clear_color); - -#ifdef WORKBENCH_REVEALAGE_ENABLED - const float clear_color1[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - GPU_framebuffer_bind(fbl->transparent_revealage_fb); - GPU_framebuffer_clear_color(fbl->transparent_revealage_fb, clear_color1); -#endif - GPU_framebuffer_bind(fbl->object_outline_fb); - GPU_framebuffer_clear_color_depth(fbl->object_outline_fb, clear_color, 1.0f); - DRW_stats_group_end(); /* Transparency Accum */ { - int state = DRW_STATE_WRITE_COLOR | DRW_STATE_ADDITIVE_FULL; + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT; psl->transparent_accum_pass = DRW_pass_create("Transparent Accum", state); } - -#ifdef WORKBENCH_REVEALAGE_ENABLED - /* Transparency Revealage */ - { - int state = DRW_STATE_WRITE_COLOR | DRW_STATE_TRANSPARENT_REVEALAGE; - psl->transparent_revealage_pass = DRW_pass_create("Transparent Revealage", state); - grp = DRW_shgroup_create(e_data.transparent_revealage_sh, psl->transparent_revealage_pass); - DRW_shgroup_uniform_float(grp, "alpha", &wpd->shading.xray_alpha, 1); - wpd->transparent_revealage_shgrp = grp; - } -#endif - /* Depth */ { int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; @@ -407,9 +342,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass); DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx); DRW_shgroup_uniform_texture_ref(grp, "transparentAccum", &e_data.transparent_accum_tx); -#ifdef WORKBENCH_REVEALAGE_ENABLED DRW_shgroup_uniform_texture_ref(grp, "transparentRevealage", &e_data.transparent_revealage_tx); -#endif DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1); DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL); @@ -429,10 +362,6 @@ void workbench_forward_engine_free() DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]); DRW_SHADER_FREE_SAFE(e_data.transparent_accum_sh_cache[index]); } -#ifdef WORKBENCH_REVEALAGE_ENABLED - DRW_SHADER_FREE_SAFE(e_data.transparent_revealage_sh); - DRW_SHADER_FREE_SAFE(e_data.transparent_revealage_hair_sh); -#endif DRW_SHADER_FREE_SAFE(e_data.object_outline_sh); DRW_SHADER_FREE_SAFE(e_data.object_outline_hair_sh); DRW_SHADER_FREE_SAFE(e_data.checker_depth_sh); @@ -496,12 +425,6 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O GPUTexture *tex = GPU_texture_from_blender(image, NULL, GL_TEXTURE_2D, false, false, false); DRW_shgroup_uniform_texture(shgrp, "image", tex); } -#ifdef WORKBENCH_REVEALAGE_ENABLED - shgrp = DRW_shgroup_hair_create(ob, psys, md, - psl->transparent_revealage_pass, - e_data.transparent_revealage_hair_sh); - DRW_shgroup_uniform_float(shgrp, "alpha", &wpd->shading.xray_alpha, 1); -#endif shgrp = DRW_shgroup_hair_create(ob, psys, md, vedata->psl->object_outline_pass, e_data.object_outline_hair_sh); @@ -550,9 +473,6 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) mat_drawtype = OB_TEXTURE; } material = get_or_create_material_data(vedata, ob, mat, image, mat_drawtype); -#ifdef WORKBENCH_REVEALAGE_ENABLED - DRW_shgroup_call_object_add(wpd->transparent_revealage_shgrp, geom_array[i], ob); -#endif DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob); DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob); } @@ -568,16 +488,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); if (geom) { if (is_sculpt_mode) { -#ifdef WORKBENCH_REVEALAGE_ENABLED - DRW_shgroup_call_sculpt_add(wpd->transparent_revealage_shgrp, ob, ob->obmat); -#endif DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat); DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat); } else { -#ifdef WORKBENCH_REVEALAGE_ENABLED - DRW_shgroup_call_object_add(wpd->transparent_revealage_shgrp, geom, ob); -#endif DRW_shgroup_call_object_add(material->shgrp_object_outline, geom, ob); DRW_shgroup_call_object_add(material->shgrp, geom, ob); } @@ -596,9 +510,6 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) for (int i = 0; i < materials_len; ++i) { Material *mat = give_current_material(ob, i + 1); material = get_or_create_material_data(vedata, ob, mat, NULL, OB_SOLID); -#ifdef WORKBENCH_REVEALAGE_ENABLED - DRW_shgroup_call_object_add(wpd->transparent_revealage_shgrp, mat_geom[i], ob); -#endif DRW_shgroup_call_object_add(material->shgrp_object_outline, mat_geom[i], ob); DRW_shgroup_call_object_add(material->shgrp, mat_geom[i], ob); } @@ -616,7 +527,7 @@ void workbench_forward_draw_background(WORKBENCH_Data *UNUSED(vedata)) { const float clear_depth = 1.0f; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - DRW_stats_group_start("Clear Background"); + DRW_stats_group_start("Clear depth"); GPU_framebuffer_bind(dfbl->default_fb); GPU_framebuffer_clear_depth(dfbl->default_fb, clear_depth); DRW_stats_group_end(); @@ -631,17 +542,23 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata) DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); /* Write Depth + Object ID */ + const float clear_outline[4] = {0.0f}; GPU_framebuffer_bind(fbl->object_outline_fb); + GPU_framebuffer_clear_color(fbl->object_outline_fb, clear_outline); DRW_draw_pass(psl->object_outline_pass); if (wpd->shading.xray_alpha > 0.0) { - /* Shade */ + const float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; GPU_framebuffer_bind(fbl->transparent_accum_fb); + GPU_framebuffer_clear_color(fbl->transparent_accum_fb, clear_color); DRW_draw_pass(psl->transparent_accum_pass); -#ifdef WORKBENCH_REVEALAGE_ENABLED - GPU_framebuffer_bind(fbl->transparent_revealage_fb); - DRW_draw_pass(psl->transparent_revealage_pass); -#endif + } + else { + /* TODO(fclem): this is unecessary and takes up perf. + * Better change the composite frag shader to not use the tx. */ + const float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + GPU_framebuffer_bind(fbl->transparent_accum_fb); + GPU_framebuffer_clear_color(fbl->transparent_accum_fb, clear_color); } /* Composite */ diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index b25938cd0e5..231d9a9582a 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -95,10 +95,6 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype, BLI_dynstr_appendf(ds, "#define HAIR_SHADER\n"); } -#ifdef WORKBENCH_REVEALAGE_ENABLED - BLI_dynstr_appendf(ds, "#define WORKBENCH_REVEALAGE_ENABLED\n"); -#endif - str = BLI_dynstr_get_cstring(ds); BLI_dynstr_free(ds); return str; diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 9c5f97729bf..b17cc93d148 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -55,8 +55,6 @@ #define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd) || SPECULAR_HIGHLIGHT_ENABLED(wpd)) #define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) || CAVITY_ENABLED(wpd)) #define NORMAL_ENCODING_ENABLED() (true) -#define WORKBENCH_REVEALAGE_ENABLED - typedef struct WORKBENCH_FramebufferList { /* Deferred render buffers */ @@ -67,10 +65,7 @@ typedef struct WORKBENCH_FramebufferList { /* Forward render buffers */ struct GPUFrameBuffer *object_outline_fb; struct GPUFrameBuffer *transparent_accum_fb; - -#ifdef WORKBENCH_REVEALAGE_ENABLED struct GPUFrameBuffer *transparent_revealage_fb; -#endif } WORKBENCH_FramebufferList; typedef struct WORKBENCH_StorageList { @@ -93,9 +88,6 @@ typedef struct WORKBENCH_PassList { /* forward rendering */ struct DRWPass *transparent_accum_pass; -#ifdef WORKBENCH_REVEALAGE_ENABLED - struct DRWPass *transparent_revealage_pass; -#endif struct DRWPass *object_outline_pass; struct DRWPass *depth_pass; struct DRWPass *checker_depth_pass; @@ -158,9 +150,6 @@ typedef struct WORKBENCH_PrivateData { struct GPUUniformBuffer *world_ubo; struct DRWShadingGroup *shadow_shgrp; struct DRWShadingGroup *depth_shgrp; -#ifdef WORKBENCH_REVEALAGE_ENABLED - struct DRWShadingGroup *transparent_revealage_shgrp; -#endif WORKBENCH_UBO_World world_data; float shadow_multiplier; float cached_shadow_direction[3]; diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index b74e6ba9204..f79a2405c3f 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -282,7 +282,7 @@ typedef enum { DRW_STATE_BLEND_PREMUL = (1 << 21), /* Use that if color is already premult by alpha. */ DRW_STATE_WIRE_SMOOTH = (1 << 22), DRW_STATE_TRANS_FEEDBACK = (1 << 23), - DRW_STATE_TRANSPARENT_REVEALAGE = (1 << 24), + DRW_STATE_BLEND_OIT = (1 << 24), DRW_STATE_WRITE_STENCIL = (1 << 27), DRW_STATE_WRITE_STENCIL_SHADOW_PASS = (1 << 28), diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index f6b6438395d..3b7d19ac361 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -222,7 +222,7 @@ void drw_state_set(DRWState state) if (CHANGED_ANY_STORE_VAR( DRW_STATE_BLEND | DRW_STATE_BLEND_PREMUL | DRW_STATE_ADDITIVE | DRW_STATE_MULTIPLY | DRW_STATE_TRANSMISSION | DRW_STATE_ADDITIVE_FULL | - DRW_STATE_TRANSPARENT_REVEALAGE, + DRW_STATE_BLEND_OIT, test)) { if (test) { @@ -241,8 +241,9 @@ void drw_state_set(DRWState state) else if ((state & DRW_STATE_TRANSMISSION) != 0) { glBlendFunc(GL_ONE, GL_SRC_ALPHA); } - else if ((state & DRW_STATE_TRANSPARENT_REVEALAGE) != 0) { - glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); + else if ((state & DRW_STATE_BLEND_OIT) != 0) { + glBlendFuncSeparate(GL_ONE, GL_ONE, /* RGB */ + GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); /* Alpha */ } else if ((state & DRW_STATE_ADDITIVE) != 0) { /* Do not let alpha accumulate but premult the source RGB by it. */ |