diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-01-29 05:06:59 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-01-29 17:07:53 +0300 |
commit | bc99f4903c5f55d35b5fec32d6e18400f25089fb (patch) | |
tree | 2fc65d8a39a7529d0cc885b26805ebc5c6e54f1e /source/blender/draw/engines/workbench | |
parent | d88492d4ad432a66d72269fe5fa514b18d0407ff (diff) |
Workbench: Add transparency support for materials
This adds the posibility of having certain materials transparent in solid
mode. The option is (for now) per material only and thus only shows in
material color mode.
This uses the same rendering technique as Xray mode.
Note that objects are not considered transparent for selection with this.
Diffstat (limited to 'source/blender/draw/engines/workbench')
5 files changed, 150 insertions, 40 deletions
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 cb5516ca34f..b1f08cfef15 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 @@ -5,10 +5,13 @@ uniform sampler2D transparentAccum; uniform sampler2D transparentRevealage; uniform vec2 invertedViewportSize; +#ifndef ALPHA_COMPOSITE layout(std140) uniform world_block { WorldData world_data; }; +#endif +/* TODO: Bypass the whole shader if there is no xray pass and no outline pass. */ void main() { ivec2 texel = ivec2(gl_FragCoord.xy); @@ -19,17 +22,21 @@ void main() float trans_revealage = trans_accum.a; trans_accum.a = texelFetch(transparentRevealage, texel, 0).r; + vec3 trans_color = trans_accum.rgb / clamp(trans_accum.a, 1e-4, 5e4); + +#ifndef ALPHA_COMPOSITE 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); -#ifdef V3D_SHADING_OBJECT_OUTLINE +# ifdef V3D_SHADING_OBJECT_OUTLINE uint object_id = texelFetch(objectId, texel, 0).r; float outline = calculate_object_outline(objectId, texel, object_id); color = mix(world_data.object_outline_color.rgb, color, outline); -#endif +# endif fragColor = vec4(color, 1.0); +#else + fragColor = vec4(trans_color, 1.0 - trans_revealage); +#endif } diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index 22a8f51c23c..b009a8acb08 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -42,6 +42,7 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene = draw_ctx->scene; wpd->material_hash = BLI_ghash_ptr_new(__func__); + wpd->material_transp_hash = BLI_ghash_ptr_new(__func__); wpd->preferences = &U; View3D *v3d = draw_ctx->v3d; @@ -216,6 +217,7 @@ void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, floa void workbench_private_data_free(WORKBENCH_PrivateData *wpd) { BLI_ghash_free(wpd->material_hash, NULL, MEM_freeN); + BLI_ghash_free(wpd->material_transp_hash, NULL, MEM_freeN); DRW_UBO_FREE_SAFE(wpd->world_ubo); DRW_UBO_FREE_SAFE(wpd->dof_ubo); GPU_BATCH_DISCARD_SAFE(wpd->world_clip_planes_batch); diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 2e421595998..6f97c9df74d 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -71,7 +71,11 @@ static struct { struct GPUShader *shadow_pass_manifold_sh; struct GPUShader *shadow_caps_sh; struct GPUShader *shadow_caps_manifold_sh; + struct GPUShader *oit_resolve_sh; + /* TODO(fclem) move everything below to wpd and custom viewlayer data. */ + struct GPUTexture *oit_accum_tx; /* ref only, not alloced */ + struct GPUTexture *oit_revealage_tx; /* ref only, not alloced */ struct GPUTexture *ghost_depth_tx; /* ref only, not alloced */ struct GPUTexture *object_id_tx; /* ref only, not alloced */ struct GPUTexture *color_buffer_tx; /* ref only, not alloced */ @@ -95,6 +99,7 @@ extern char datatoc_common_world_clip_lib_glsl[]; extern char datatoc_workbench_prepass_vert_glsl[]; extern char datatoc_workbench_prepass_frag_glsl[]; extern char datatoc_workbench_cavity_frag_glsl[]; +extern char datatoc_workbench_forward_composite_frag_glsl[]; extern char datatoc_workbench_deferred_composite_frag_glsl[]; extern char datatoc_workbench_deferred_background_frag_glsl[]; extern char datatoc_workbench_ghost_resolve_frag_glsl[]; @@ -417,6 +422,17 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) workbench_dof_engine_init(vedata, camera); + if (OIT_ENABLED(wpd)) { + if (e_data.oit_resolve_sh == NULL) { + e_data.oit_resolve_sh = DRW_shader_create_fullscreen( + datatoc_workbench_forward_composite_frag_glsl, + "#define ALPHA_COMPOSITE\n"); + } + + workbench_forward_choose_shaders(wpd); + workbench_forward_outline_shaders_ensure(wpd); + } + { const float *viewport_size = DRW_viewport_size_get(); const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]}; @@ -444,6 +460,10 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) if (CAVITY_ENABLED(wpd)) { e_data.cavity_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R16, &draw_engine_workbench_solid); } + if (OIT_ENABLED(wpd)) { + e_data.oit_accum_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_solid); + e_data.oit_revealage_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R16F, &draw_engine_workbench_solid); + } GPU_framebuffer_ensure_config(&fbl->prepass_fb, { GPU_ATTACHMENT_TEXTURE(dtxl->depth), @@ -479,6 +499,13 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx), }); } + if (OIT_ENABLED(wpd)) { + GPU_framebuffer_ensure_config(&fbl->transparent_accum_fb, { + GPU_ATTACHMENT_TEXTURE(dtxl->depth), + GPU_ATTACHMENT_TEXTURE(e_data.oit_accum_tx), + GPU_ATTACHMENT_TEXTURE(e_data.oit_revealage_tx), + }); + } } { @@ -505,7 +532,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) /* Prepass */ { DRWShadingGroup *grp; - const bool do_cull = (v3d && (v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); + const bool do_cull = CULL_BACKFACE_ENABLED(wpd); int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; psl->prepass_pass = DRW_pass_create("Prepass", (do_cull) ? state | DRW_STATE_CULL_BACK : state); @@ -587,6 +614,8 @@ void workbench_deferred_engine_free(void) DRW_SHADER_FREE_SAFE(e_data.background_sh[0]); DRW_SHADER_FREE_SAFE(e_data.background_sh[1]); + DRW_SHADER_FREE_SAFE(e_data.oit_resolve_sh); + DRW_SHADER_FREE_SAFE(e_data.shadow_pass_sh); DRW_SHADER_FREE_SAFE(e_data.shadow_pass_manifold_sh); DRW_SHADER_FREE_SAFE(e_data.shadow_fail_sh); @@ -736,6 +765,40 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL); } } + + /** + * Order Independant Transparency. + * Similar to workbench forward. Duplicated code to avoid + * spaghetti with workbench forward. It would be great if we unify + * this in a clean way. + **/ + if (OIT_ENABLED(wpd)) { + const bool do_cull = CULL_BACKFACE_ENABLED(wpd); + const int cull_state = (do_cull) ? DRW_STATE_CULL_BACK : 0; + /* Transparency Accum */ + { + /* Same as forward but here we use depth test to + * not bleed through other solid objects. */ + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT | DRW_STATE_DEPTH_LESS | cull_state; + psl->transparent_accum_pass = DRW_pass_create("Transparent Accum", state); + } + /* Depth */ + { + int state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | cull_state; + psl->object_outline_pass = DRW_pass_create("Transparent Depth", state); + } + /* OIT Composite */ + { + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND; + psl->oit_composite_pass = DRW_pass_create("OIT Composite", state); + + grp = DRW_shgroup_create(e_data.oit_resolve_sh, psl->oit_composite_pass); + DRW_shgroup_uniform_texture_ref(grp, "transparentAccum", &e_data.oit_accum_tx); + DRW_shgroup_uniform_texture_ref(grp, "transparentRevealage", &e_data.oit_revealage_tx); + DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1); + DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL); + } + } } static WORKBENCH_MaterialData *get_or_create_material_data( @@ -860,6 +923,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) const bool use_hide = is_active && DRW_object_use_hide_faces(ob); const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; + bool has_transp_mat = false; if (!is_sculpt_mode && me && me->mloopuv && TEXTURE_DRAWING_ENABLED(wpd)) { /* Draw textured */ @@ -908,7 +972,16 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) for (int i = 0; i < materials_len; ++i) { if (geoms != NULL && geoms[i] != NULL) { Material *mat = give_current_material(ob, i + 1); - material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); + if (mat != NULL && mat->transparency > 0.0) { + /* Hack */ + wpd->shading.xray_alpha = 1.0f - mat->transparency; + CLAMP(wpd->shading.xray_alpha, 0.0, 1.0); + material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); + has_transp_mat = true; + } + else { + material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); + } DRW_shgroup_call_object_add(material->shgrp, geoms[i], ob); } } @@ -937,7 +1010,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) DRWShadingGroup *grp; bool use_shadow_pass_technique = !studiolight_camera_in_object_shadow(wpd, ob, engine_object_data); - if (use_shadow_pass_technique) { + if (use_shadow_pass_technique && !has_transp_mat) { if (is_manifold) { grp = DRW_shgroup_create(e_data.shadow_pass_manifold_sh, psl->shadow_depth_pass_mani_pass); } @@ -1103,6 +1176,16 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata) GPU_framebuffer_bind(fbl->composite_fb); DRW_draw_pass(psl->background_pass); + if (OIT_ENABLED(wpd)) { + 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); + + GPU_framebuffer_bind(fbl->composite_fb); + DRW_draw_pass(psl->oit_composite_pass); + } + if (wpd->volumes_do) { GPU_framebuffer_bind(fbl->color_only_fb); DRW_draw_pass(psl->volume_pass); diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 1a8db642c10..a3643c7f118 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -143,7 +143,7 @@ static void workbench_init_object_data(DrawData *dd) data->object_id = ((e_data.next_object_id++) & 0xff) + 1; } -static WORKBENCH_MaterialData *get_or_create_material_data( +WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data( WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type, int interp) { WORKBENCH_StorageList *stl = vedata->stl; @@ -163,7 +163,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( material_template.interp = interp; uint hash = workbench_material_get_hash(&material_template, false); - material = BLI_ghash_lookup(wpd->material_hash, POINTER_FROM_UINT(hash)); + material = BLI_ghash_lookup(wpd->material_transp_hash, POINTER_FROM_UINT(hash)); if (material == NULL) { material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), __func__); @@ -172,7 +172,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( color_type == V3D_SHADING_TEXTURE_COLOR ? wpd->transparent_accum_texture_sh: wpd->transparent_accum_sh, psl->transparent_accum_pass); DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); - DRW_shgroup_uniform_float(grp, "alpha", &wpd->shading.xray_alpha, 1); + DRW_shgroup_uniform_float_copy(grp, "alpha", wpd->shading.xray_alpha); DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3); workbench_material_copy(material, &material_template); if (STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)) { @@ -204,7 +204,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( RegionView3D *rv3d = draw_ctx->rv3d; DRW_shgroup_world_clip_planes_from_rv3d(material->shgrp_object_outline, rv3d); } - BLI_ghash_insert(wpd->material_hash, POINTER_FROM_UINT(hash), material); + BLI_ghash_insert(wpd->material_transp_hash, POINTER_FROM_UINT(hash), material); } return material; } @@ -212,6 +212,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( static GPUShader *ensure_forward_accum_shaders(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair) { int index = workbench_material_get_accum_shader_index(wpd, use_textures, is_hair); + BLI_assert(index < MAX_ACCUM_SHADERS); if (e_data.transparent_accum_sh_cache[index] == NULL) { char *defines = workbench_material_build_defines(wpd, use_textures, is_hair); char *transparent_accum_vert = workbench_build_forward_vert(is_hair); @@ -239,7 +240,7 @@ static GPUShader *ensure_forward_composite_shaders(WORKBENCH_PrivateData *wpd) return e_data.composite_sh_cache[index]; } -static void select_forward_shaders(WORKBENCH_PrivateData *wpd) +void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd) { wpd->composite_sh = ensure_forward_composite_shaders(wpd); wpd->transparent_accum_sh = ensure_forward_accum_shaders(wpd, false, false); @@ -248,6 +249,33 @@ static void select_forward_shaders(WORKBENCH_PrivateData *wpd) wpd->transparent_accum_texture_hair_sh = ensure_forward_accum_shaders(wpd, true, true); } +void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd) +{ + if (e_data.object_outline_sh == NULL) { + char *defines = workbench_material_build_defines(wpd, false, false); + char *defines_texture = workbench_material_build_defines(wpd, true, false); + char *defines_hair = workbench_material_build_defines(wpd, false, true); + char *forward_vert = workbench_build_forward_vert(false); + char *forward_hair_vert = workbench_build_forward_vert(true); + + e_data.object_outline_sh = DRW_shader_create( + forward_vert, NULL, + datatoc_workbench_forward_depth_frag_glsl, defines); + e_data.object_outline_texture_sh = DRW_shader_create( + forward_vert, NULL, + datatoc_workbench_forward_depth_frag_glsl, defines_texture); + e_data.object_outline_hair_sh = DRW_shader_create( + forward_hair_vert, NULL, + datatoc_workbench_forward_depth_frag_glsl, defines_hair); + + MEM_freeN(forward_hair_vert); + MEM_freeN(forward_vert); + MEM_freeN(defines); + MEM_freeN(defines_texture); + MEM_freeN(defines_hair); + } +} + /* public functions */ void workbench_forward_engine_init(WORKBENCH_Data *vedata) { @@ -273,38 +301,18 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) if (!e_data.next_object_id) { e_data.next_object_id = 1; - memset(e_data.composite_sh_cache, 0x00, sizeof(e_data.composite_sh_cache)); - memset(e_data.transparent_accum_sh_cache, 0x00, sizeof(e_data.transparent_accum_sh_cache)); - - char *defines = workbench_material_build_defines(wpd, false, false); - char *defines_texture = workbench_material_build_defines(wpd, true, false); - char *defines_hair = workbench_material_build_defines(wpd, false, true); - char *forward_vert = workbench_build_forward_vert(false); - char *forward_hair_vert = workbench_build_forward_vert(true); - e_data.object_outline_sh = DRW_shader_create( - forward_vert, NULL, - datatoc_workbench_forward_depth_frag_glsl, defines); - e_data.object_outline_texture_sh = DRW_shader_create( - forward_vert, NULL, - datatoc_workbench_forward_depth_frag_glsl, defines_texture); - e_data.object_outline_hair_sh = DRW_shader_create( - forward_hair_vert, NULL, - datatoc_workbench_forward_depth_frag_glsl, defines_hair); + workbench_forward_outline_shaders_ensure(wpd); e_data.checker_depth_sh = DRW_shader_create_fullscreen( datatoc_workbench_checkerboard_depth_frag_glsl, NULL); - MEM_freeN(forward_hair_vert); - MEM_freeN(forward_vert); - MEM_freeN(defines); - MEM_freeN(defines_texture); - MEM_freeN(defines_hair); + } workbench_volume_engine_init(); workbench_fxaa_engine_init(); workbench_taa_engine_init(vedata); - select_forward_shaders(wpd); + workbench_forward_choose_shaders(wpd); const float *viewport_size = DRW_viewport_size_get(); const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]}; @@ -337,7 +345,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) }); workbench_volume_cache_init(vedata); - const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); + const bool do_cull = CULL_BACKFACE_ENABLED(wpd); const int cull_state = (do_cull) ? DRW_STATE_CULL_BACK : 0; /* Transparency Accum */ @@ -460,7 +468,7 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O int interp; workbench_material_get_image_and_mat(ob, part->omat, &image, &interp, &mat); int color_type = workbench_material_determine_color_type(wpd, image, ob); - WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, color_type, interp); + WORKBENCH_MaterialData *material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, color_type, interp); struct GPUShader *shader = (color_type != V3D_SHADING_TEXTURE_COLOR) ? wpd->transparent_accum_hair_sh @@ -541,7 +549,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) int interp; workbench_material_get_image_and_mat(ob, i + 1, &image, &interp, &mat); int color_type = workbench_material_determine_color_type(wpd, image, ob); - material = get_or_create_material_data(vedata, ob, mat, image, color_type, interp); + material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, color_type, interp); DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob); DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob); } @@ -557,7 +565,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) /* No material split needed */ struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { - material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0); + material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0); if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat); if (!is_wire) { @@ -588,7 +596,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) } Material *mat = give_current_material(ob, i + 1); - material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); + material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat); if (!is_wire) { diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 35cd9571711..90b2c7a3369 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -61,6 +61,8 @@ #define CAVITY_ENABLED(wpd) (CURVATURE_ENABLED(wpd) || SSAO_ENABLED(wpd)) #define SHADOW_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_SHADOW) #define GHOST_ENABLED(psl) (!DRW_pass_is_empty(psl->ghost_prepass_pass) || !DRW_pass_is_empty(psl->ghost_prepass_hair_pass)) +#define CULL_BACKFACE_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_BACKFACE_CULLING) != 0) +#define OIT_ENABLED(wpd) (wpd->shading.color_type == V3D_SHADING_MATERIAL_COLOR) #define IS_NAVIGATING(wpd) ((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING)) #define FXAA_ENABLED(wpd) ((!DRW_state_is_opengl_render()) && \ @@ -135,6 +137,7 @@ typedef struct WORKBENCH_PassList { struct DRWPass *shadow_depth_fail_caps_mani_pass; struct DRWPass *composite_pass; struct DRWPass *composite_shadow_pass; + struct DRWPass *oit_composite_pass; struct DRWPass *background_pass; struct DRWPass *background_pass_clip; struct DRWPass *ghost_resolve_pass; @@ -190,6 +193,7 @@ BLI_STATIC_ASSERT_ALIGN(WORKBENCH_UBO_World, 16) typedef struct WORKBENCH_PrivateData { struct GHash *material_hash; + struct GHash *material_transp_hash; struct GPUShader *prepass_solid_sh; struct GPUShader *prepass_solid_hair_sh; struct GPUShader *prepass_texture_sh; @@ -317,6 +321,12 @@ void workbench_forward_cache_init(WORKBENCH_Data *vedata); void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob); void workbench_forward_cache_finish(WORKBENCH_Data *vedata); +/* For OIT in deferred */ +void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd); +void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd); +WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data( + WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type, int interp); + /* workbench_effect_aa.c */ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx); void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx); |