couch/shaders/flat.frag

47 lines
665 B
GLSL
Raw Permalink 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-22 18:44:43 -06:00
in vec3 AMBIENT;
in vec3 DIFFUSE;
in vec3 SPECULAR;
2021-01-23 23:49:13 -06:00
flat in float kill;
2021-01-13 10:42:57 -06:00
2021-01-20 20:49:12 -06:00
out vec4 FragColor;
struct Material {
sampler2D tex;
bool usesTex;
2021-01-22 18:44:43 -06:00
vec3 ambient;
vec3 diffuse;
vec3 specular;
int shininess;
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-22 18:44:43 -06:00
FragColor = vec4(AMBIENT + DIFFUSE + SPECULAR, 1.0);
2021-01-22 15:27:32 -06:00
if (material.usesTex) {
2021-01-22 18:44:43 -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-23 23:49:13 -06:00
if (kill == 1.0) {
discard;
}
2021-01-13 10:42:57 -06:00
}