2021-01-13 10:42:57 -06:00
|
|
|
#version 330 core
|
|
|
|
|
2021-01-22 14:37:32 -06:00
|
|
|
noperspective in vec2 UV;
|
2021-01-21 15:26:39 -06:00
|
|
|
in vec3 NORMAL;
|
2021-01-22 14:40:45 -06:00
|
|
|
|
|
|
|
flat in vec3 AMBIENT;
|
|
|
|
flat in vec3 DIFFUSE;
|
|
|
|
flat in vec3 SPECULAR;
|
2021-01-13 10:42:57 -06:00
|
|
|
|
2021-01-20 20:49:12 -06:00
|
|
|
out vec4 FragColor;
|
|
|
|
|
2021-01-17 14:36:38 -06:00
|
|
|
struct Material {
|
|
|
|
vec3 color;
|
|
|
|
bool usesColor;
|
|
|
|
sampler2D tex;
|
|
|
|
bool usesTex;
|
2021-01-20 20:49:12 -06:00
|
|
|
float alphaScissor;
|
2021-01-21 15:26:39 -06:00
|
|
|
bool unshaded;
|
|
|
|
};
|
|
|
|
|
2021-01-17 14:36:38 -06:00
|
|
|
uniform Material material;
|
|
|
|
|
2021-01-13 10:42:57 -06:00
|
|
|
void main() {
|
2021-01-20 20:49:12 -06:00
|
|
|
FragColor = vec4(0.0);
|
2021-01-17 14:36:38 -06:00
|
|
|
if (material.usesColor) {
|
2021-01-20 20:49:12 -06:00
|
|
|
FragColor += vec4(material.color, 1.0);
|
2021-01-17 14:36:38 -06:00
|
|
|
}
|
|
|
|
if (material.usesTex) {
|
2021-01-22 14:37:32 -06:00
|
|
|
FragColor += texture(material.tex, UV);
|
2021-01-20 12:50:59 -06:00
|
|
|
}
|
2021-01-20 20:49:12 -06:00
|
|
|
if (FragColor.w < material.alphaScissor) {
|
2021-01-20 12:50:59 -06:00
|
|
|
discard;
|
2021-01-17 14:36:38 -06:00
|
|
|
}
|
2021-01-21 15:26:39 -06:00
|
|
|
|
|
|
|
if (!material.unshaded) {
|
2021-01-22 14:40:45 -06:00
|
|
|
FragColor *= vec4(AMBIENT + DIFFUSE + SPECULAR, 1.0);
|
2021-01-21 15:26:39 -06:00
|
|
|
}
|
2021-01-13 10:42:57 -06:00
|
|
|
}
|