Commit: 6b1042f45a587280cdeed167d941478cb39e40c7 Author: Jeroen Bakker Date: Wed Oct 7 17:17:19 2020 +0200 Branches: blender-v2.83-release https://developer.blender.org/rB6b1042f45a587280cdeed167d941478cb39e40c7
Fix T81254: Incorrect calculation of EEVEE Transmittance Volumetrics Regular rendering uses a custom blend mode, but render passes renders to 2 separate textures. This wasn't configured correctly inside the fragment shaders. This patch adds a switch to configure the fragment shader with the correct attachments. Backport to Blender 2.83. Reviewed By: Clément Foucault Differential Revision: https://developer.blender.org/D9038 =================================================================== M source/blender/draw/engines/eevee/eevee_volumes.c M source/blender/draw/engines/eevee/shaders/volumetric_accum_frag.glsl M source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl =================================================================== diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 1c74003bf12..acae4b3534b 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -58,7 +58,7 @@ static struct { struct GPUShader *scatter_sh; struct GPUShader *scatter_with_lights_sh; struct GPUShader *volumetric_integration_sh; - struct GPUShader *volumetric_resolve_sh; + struct GPUShader *volumetric_resolve_sh[2]; struct GPUShader *volumetric_accum_sh; GPUTexture *depth_src; @@ -141,11 +141,18 @@ static void eevee_create_shader_volumes(void) "#extension GL_ARB_shading_language_420pack: enable\n" "#define USE_VOLUME_OPTI\n" : NULL); - e_data.volumetric_resolve_sh = DRW_shader_create_with_lib(datatoc_common_fullscreen_vert_glsl, - NULL, - datatoc_volumetric_resolve_frag_glsl, - e_data.volumetric_common_lib, - NULL); + e_data.volumetric_resolve_sh[0] = DRW_shader_create_with_lib( + datatoc_common_fullscreen_vert_glsl, + NULL, + datatoc_volumetric_resolve_frag_glsl, + e_data.volumetric_common_lib, + NULL); + e_data.volumetric_resolve_sh[1] = DRW_shader_create_with_lib( + datatoc_common_fullscreen_vert_glsl, + NULL, + datatoc_volumetric_resolve_frag_glsl, + e_data.volumetric_common_lib, + "#define VOLUMETRICS_ACCUM\n"); e_data.volumetric_accum_sh = DRW_shader_create_fullscreen(datatoc_volumetric_accum_frag_glsl, NULL); @@ -678,7 +685,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) grp, NULL, USE_VOLUME_OPTI ? 1 : common_data->vol_tex_size[2]); DRW_PASS_CREATE(psl->volumetric_resolve_ps, DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM); - grp = DRW_shgroup_create(e_data.volumetric_resolve_sh, psl->volumetric_resolve_ps); + grp = DRW_shgroup_create(e_data.volumetric_resolve_sh[0], psl->volumetric_resolve_ps); DRW_shgroup_uniform_texture_ref(grp, "inScattering", &txl->volume_scatter); DRW_shgroup_uniform_texture_ref(grp, "inTransmittance", &txl->volume_transmit); DRW_shgroup_uniform_texture_ref(grp, "inSceneDepth", &e_data.depth_src); @@ -874,7 +881,8 @@ void EEVEE_volumes_free(void) DRW_SHADER_FREE_SAFE(e_data.scatter_sh); DRW_SHADER_FREE_SAFE(e_data.scatter_with_lights_sh); DRW_SHADER_FREE_SAFE(e_data.volumetric_integration_sh); - DRW_SHADER_FREE_SAFE(e_data.volumetric_resolve_sh); + DRW_SHADER_FREE_SAFE(e_data.volumetric_resolve_sh[0]); + DRW_SHADER_FREE_SAFE(e_data.volumetric_resolve_sh[1]); DRW_SHADER_FREE_SAFE(e_data.volumetric_accum_sh); } @@ -915,7 +923,7 @@ void EEVEE_volumes_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRW_PASS_CREATE(psl->volumetric_accum_ps, DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ADD_FULL); DRWShadingGroup *grp = NULL; if ((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) { - grp = DRW_shgroup_create(e_data.volumetric_resolve_sh, psl->volumetric_accum_ps); + grp = DRW_shgroup_create(e_data.volumetric_resolve_sh[1], psl->volumetric_accum_ps); DRW_shgroup_uniform_texture_ref(grp, "inScattering", &txl->volume_scatter); DRW_shgroup_uniform_texture_ref(grp, "inTransmittance", &txl->volume_transmit); DRW_shgroup_uniform_texture_ref(grp, "inSceneDepth", &e_data.depth_src); diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_accum_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_accum_frag.glsl index 1b6a7b33f42..d8ce7905a1a 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_accum_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_accum_frag.glsl @@ -1,8 +1,8 @@ /* This shader is used to add default values to the volume accum textures. * so it looks similar (transmittance = 1, scattering = 0) */ -layout(location = 0, index = 0) out vec4 FragColor0; -layout(location = 0, index = 1) out vec4 FragColor1; +layout(location = 0) out vec4 FragColor0; +layout(location = 1) out vec4 FragColor1; void main() { diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl index 1ff7e848c40..1c2465f6b0d 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl @@ -7,8 +7,13 @@ uniform sampler2D inSceneDepth; /* Blend equation is : FragColor0 + FragColor1 * DstColor */ +#ifdef VOLUMETRICS_ACCUM +layout(location = 0) out vec4 FragColor0; +layout(location = 1) out vec4 FragColor1; +#else layout(location = 0, index = 0) out vec4 FragColor0; layout(location = 0, index = 1) out vec4 FragColor1; +#endif void main() { _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs