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
This commit is contained in:
Jeroen Bakker
2019-03-19 15:41:14 +01:00
parent 9b8eef9d9c
commit e226460dd3
4 changed files with 8 additions and 6 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;