forked from lettier/3d-game-shaders-for-beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilm-grain.frag
More file actions
46 lines (33 loc) 路 715 Bytes
/
Copy pathfilm-grain.frag
File metadata and controls
46 lines (33 loc) 路 715 Bytes
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
/*
(C) 2019 David Lettier
lettier.com
*/
#version 150
uniform vec2 pi;
uniform float osg_FrameTime;
uniform sampler2D colorTexture;
uniform vec2 enabled;
out vec4 fragColor;
void main() {
float amount = 0.01;
vec2 texSize = textureSize(colorTexture, 0).xy;
vec2 texCoord = gl_FragCoord.xy / texSize;
vec4 color = texture(colorTexture, texCoord);
if (enabled.x == 1) {
float randomIntensity =
fract
( 10000
* sin
(
( gl_FragCoord.x
+ gl_FragCoord.y
* osg_FrameTime
)
* pi.y
)
);
amount *= randomIntensity;
color.rgb += amount;
}
fragColor = color;
}