couch/shaders/flat.frag

47 lines
739 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;
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;
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-22 15:27:32 -06:00
bool cullBack;
2021-01-21 15:26:39 -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-22 15:27:32 -06:00
if (material.usesColor) {
2021-01-20 20:49:12 -06:00
FragColor += vec4(material.color, 1.0);
}
2021-01-22 15:27:32 -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-22 15:27:32 -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
2021-01-22 15:27:32 -06:00
if (material.cullBack && !gl_FrontFacing) {
discard;
}
2021-01-21 15:26:39 -06:00
if (!material.unshaded) {
FragColor *= vec4(AMBIENT + DIFFUSE + SPECULAR, 1.0);
2021-01-21 15:26:39 -06:00
}
2021-01-13 10:42:57 -06:00
}