49 lines
950 B
GLSL
49 lines
950 B
GLSL
// Basic Texture Shader
|
|
|
|
#type vertex
|
|
#version 430 core
|
|
|
|
layout(location = 0) in vec3 a_Position;
|
|
layout(location = 1) in vec4 a_Color;
|
|
layout(location = 2) in vec2 a_TexCoord;
|
|
layout(location = 3) in int a_TexIndex;
|
|
layout(location = 4) in float a_TilingFactor;
|
|
|
|
uniform mat4 u_ViewProjection;
|
|
|
|
out vec4 v_Color;
|
|
out vec2 v_TexCoord;
|
|
flat out int v_TexIndex;
|
|
out float v_TilingFactor;
|
|
|
|
void main()
|
|
{
|
|
v_Color = a_Color;
|
|
v_TexCoord = a_TexCoord;
|
|
v_TexIndex = a_TexIndex;
|
|
v_TilingFactor = a_TilingFactor;
|
|
gl_Position = u_ViewProjection * vec4(a_Position, 1.0);
|
|
}
|
|
|
|
#type fragment
|
|
#version 430 core
|
|
|
|
layout(location = 0) out vec4 color;
|
|
|
|
in vec4 v_Color;
|
|
in vec2 v_TexCoord;
|
|
flat in int v_TexIndex;
|
|
in float v_TilingFactor;
|
|
|
|
uniform sampler2D u_Textures[32];
|
|
|
|
void main()
|
|
{
|
|
vec4 texColor = texture(u_Textures[v_TexIndex], v_TexCoord * v_TilingFactor) * v_Color;
|
|
|
|
if(texColor.a < 0.1)
|
|
discard;
|
|
|
|
color = texColor;
|
|
}
|