aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag
blob: 76738c31ed6a373090f60fb4e96afcb791d186de (plain)
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
#version 120

varying vec4 passColour;
varying vec3 passNormal;
uniform sampler2D textureIn;

uniform int millis;

//Algorithm by hughsk
vec3 hsv2rgb(vec3 c) {
  vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
  vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
  return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

void main() {
    vec4 texture = texture2D(textureIn, gl_TexCoord[0].st);

    float hue = mod(millis/10000f+gl_TexCoord[0].t, 1f);
    float sat = 0.5f;
    float val = 0.5f;
    vec3 fade = hsv2rgb(vec3(hue, sat, val));

    gl_FragColor = vec4(texture.rgb*texture.a + fade*(1-texture.a), 1f) * passColour;

    vec3 fakeSunNormal = normalize(vec3(0.2f,1f,-0.2f));
    vec3 normNormal = normalize(passNormal);
    float shading = max(0.6f, dot(fakeSunNormal, normNormal));

    gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a);
}