diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-10-13 19:48:28 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-10-13 20:58:14 +0300 |
commit | d39cd851c0ca67dff975b1c447089d319ef0816f (patch) | |
tree | fd5a25fed2625aa5fd05b02590545f07a10eb264 /source/blender/draw/engines/eevee/eevee_occlusion.c | |
parent | 98a62a5c088b18d5dd7d60e733c618d9c3db3a46 (diff) |
Fix T89777 EEVEE: Contact Shadows causes wrong shading in Reflection Plane
The planar reflections being rendered at the same resolution as the HiZ max
buffer, do not need any uv correction during raytracing.
However, the GTAO horizon buffer being at output resolution do need the
uv factors in order to match the pixels visible on screen. To avoid many
complication, we increase the size of the GTAO texture up to the hiz buffer
size. This way, if planar reflections need GTAO the texture is big enough.
We change the viewport of the GTAO framebuffer for the main view in order
to not have to modify Uvs in many places.
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_occlusion.c')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_occlusion.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c index 4c2024a6f65..955cfd990ef 100644 --- a/source/blender/draw/engines/eevee/eevee_occlusion.c +++ b/source/blender/draw/engines/eevee/eevee_occlusion.c @@ -77,14 +77,14 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) common_data->ao_bounce_fac = (scene_eval->eevee.flag & SCE_EEVEE_GTAO_BOUNCE) ? 1.0f : 0.0f; effects->gtao_horizons_renderpass = DRW_texture_pool_query_2d( - fs_size[0], fs_size[1], GPU_RGBA8, &draw_engine_eevee_type); + UNPACK2(effects->hiz_size), GPU_RGBA8, &draw_engine_eevee_type); GPU_framebuffer_ensure_config( &fbl->gtao_fb, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(effects->gtao_horizons_renderpass)}); if (G.debug_value == 6) { effects->gtao_horizons_debug = DRW_texture_pool_query_2d( - fs_size[0], fs_size[1], GPU_RGBA8, &draw_engine_eevee_type); + UNPACK2(fs_size), GPU_RGBA8, &draw_engine_eevee_type); GPU_framebuffer_ensure_config( &fbl->gtao_debug_fb, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(effects->gtao_horizons_debug)}); @@ -188,20 +188,32 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) } } -void EEVEE_occlusion_compute(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) +void EEVEE_occlusion_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) { EEVEE_PassList *psl = vedata->psl; EEVEE_FramebufferList *fbl = vedata->fbl; EEVEE_StorageList *stl = vedata->stl; EEVEE_EffectsInfo *effects = stl->effects; + EEVEE_CommonUniformBuffer *common_data = &sldata->common_data; if ((effects->enabled_effects & EFFECT_GTAO) != 0) { DRW_stats_group_start("GTAO Horizon Scan"); + /** NOTE(fclem): Kind of fragile. We need this to make sure everything lines up + * nicely during planar reflection. */ + if (common_data->ray_type != EEVEE_RAY_GLOSSY) { + const float *viewport_size = DRW_viewport_size_get(); + GPU_framebuffer_viewport_set(fbl->gtao_fb, 0, 0, UNPACK2(viewport_size)); + } + GPU_framebuffer_bind(fbl->gtao_fb); DRW_draw_pass(psl->ao_horizon_search); + if (common_data->ray_type != EEVEE_RAY_GLOSSY) { + GPU_framebuffer_viewport_reset(fbl->gtao_fb); + } + if (GPU_mip_render_workaround() || GPU_type_matches(GPU_DEVICE_INTEL_UHD, GPU_OS_WIN, GPU_DRIVER_ANY)) { /* Fix dot corruption on intel HD5XX/HD6XX series. */ |