-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor_texture.fragment
More file actions
106 lines (84 loc) · 2.12 KB
/
Copy pathcolor_texture.fragment
File metadata and controls
106 lines (84 loc) · 2.12 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// __multiversion__
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
// attribute to in
// varying to out when in vertex shaders or in when in fragment shaders
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
// texture2D to texture
#if __VERSION__ >= 300
#ifdef MSAA_FRAMEBUFFER_ENABLED
#define _centroid centroid
#else
#define _centroid
#endif
// version 300 code
_centroid in vec2 uv;
#define varying in
#define texture2D texture
out vec4 FragColor;
#define gl_FragColor FragColor
#else
// version 100 code
varying vec2 uv;
#endif
uniform sampler2D TEXTURE_0;
uniform sampler2D TEXTURE_1;
uniform vec4 OVERLAY_COLOR;
#ifdef ENABLE_VERTEX_TINT_MASK
uniform vec4 CHANGE_COLOR;
#endif
#ifdef GLINT
uniform vec4 GLINT_COLOR;
#endif
varying vec4 color;
#ifdef ENABLE_FOG
varying vec4 fogColor;
#endif
#ifdef GLINT
varying vec2 layer1UV;
varying vec2 layer2UV;
vec4 glintBlend(vec4 dest, vec4 source) {
return vec4(source.rgb * source.rgb, 0.0) + dest;
}
#endif
void main()
{
vec4 diffuse = texture2D( TEXTURE_0, uv );
#ifdef ALPHA_TEST
#ifdef ENABLE_VERTEX_TINT_MASK
if(diffuse.a <= 0.0)
#else
if(diffuse.a < 0.5)
#endif
discard;
#endif
#ifdef ENABLE_VERTEX_TINT_MASK
diffuse.rgb = mix(diffuse.rgb, diffuse.rgb*color.rgb, diffuse.a);
if (color.a > 0.0) {
diffuse.a = (diffuse.a > 0.0) ? 1.0 : 0.0;
}
#endif
#ifdef GLINT
vec4 layer1 = texture2D(TEXTURE_1, fract(layer1UV)).rgbr * GLINT_COLOR;
vec4 layer2 = texture2D(TEXTURE_1, fract(layer2UV)).rgbr * GLINT_COLOR;
vec4 glint = (layer1 + layer2);
#ifdef INVENTORY
diffuse.rgb = glint.rgb;
#else
diffuse.rgb = glintBlend(diffuse, glint).rgb;
#endif
#endif
#ifdef USE_OVERLAY
//use either the diffuse or the OVERLAY_COLOR
diffuse.rgb = mix(diffuse, OVERLAY_COLOR, OVERLAY_COLOR.a).rgb;
#endif
#ifdef ENABLE_FOG
//apply fog
diffuse.rgb = mix( diffuse.rgb, fogColor.rgb, fogColor.a );
#endif
#ifdef ENABLE_VERTEX_TINT_MASK
gl_FragColor = diffuse;
#else
gl_FragColor = diffuse * color;
#endif
}