-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathDissolve.frag
More file actions
52 lines (42 loc) · 1.26 KB
/
Dissolve.frag
File metadata and controls
52 lines (42 loc) · 1.26 KB
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
#version 130
in vec2 textureUV;
in vec4 vertexColor;
out vec4 FragColor;
uniform sampler2D rteTexture;
uniform sampler2D rtePalette;
uniform vec4 rteColor;
// Pseudo random number generator.
float hash( vec2 a )
{
return fract( sin( a.x * 3433.8 + a.y * 3843.98 ) * 45933.8 );
}
// Value noise courtesy of BigWingz
// check his youtube channel he has
// a video of this one.
// Succint version by FabriceNeyret
float noise( vec2 U )
{
vec2 id = floor( U );
U = fract( U );
U *= U * ( 3. - 2. * U );
vec2 A = vec2( hash(id), hash(id + vec2(0,1)) );
vec2 B = vec2( hash(id + vec2(1,0)), hash(id + vec2(1,1)) );
vec2 C = mix( A, B, U.x);
return mix( C.x, C.y, U.y );
}
vec4 texture2DAA(sampler2D tex, vec2 uv) {
vec2 texsize = vec2(textureSize(tex, 0));
vec2 uv_texspace = uv * texsize;
vec2 seam = floor(uv_texspace + .5);
uv_texspace = (uv_texspace - seam) / fwidth(uv_texspace) + seam;
uv_texspace = clamp(uv_texspace, seam - .5, seam + .5);
return texture(tex, uv_texspace / texsize);
}
void main() {
if (noise(gl_FragCoord.xy + textureUV) < 0.5) {
discard;
}
float red = texture2D(rteTexture, textureUV).r;
vec4 color = texture2DAA(rtePalette, vec2(red * vertexColor.r, 0.0)) * vec4(rteColor.rgb, rteColor.a * vertexColor.a);
FragColor = color;
}