diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-02-04 16:08:21 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-02-04 16:08:27 +0300 |
commit | 0dd3e77d7177cbf75a1370e594020c02e48cfa10 (patch) | |
tree | 054837646510d9bc5ef7cab78c6c59e14fe6e34d /source/blender/draw/engines/workbench/shaders | |
parent | 71fff319905e8061d464d28ef63f15664bf62b47 (diff) |
Cleanup: Workbench: Remove unused resources in cavity shaders
This avoid uneeded resource binds.
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders')
3 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_cavity_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_cavity_info.hh index 60d79ed50d9..29468d6002a 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_cavity_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_cavity_info.hh @@ -3,11 +3,7 @@ GPU_SHADER_CREATE_INFO(workbench_effect_cavity_common) .fragment_out(0, Type::VEC4, "fragColor") - .sampler(0, ImageType::DEPTH_2D, "depthBuffer") - .sampler(1, ImageType::FLOAT_2D, "normalBuffer") - .sampler(2, ImageType::UINT_2D, "objectIdBuffer") - .sampler(3, ImageType::FLOAT_2D, "cavityJitter") - .uniform_buf(3, "vec4", "samples_coords[512]") + .sampler(0, ImageType::FLOAT_2D, "normalBuffer") .uniform_buf(4, "WorldData", "world_data", Frequency::PASS) .typedef_source("workbench_shader_shared.h") .fragment_source("workbench_effect_cavity_frag.glsl") @@ -17,15 +13,23 @@ GPU_SHADER_CREATE_INFO(workbench_effect_cavity_common) GPU_SHADER_CREATE_INFO(workbench_effect_cavity) .do_static_compilation(true) .define("USE_CAVITY") + .uniform_buf(3, "vec4", "samples_coords[512]") + .sampler(1, ImageType::DEPTH_2D, "depthBuffer") + .sampler(2, ImageType::FLOAT_2D, "cavityJitter") .additional_info("workbench_effect_cavity_common"); GPU_SHADER_CREATE_INFO(workbench_effect_curvature) .do_static_compilation(true) .define("USE_CURVATURE") + .sampler(1, ImageType::UINT_2D, "objectIdBuffer") .additional_info("workbench_effect_cavity_common"); GPU_SHADER_CREATE_INFO(workbench_effect_cavity_curvature) .do_static_compilation(true) .define("USE_CAVITY") .define("USE_CURVATURE") + .uniform_buf(3, "vec4", "samples_coords[512]") + .sampler(1, ImageType::DEPTH_2D, "depthBuffer") + .sampler(2, ImageType::FLOAT_2D, "cavityJitter") + .sampler(3, ImageType::UINT_2D, "objectIdBuffer") .additional_info("workbench_effect_cavity_common"); diff --git a/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl index ad83d6f39e5..880f17b0c9d 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_cavity_lib.glsl @@ -5,6 +5,8 @@ /* From The Alchemy screen-space ambient obscurance algorithm * http://graphics.cs.williams.edu/papers/AlchemyHPG11/VV11AlchemyAO.pdf */ +#ifdef USE_CAVITY + void cavity_compute(vec2 screenco, sampler2D depthBuffer, sampler2D normalBuffer, @@ -90,3 +92,5 @@ void cavity_compute(vec2 screenco, cavities = clamp(cavities * world_data.cavity_valley_factor, 0.0, 1.0); edges = edges * world_data.cavity_ridge_factor; } + +#endif /* USE_CAVITY */ diff --git a/source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl index 18a093275c5..a6f7a1f522a 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl @@ -1,4 +1,8 @@ +#pragma BLENDER_REQUIRE(workbench_common_lib.glsl) + +#ifdef USE_CURVATURE + float curvature_soft_clamp(float curvature, float control) { if (curvature < 0.5 / control) { @@ -43,3 +47,5 @@ void curvature_compute(vec2 uv, curvature = 2.0 * curvature_soft_clamp(normal_diff, world_data.curvature_ridge); } } + +#endif /* USE_CURVATURE */ |