Textures and colors passed to shader via Uniforms

This commit is contained in:
Dane Johnson
2021-01-17 14:36:38 -06:00
parent e243a666f1
commit 5e8d693758
21 changed files with 7960 additions and 16 deletions

View File

@@ -1,9 +1,24 @@
#version 330 core
uniform vec3 color;
in vec2 UV;
out vec4 FragColor;
struct Material {
vec3 color;
bool usesColor;
sampler2D tex;
bool usesTex;
};
uniform Material material;
void main() {
FragColor = vec4(color, 1.0);
FragColor = vec4(0.0);
if (material.usesColor) {
FragColor += vec4(material.color, 1.0);
}
if (material.usesTex) {
FragColor += texture(material.tex, UV);
}
}

View File

@@ -1,11 +1,15 @@
#version 330 core
layout (location = 0) in vec3 pos;
layout (location = 1) in vec2 uv;
uniform mat4 MODEL;
uniform mat4 VIEW;
uniform mat4 PROJECTION;
out vec2 UV;
void main() {
gl_Position = PROJECTION * VIEW * MODEL * vec4(pos, 1.0);
UV = uv;
}