-
-
Notifications
You must be signed in to change notification settings - Fork 213
/
shader.frag
84 lines (46 loc) · 1.13 KB
/
shader.frag
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
73
74
75
76
77
78
79
80
81
82
83
84
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform vec2 resolution;
uniform vec2 texelSize;
uniform float cameraNear;
uniform float cameraFar;
uniform float aspect;
uniform float time;
varying vec2 vUv;
float readDepth(const in vec2 uv) {
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer, uv));
#else
return texture2D(depthBuffer, uv).r;
#endif
}
float getViewZ(const in float depth) {
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
#else
return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
#endif
}
FRAGMENT_HEAD
void main() {
FRAGMENT_MAIN_UV
vec4 color0 = texture2D(inputBuffer, UV);
vec4 color1 = vec4(0.0);
FRAGMENT_MAIN_IMAGE
gl_FragColor = color0;
#ifdef ENCODE_OUTPUT
#include <encodings_fragment>
#endif
#include <dithering_fragment>
}