Shader refactor

This commit is contained in:
Dane Johnson
2021-01-22 15:27:32 -06:00
parent b08552c9fa
commit 1ee5ed3e88
11 changed files with 38 additions and 42 deletions

View File

@@ -16,22 +16,30 @@ struct Material {
bool usesTex;
float alphaScissor;
bool unshaded;
bool cullBack;
};
uniform Material material;
void main() {
FragColor = vec4(0.0);
if (material.usesColor) {
FragColor += vec4(material.color, 1.0);
}
if (material.usesTex) {
FragColor += texture(material.tex, UV);
}
if (FragColor.w < material.alphaScissor) {
discard;
}
if (material.cullBack && !gl_FrontFacing) {
discard;
}
if (!material.unshaded) {
FragColor *= vec4(AMBIENT + DIFFUSE + SPECULAR, 1.0);
}

View File

@@ -4,15 +4,8 @@ in vec2 UV;
out vec4 FragColor;
struct Material {
vec3 color;
bool usesColor;
sampler2D tex;
bool usesTex;
};
uniform Material material;
uniform sampler2D tex;
void main() {
FragColor = texture(material.tex, UV);
FragColor = texture(tex, UV);
}