From 249f6c9fa384e9e3265cafb1357e502ea7db72f7 Mon Sep 17 00:00:00 2001 From: tylermurphy534 Date: Tue, 20 Sep 2022 22:02:58 -0400 Subject: texture loading --- res/image/scaly.png | Bin 0 -> 3227705 bytes res/image/texture.png | Bin 0 -> 1338368 bytes res/shaders/simple_shader.frag | 7 +++++-- res/shaders/simple_shader.frag.spv | Bin 1112 -> 1456 bytes res/shaders/simple_shader.vert | 16 +++++++++------- res/shaders/simple_shader.vert.spv | Bin 2816 -> 2912 bytes 6 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 res/image/scaly.png create mode 100644 res/image/texture.png (limited to 'res') diff --git a/res/image/scaly.png b/res/image/scaly.png new file mode 100644 index 0000000..cefdd5f Binary files /dev/null and b/res/image/scaly.png differ diff --git a/res/image/texture.png b/res/image/texture.png new file mode 100644 index 0000000..e1db6c1 Binary files /dev/null and b/res/image/texture.png differ diff --git a/res/shaders/simple_shader.frag b/res/shaders/simple_shader.frag index b11a5a8..4eaaafc 100755 --- a/res/shaders/simple_shader.frag +++ b/res/shaders/simple_shader.frag @@ -1,19 +1,22 @@ #version 450 layout (location = 0) in vec3 fragColor; +layout (location = 1) in vec2 fragUv; layout (location = 0) out vec4 outColor; -layout(set = 0, binding = 0) uniform GlobalUbo { +layout (binding = 0) uniform GlobalUbo { mat4 projectionViewMatrix; vec3 directionToLight; } ubo; +layout (binding = 1) uniform sampler2D texSampler; + layout(push_constant) uniform Push { mat4 transform; mat4 normalMatrix; } push; void main() { - outColor = vec4(fragColor, 1.0); + outColor = mix(texture(texSampler, fragUv), vec4(fragColor, 1.0), .5); } \ No newline at end of file diff --git a/res/shaders/simple_shader.frag.spv b/res/shaders/simple_shader.frag.spv index ff80cc6..a6afbfe 100644 Binary files a/res/shaders/simple_shader.frag.spv and b/res/shaders/simple_shader.frag.spv differ diff --git a/res/shaders/simple_shader.vert b/res/shaders/simple_shader.vert index 55b0199..a61fa0b 100755 --- a/res/shaders/simple_shader.vert +++ b/res/shaders/simple_shader.vert @@ -1,18 +1,19 @@ #version 450 -layout(location = 0) in vec3 position; -layout(location = 1) in vec3 color; -layout(location = 2) in vec3 normal; -layout(location = 3) in vec2 uv; +layout (location = 0) in vec3 position; +layout (location = 1) in vec3 color; +layout (location = 2) in vec3 normal; +layout (location = 3) in vec2 uv; -layout(location = 0) out vec3 fragColor; +layout (location = 0) out vec3 fragColor; +layout (location = 1) out vec2 fragUv; -layout(set = 0, binding = 0) uniform GlobalUbo { +layout (binding = 0) uniform GlobalUbo { mat4 projectionViewMatrix; vec3 directionToLight; } ubo; -layout(push_constant) uniform Push { +layout (push_constant) uniform Push { mat4 modelMatrix; mat4 normalMatrix; } push; @@ -27,4 +28,5 @@ void main() { float lightIntensity = AMBIENT + max(dot(normalWorldSpace, ubo.directionToLight), 0); fragColor = lightIntensity * vec3(1/position.y,position.y,clamp(sin(position.x - position.z), 0, 1)); + fragUv = uv; } \ No newline at end of file diff --git a/res/shaders/simple_shader.vert.spv b/res/shaders/simple_shader.vert.spv index bba7f70..84c0f48 100644 Binary files a/res/shaders/simple_shader.vert.spv and b/res/shaders/simple_shader.vert.spv differ -- cgit v1.2.3-freya