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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
uniform vec2 invrendertargetdim;
//texture coordinates for framebuffer read
varying vec4 uvcoordsvar;
/* color texture coordinates, offset by a small amount */
varying vec2 color_uv1;
varying vec2 color_uv2;
varying vec2 depth_uv1;
varying vec2 depth_uv2;
varying vec2 depth_uv3;
varying vec2 depth_uv4;
//very simple shader for gull screen FX, just pass values on
void vert_generic()
{
uvcoordsvar = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
}
void vert_dof_first_pass()
{
/* we offset the texture coordinates by 1.5 pixel,
* then we reuse that to sample the surrounding pixels */
color_uv1 = gl_MultiTexCoord0.xy + vec2(-1.5, -1.5) * invrendertargetdim;
color_uv2 = gl_MultiTexCoord0.xy + vec2(0.5, -1.5) * invrendertargetdim;
depth_uv1 = gl_MultiTexCoord0.xy + vec2(-1.5, -1.5) * invrendertargetdim;
depth_uv2 = gl_MultiTexCoord0.xy + vec2(-0.5, -1.5) * invrendertargetdim;
depth_uv3 = gl_MultiTexCoord0.xy + vec2(0.5, -1.5) * invrendertargetdim;
depth_uv4 = gl_MultiTexCoord0.xy + vec2(1.5, -1.5) * invrendertargetdim;
gl_Position = gl_Vertex;
}
void vert_dof_fourth_pass()
{
vec4 halfpixel = vec4(-0.5, 0.5, -0.5, 0.5);
uvcoordsvar = gl_MultiTexCoord0.xxyy +
halfpixel *
vec4(invrendertargetdim.x,
invrendertargetdim.x,
invrendertargetdim.y,
invrendertargetdim.y);
gl_Position = gl_Vertex;
}
void vert_dof_fifth_pass()
{
vec4 halfpixel = vec4(-0.5, 0.5, -0.5, 0.5);
color_uv1 = vec2(0.5, 1.5) * invrendertargetdim;
uvcoordsvar = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
}
void main()
{
#ifdef FIRST_PASS
vert_dof_first_pass();
#elif defined(FOURTH_PASS)
vert_dof_fourth_pass();
#elif defined(FIFTH_PASS)
vert_dof_fifth_pass();
#else
vert_generic();
#endif
}
|