summaryrefslogtreecommitdiff
path: root/assets/shaders
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-09-14 19:24:43 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-09-14 19:41:41 -0400
commit2eb22f8debec811cdea32ed7b8cf3ec98c752f7c (patch)
tree2fb1181c8b1ab0c741db5d408fb9bffe9300f47e /assets/shaders
parentd7ce568e2baacc68424eae4adbb98ac5b126af21 (diff)
Load model textures checkpoint.
Refactors some Vulkan items related to CompGrBinds and EntityTypes. Adds some Vulkan globals related to textures. Adds a number of placeholder items: - Iffy use of setting Vulkan globals on instanced structs. - Unimplemented and inaccurate shaders - Iffy gltf sub-buffer logic (ignores vertex color data) - MipMap TODOs - TextureArray TODOs
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);
+}