Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_downsample_comp.glsl')
-rw-r--r--source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_downsample_comp.glsl32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_downsample_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_downsample_comp.glsl
new file mode 100644
index 00000000000..3d45f285da9
--- /dev/null
+++ b/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_downsample_comp.glsl
@@ -0,0 +1,32 @@
+
+/**
+ * Downsample pass: CoC aware downsample to quarter resolution.
+ *
+ * Pretty much identical to the setup pass but get CoC from buffer.
+ * Also does not weight luma for the bilateral weights.
+ */
+
+#pragma BLENDER_REQUIRE(eevee_depth_of_field_lib.glsl)
+
+void main()
+{
+ vec2 halfres_texel_size = 1.0 / vec2(textureSize(color_tx, 0).xy);
+ /* Center uv around the 4 halfres pixels. */
+ vec2 quad_center = vec2(gl_GlobalInvocationID * 2 + 1) * halfres_texel_size;
+
+ vec4 colors[4];
+ vec4 cocs;
+ for (int i = 0; i < 4; i++) {
+ vec2 sample_uv = quad_center + quad_offsets[i] * halfres_texel_size;
+ colors[i] = textureLod(color_tx, sample_uv, 0.0);
+ cocs[i] = textureLod(coc_tx, sample_uv, 0.0).r;
+ }
+
+ vec4 weights = dof_bilateral_coc_weights(cocs);
+ /* Normalize so that the sum is 1. */
+ weights *= safe_rcp(sum(weights));
+
+ vec4 out_color = weighted_sum_array(colors, weights);
+
+ imageStore(out_color_img, ivec2(gl_GlobalInvocationID.xy), out_color);
+}