diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-03-19 17:41:14 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-03-19 17:43:49 +0300 |
commit | e226460dd35b1439092888f280b00e7993d78f13 (patch) | |
tree | 8645c94e5980c145bf156edfaf35a3aded0632af /source/blender/draw | |
parent | 9b8eef9d9c4a337bcdb9127bec63513dd0ee7e54 (diff) |
Workbench: World Clipping For Specular Transparent
When Specular Transparent materials are used the world clipping
did not work on the transparent materials. The reason was that the
accum shaders did not vary on the existance of the clipping planes
This patch will variate the accum shaders when clipping planes are
active.
Reviewed By: fclem
Maniphest Tasks: T61023
Diffstat (limited to 'source/blender/draw')
4 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index b4175935b7a..1fe0202da5b 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -824,7 +824,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( DRW_shgroup_stencil_mask(material->shgrp, (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF); DRW_shgroup_uniform_int(material->shgrp, "object_id", &material->object_id, 1); workbench_material_shgroup_uniform(wpd, material->shgrp, material, ob, true, true, interp); - if (wpd->world_clip_planes) { + if (WORLD_CLIPPING_ENABLED(wpd)) { const DRWContextState *draw_ctx = DRW_context_state_get(); RegionView3D *rv3d = draw_ctx->rv3d; DRW_shgroup_world_clip_planes_from_rv3d(material->shgrp, rv3d); diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index d6a11a2b1e7..bf5de40bbef 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -199,7 +199,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data( } material->object_id = engine_object_data->object_id; DRW_shgroup_uniform_int(material->shgrp_object_outline, "object_id", &material->object_id, 1); - if (wpd->world_clip_planes) { + if (WORLD_CLIPPING_ENABLED(wpd)) { const DRWContextState *draw_ctx = DRW_context_state_get(); RegionView3D *rv3d = draw_ctx->rv3d; DRW_shgroup_world_clip_planes_from_rv3d(material->shgrp_object_outline, rv3d); diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 47895f8729b..0bca8541e80 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -130,7 +130,7 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_text if (is_hair) { BLI_dynstr_appendf(ds, "#define HAIR_SHADER\n"); } - if (wpd->world_clip_planes != NULL) { + if (WORLD_CLIPPING_ENABLED(wpd)) { BLI_dynstr_appendf(ds, "#define USE_WORLD_CLIP_PLANES\n"); } @@ -192,7 +192,7 @@ int workbench_material_get_prepass_shader_index( SET_FLAG_FROM_TEST(index, NORMAL_VIEWPORT_PASS_ENABLED(wpd), 1 << 3); SET_FLAG_FROM_TEST(index, MATCAP_ENABLED(wpd), 1 << 4); SET_FLAG_FROM_TEST(index, use_textures, 1 << 5); - SET_FLAG_FROM_TEST(index, wpd->world_clip_planes != NULL, 1 << 6); + SET_FLAG_FROM_TEST(index, WORLD_CLIPPING_ENABLED(wpd), 1 << 6); BLI_assert(index < MAX_PREPASS_SHADERS); return index; } @@ -207,6 +207,7 @@ int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, bool u SET_FLAG_FROM_TEST(index, is_hair, 1 << 3); /* 1 bits SHADOWS (only facing factor) */ SET_FLAG_FROM_TEST(index, SHADOW_ENABLED(wpd), 1 << 4); + SET_FLAG_FROM_TEST(index, WORLD_CLIPPING_ENABLED(wpd), 1 << 5); BLI_assert(index < MAX_ACCUM_SHADERS); return index; } @@ -281,7 +282,7 @@ void workbench_material_shgroup_uniform( DRW_shgroup_uniform_float(grp, "materialRoughness", &material->roughness, 1); } - if (wpd->world_clip_planes != NULL) { + if (WORLD_CLIPPING_ENABLED(wpd)) { DRW_shgroup_uniform_vec4(grp, "WorldClipPlanes", wpd->world_clip_planes[0], 6); DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index eb1d9c4e860..9f13a1c9999 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -39,7 +39,7 @@ #define M_GOLDEN_RATION_CONJUGATE 0.618033988749895 #define MAX_COMPOSITE_SHADERS (1 << 6) #define MAX_PREPASS_SHADERS (1 << 7) -#define MAX_ACCUM_SHADERS (1 << 5) +#define MAX_ACCUM_SHADERS (1 << 6) #define MAX_CAVITY_SHADERS (1 << 3) #define TEXTURE_DRAWING_ENABLED(wpd) (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) @@ -71,6 +71,7 @@ #define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd)) #define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) || SSAO_ENABLED(wpd) || CURVATURE_ENABLED(wpd)) #define NORMAL_ENCODING_ENABLED() (true) +#define WORLD_CLIPPING_ENABLED(wpd) (wpd->world_clip_planes != NULL) struct RenderEngine; |