diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-10-29 17:05:07 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-10-29 17:16:47 +0300 |
commit | 883e22a92ca5b2b22bd441bedc6bdd1626980f35 (patch) | |
tree | c031fc40200bf63b65f899ec25e9a4a14ab3f839 /source/blender/draw | |
parent | d758a79557c05487a2b0014f2851597738ea6ef0 (diff) |
Fix T71050 EEVEE: Light Path Node broken in 2.81
Also fixes the sampling of hashed shadows.
Diffstat (limited to 'source/blender/draw')
5 files changed, 20 insertions, 25 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 701d73461fc..5eba1b6c808 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -68,8 +68,6 @@ static struct { uint sss_count; - float alpha_hash_offset; - float alpha_hash_scale; float noise_offsets[3]; } e_data = {NULL}; /* Engine data */ @@ -609,14 +607,14 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, } if (!DRW_state_is_image_render() && ((stl->effects->enabled_effects & EFFECT_TAA) == 0)) { - e_data.alpha_hash_offset = 0.0f; - e_data.alpha_hash_scale = 1.0f; + sldata->common_data.alpha_hash_offset = 0.0f; + sldata->common_data.alpha_hash_scale = 1.0f; } else { double r; BLI_halton_1d(5, 0.0, stl->effects->taa_current_sample - 1, &r); - e_data.alpha_hash_offset = (float)r; - e_data.alpha_hash_scale = 0.01f; + sldata->common_data.alpha_hash_offset = (float)r; + sldata->common_data.alpha_hash_scale = 0.01f; } { @@ -1218,14 +1216,6 @@ static void material_opaque(Material *ma, DRW_shgroup_uniform_float(*shgrp_depth, "alphaThreshold", &ma->alpha_threshold, 1); DRW_shgroup_uniform_float(*shgrp_depth_clip, "alphaThreshold", &ma->alpha_threshold, 1); } - else if (ma->blend_method == MA_BM_HASHED) { - DRW_shgroup_uniform_float(*shgrp_depth, "hashAlphaOffset", &e_data.alpha_hash_offset, 1); - DRW_shgroup_uniform_float( - *shgrp_depth_clip, "hashAlphaOffset", &e_data.alpha_hash_offset, 1); - DRW_shgroup_uniform_float_copy(*shgrp_depth, "hashAlphaScale", e_data.alpha_hash_scale); - DRW_shgroup_uniform_float_copy( - *shgrp_depth_clip, "hashAlphaScale", e_data.alpha_hash_scale); - } } } diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index f4f40d40de6..32c0523474a 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -665,9 +665,13 @@ typedef struct EEVEE_CommonUniformBuffer { float prb_lod_cube_max; /* float */ float prb_lod_planar_max; /* float */ /* Misc */ - int hiz_mip_offset; /* int */ - int ray_type; /* int */ - float ray_depth; /* float */ + int hiz_mip_offset; /* int */ + int ray_type; /* int */ + float ray_depth; /* float */ + float alpha_hash_offset; /* float */ + float alpha_hash_scale; /* float */ + float pad7; /* float */ + float pad8; /* float */ } EEVEE_CommonUniformBuffer; BLI_STATIC_ASSERT_ALIGN(EEVEE_CommonUniformBuffer, 16) diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c index 46fc6e07c1c..1776f535237 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows.c +++ b/source/blender/draw/engines/eevee/eevee_shadows.c @@ -365,7 +365,7 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView /* Precompute all shadow/view test before rendering and trashing the culling cache. */ BLI_bitmap *cube_visible = BLI_BITMAP_NEW_ALLOCA(MAX_SHADOW_CUBE); - bool any_visible = false; + bool any_visible = linfo->cascade_len > 0; for (int cube = 0; cube < linfo->cube_len; cube++) { if (DRW_culling_sphere_test(view, linfo->shadow_bounds + cube)) { BLI_BITMAP_ENABLE(cube_visible, cube); @@ -373,7 +373,7 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView } } - if (!any_visible && linfo->cascade_len == 0) { + if (any_visible) { sldata->common_data.ray_type = EEVEE_RAY_SHADOW; DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); } @@ -400,7 +400,7 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView DRW_uniformbuffer_update(sldata->shadow_ubo, &linfo->shadow_data); /* Update all data at once */ - if (!any_visible && linfo->cascade_len == 0) { + if (any_visible) { sldata->common_data.ray_type = saved_ray_type; DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data); } diff --git a/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl b/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl index c7ae2417904..7f255b0859d 100644 --- a/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl @@ -43,6 +43,10 @@ layout(std140) uniform common_block int hizMipOffset; int rayType; float rayDepth; + float alphaHashOffset; + float alphaHashScale; + float pad7; + float pad8; }; /* rayType (keep in sync with ray_type) */ diff --git a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl index dea6bc020ec..b49dbfceba2 100644 --- a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl @@ -12,14 +12,11 @@ float hash3d(vec3 a) return hash(vec2(hash(a.xy), a.z)); } -uniform float hashAlphaOffset; -uniform float hashAlphaScale = 1.0; /* Roughly in pixel */ - float hashed_alpha_threshold(vec3 co) { /* Find the discretized derivatives of our coordinates. */ float max_deriv = max(length(dFdx(co)), length(dFdy(co))); - float pix_scale = 1.0 / (hashAlphaScale * max_deriv); + float pix_scale = 1.0 / (alphaHashScale * max_deriv); /* Find two nearest log-discretized noise scales. */ float pix_scale_log = log2(pix_scale); @@ -52,7 +49,7 @@ float hashed_alpha_threshold(vec3 co) threshold = clamp(threshold, 1.0e-6, 1.0); /* Jitter the threshold for TAA accumulation. */ - return fract(threshold + hashAlphaOffset); + return fract(threshold + alphaHashOffset); } #endif |