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

lightprobe_planar_downsample_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: c2ef085ca019722e7f7b52b99f7fd5c3e52cfc15 (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
31
/**
 * Simple downsample shader. Takes the average of the 4 texels of lower mip.
 **/

uniform sampler2DArray source;
uniform vec2 texelSize;

in vec2 uvs;
flat in float layer;

out vec4 FragColor;

void main()
{
	/* Reconstructing Target uvs like this avoid missing pixels */
	vec2 uvs = gl_FragCoord.xy * 2.0 / vec2(textureSize(source, 0).xy);

#if 0 /* Slower and does not match the main framebuffer downsampling. */
	/* Downsample with a 4x4 box filter */
	vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1);

	FragColor  = texture(source, vec3(uvs + d.xy, layer)).rgba;
	FragColor += texture(source, vec3(uvs + d.zy, layer)).rgba;
	FragColor += texture(source, vec3(uvs + d.xw, layer)).rgba;
	FragColor += texture(source, vec3(uvs + d.zw, layer)).rgba;

	FragColor /= 4.0;
#endif

	FragColor = texture(source, vec3(uvs, layer));
}