Extra2D/examples/scene_graph_demo/romfs/shader/default.glsl

66 lines
1.2 KiB
GLSL

#type vertex
#version 320 es
precision highp float;
layout(std140, binding = 0) uniform GlobalUBO {
mat4 uViewProjection;
vec4 uCameraPosition;
float uTime;
float uDeltaTime;
vec2 uScreenSize;
};
layout(std140, binding = 1) uniform MaterialUBO {
vec4 uColor;
vec4 uTintColor;
float uOpacity;
float uPadding[3];
};
uniform mat4 uModelMatrix;
layout(location = 0) in vec2 aPosition;
layout(location = 1) in vec2 aTexCoord;
layout(location = 2) in vec4 aColor;
out vec2 vTexCoord;
out vec4 vColor;
out vec4 vTintColor;
out float vOpacity;
void main() {
gl_Position = uViewProjection * uModelMatrix * vec4(aPosition, 0.0, 1.0);
vTexCoord = aTexCoord;
vColor = aColor * uColor;
vTintColor = uTintColor;
vOpacity = uOpacity;
}
#type fragment
#version 320 es
precision highp float;
in vec2 vTexCoord;
in vec4 vColor;
in vec4 vTintColor;
in float vOpacity;
uniform sampler2D uTexture;
out vec4 fragColor;
void main() {
vec4 texColor = texture(uTexture, vTexCoord);
if (texColor.rgb == vec3(0.0) || texColor.a < 0.01) {
texColor = vec4(1.0, 1.0, 1.0, 1.0);
}
fragColor = texColor * vColor * vTintColor;
fragColor.a *= vOpacity;
if (fragColor.a < 0.01) {
discard;
}
}