couch/shaders/flat.frag

36 lines
578 B
GLSL
Raw Normal View History

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-21 18:29:49 -06:00
flat in vec3 LIGHT;
2021-01-13 10:42:57 -06:00
2021-01-20 20:49:12 -06:00
out vec4 FragColor;
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;
};
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);
if (material.usesColor) {
2021-01-20 20:49:12 -06:00
FragColor += vec4(material.color, 1.0);
}
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-21 15:26:39 -06:00
if (!material.unshaded) {
2021-01-21 18:03:50 -06:00
FragColor *= vec4(LIGHT, 1.0);
2021-01-21 15:26:39 -06:00
}
2021-01-13 10:42:57 -06:00
}