summaryrefslogtreecommitdiff
path: root/assets/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'assets/shaders')
-rw-r--r--assets/shaders/texture.frag16
-rw-r--r--assets/shaders/vert.vert32
2 files changed, 48 insertions, 0 deletions
diff --git a/assets/shaders/texture.frag b/assets/shaders/texture.frag
new file mode 100644
index 0000000..e63995f
--- /dev/null
+++ b/assets/shaders/texture.frag
@@ -0,0 +1,16 @@
+# version 450
+
+layout(location = 0) in vec3 fragColor;
+layout(location = 1) in vec3 fragTexCoord;
+
+layout(location = 0) out vec4 outColor;
+
+layout(binding = 1) uniform sampler2D texSampler;
+
+void main() {
+ vec4 color = texture(texSampler, fragTexCoord.xy);
+ if (color.w == 0) {
+ discard;
+ }
+ outColor = color;
+}
diff --git a/assets/shaders/vert.vert b/assets/shaders/vert.vert
new file mode 100644
index 0000000..f3e7cf2
--- /dev/null
+++ b/assets/shaders/vert.vert
@@ -0,0 +1,32 @@
+#version 450
+
+layout(binding = 0) uniform UniformBufferObject {
+ mat4 model;
+ mat4 view;
+ mat4 proj;
+} ubo;
+
+// vertex
+layout(location = 0) in vec4 inColor;
+layout(location = 1) in vec3 inPosition;
+layout(location = 2) in vec3 inNorm;
+layout(location = 3) in vec2 inTexCoord;
+
+// instance
+layout(location = 4) in mat4 instPosRotScale;
+layout(location = 8) in float textureIndex;
+
+// output
+layout(location = 0) out vec3 fragColor;
+layout(location = 1) out vec3 fragTexCoord;
+
+void main() {
+ gl_Position =
+ ubo.proj *
+ ubo.view *
+ ubo.model *
+ instPosRotScale *
+ vec4(inPosition, 1.0);
+ fragColor = inColor;
+ fragTexCoord = vec3(inTexCoord, textureIndex);
+}