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

eevee_depth_of_field_reduce_recursive_frag.glsl « shaders « eevee « engines « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0ab7512fe03fbaaf726a0a277add778e5eae7431 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

/**
 * Reduce recursive pass: Simple coc & luma aware downsampling pass to generate mipmaps.
 **/

#pragma BLENDER_REQUIRE(eevee_depth_of_field_lib.glsl)

/* Downsample pass done for each mip starting from mip1. */
void main()
{
  vec2 input_texel_size = 1.0 / vec2(textureSize(color_tx, 0).xy);
  /* Center uv around the 4 pixels of the previous mip. */
  vec2 quad_center = (floor(gl_FragCoord.xy) * 2.0 + 1.0) * input_texel_size;

  vec4 colors[4];
  vec4 cocs;
  for (int i = 0; i < 4; i++) {
    vec2 sample_uv = quad_center + quad_offsets[i] * input_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);
  weights *= dof_bilateral_color_weights(colors);
  /* Normalize so that the sum is 1. */
  weights *= safe_rcp(sum(weights));

  out_color = weighted_sum_array(colors, weights);
  out_coc = dot(cocs, weights);
}