summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/45-bokeh/fs_bokeh_dof_combine.sc
blob: b60f75725026e4e5c4ef2dda4a29f050a2e03e20 (plain) (blame)
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
$input v_texcoord0

/*
* Copyright 2021 elven cache. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/

#include "../common/common.sh"
#include "parameters.sh"

SAMPLER2D(s_color,			0);
SAMPLER2D(s_blurredColor,	1);

void main()
{
	vec2 texCoord = v_texcoord0.xy;
	vec4 color = texture2D(s_color, texCoord);
	vec4 dofColorSize = texture2D(s_blurredColor, texCoord);
	vec3 dofColor = dofColorSize.xyz;
	float sampleSize = dofColorSize.w;

	float m = saturate(sampleSize-1.0);
	color.xyz = mix(color.xyz, dofColor, m);

	// this pass is writing directly out to backbuffer, convert from linear to gamma
	color.xyz = toGamma(color.xyz);

	gl_FragColor = color;
}