diff --git a/resources/audio/One True God - Careless (ft. Vania).wav b/resources/audio/One True God - Careless (ft. Vania).wav new file mode 100644 index 0000000..2030c31 Binary files /dev/null and b/resources/audio/One True God - Careless (ft. Vania).wav differ diff --git a/resources/audio/Paddle.wav b/resources/audio/Paddle.wav new file mode 100644 index 0000000..94e4b0f Binary files /dev/null and b/resources/audio/Paddle.wav differ diff --git a/resources/audio/Score.wav b/resources/audio/Score.wav new file mode 100644 index 0000000..3977ce0 Binary files /dev/null and b/resources/audio/Score.wav differ diff --git a/resources/audio/Wall.wav b/resources/audio/Wall.wav new file mode 100644 index 0000000..5aabe50 Binary files /dev/null and b/resources/audio/Wall.wav differ diff --git a/resources/audio/sample.wav b/resources/audio/sample.wav new file mode 100644 index 0000000..0d2ce74 Binary files /dev/null and b/resources/audio/sample.wav differ diff --git a/resources/fonts/Arial_24.ehf b/resources/fonts/Arial_24.ehf new file mode 100644 index 0000000..60c4255 Binary files /dev/null and b/resources/fonts/Arial_24.ehf differ diff --git a/resources/fonts/Arial_48.ehf b/resources/fonts/Arial_48.ehf new file mode 100644 index 0000000..ca3edb5 Binary files /dev/null and b/resources/fonts/Arial_48.ehf differ diff --git a/resources/fonts/Hack-Bold_12.ehf b/resources/fonts/Hack-Bold_12.ehf new file mode 100644 index 0000000..0d9f757 Binary files /dev/null and b/resources/fonts/Hack-Bold_12.ehf differ diff --git a/resources/fonts/Hack-Bold_48.ehf b/resources/fonts/Hack-Bold_48.ehf new file mode 100644 index 0000000..c294961 Binary files /dev/null and b/resources/fonts/Hack-Bold_48.ehf differ diff --git a/resources/fonts/Hack-Regular_24.ehf b/resources/fonts/Hack-Regular_24.ehf new file mode 100644 index 0000000..bbca9d3 Binary files /dev/null and b/resources/fonts/Hack-Regular_24.ehf differ diff --git a/resources/fonts/Hack-Regular_48.ehf b/resources/fonts/Hack-Regular_48.ehf new file mode 100644 index 0000000..5545b49 Binary files /dev/null and b/resources/fonts/Hack-Regular_48.ehf differ diff --git a/resources/models/Cube.ehm b/resources/models/Cube.ehm new file mode 100644 index 0000000..0447d26 Binary files /dev/null and b/resources/models/Cube.ehm differ diff --git a/resources/models/Cube_P.ehm b/resources/models/Cube_P.ehm new file mode 100644 index 0000000..248d2cd Binary files /dev/null and b/resources/models/Cube_P.ehm differ diff --git a/resources/models/PointLight.ehm b/resources/models/PointLight.ehm new file mode 100644 index 0000000..087b2f1 Binary files /dev/null and b/resources/models/PointLight.ehm differ diff --git a/resources/models/Rifle.ehm b/resources/models/Rifle.ehm new file mode 100644 index 0000000..98e3717 Binary files /dev/null and b/resources/models/Rifle.ehm differ diff --git a/resources/models/Sphere.ehm b/resources/models/Sphere.ehm new file mode 100644 index 0000000..f34d51f Binary files /dev/null and b/resources/models/Sphere.ehm differ diff --git a/resources/models/Test.ehm b/resources/models/Test.ehm new file mode 100644 index 0000000..3494cdd Binary files /dev/null and b/resources/models/Test.ehm differ diff --git a/resources/models/Test2.ehm b/resources/models/Test2.ehm new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/resources/models/Test2.ehm differ diff --git a/resources/models/Vampire.ehm b/resources/models/Vampire.ehm new file mode 100644 index 0000000..f3d5d54 Binary files /dev/null and b/resources/models/Vampire.ehm differ diff --git a/resources/models/untitled.ehm b/resources/models/untitled.ehm new file mode 100644 index 0000000..30f086f Binary files /dev/null and b/resources/models/untitled.ehm differ diff --git a/resources/shaders/Billboard.frag b/resources/shaders/Billboard.frag new file mode 100644 index 0000000..28eeb38 --- /dev/null +++ b/resources/shaders/Billboard.frag @@ -0,0 +1,31 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 fUv; +layout(location = 1) in flat uint fChannels; + +layout(location = 0) out vec4 result; + +layout(binding = 1) uniform Opt +{ + vec4 multiplier; + bool preMultiply; +} opt; + +layout(binding = 2) uniform sampler2D render; + +void main() +{ + result = opt.multiplier; + if (fChannels == 1) + result *= vec4(texture(render, fUv).rrr, 1.0f); + else if (fChannels == 2) + result *= vec4(texture(render, fUv).rrr, texture(render, fUv).g); + else if (fChannels == 3) + result *= vec4(texture(render, fUv).rgb, 1.0f); + else if (fChannels == 4) + result *= texture(render, fUv).rgba; + + if (opt.preMultiply) + result = vec4(result.rgb * result.a, result.a); +} diff --git a/resources/shaders/Billboard.vert b/resources/shaders/Billboard.vert new file mode 100644 index 0000000..503f12f --- /dev/null +++ b/resources/shaders/Billboard.vert @@ -0,0 +1,53 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec2 vUv; + +layout(location = 0) out vec2 fUv; +layout(location = 1) out uint fChannels; + +layout(binding = 0) uniform Transform +{ + mat4 viewProj; + vec3 pos; + uint channels; + vec2 size; +} trans; + +mat4 RemoveRotation(mat4 inMat) +{ + inMat[0][0] = 1.0; + inMat[0][1] = 0.0; + inMat[0][2] = 0.0; + inMat[1][0] = 0.0; + inMat[1][1] = 1.0; + inMat[1][2] = 0.0; + inMat[2][0] = 0.0; + inMat[2][1] = 0.0; + inMat[2][2] = 1.0; + + return inMat; +} + +void main() +{ + // The vec4 we will use to set gl_Position + vec4 pos = vec4(trans.pos, 1.0f); + + // Adjust the position based on the camera view + // Extract the right and up vectors from the view matrix + vec3 right = vec3(trans.viewProj[0][0], trans.viewProj[1][0], trans.viewProj[2][0]); + vec3 up = vec3(trans.viewProj[0][1], trans.viewProj[1][1], trans.viewProj[2][1]); + + // Adjust the quad vertices to face the camera + // The inPosition.xy should be in NDC space, from -1 to 1 + pos.xyz += (right * vPos.x * trans.size.x) + (up * vPos.y * trans.size.y); + + // Output position + gl_Position = trans.viewProj * pos; + + // Pass through the texture coordinates + fUv = vUv; + fChannels = trans.channels; +} diff --git a/resources/shaders/Billboard_Frag.spv b/resources/shaders/Billboard_Frag.spv new file mode 100644 index 0000000..5dcc76a Binary files /dev/null and b/resources/shaders/Billboard_Frag.spv differ diff --git a/resources/shaders/Billboard_Vert.spv b/resources/shaders/Billboard_Vert.spv new file mode 100644 index 0000000..c2d3897 Binary files /dev/null and b/resources/shaders/Billboard_Vert.spv differ diff --git a/resources/shaders/Compile.sh b/resources/shaders/Compile.sh new file mode 100644 index 0000000..69029ee --- /dev/null +++ b/resources/shaders/Compile.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +for file in ./*.vert; do + if [ -f "$file" ]; then + filename=$(basename -- "$file") + + echo "Compiling vertex shader, ${filename}" + + filename="${filename%.*}" + + glslangValidator -V "${file}" -o "./${filename}_Vert.spv" + fi +done + +for file in ./*.frag; do + if [ -f "$file" ]; then + filename=$(basename -- "$file") + + echo "Compiling vertex shader, ${filename}" + + filename="${filename%.*}" + + glslangValidator -V "${file}" -o "./${filename}_Frag.spv" + fi +done diff --git a/resources/shaders/FA_Preview.frag b/resources/shaders/FA_Preview.frag new file mode 100644 index 0000000..12a1bca --- /dev/null +++ b/resources/shaders/FA_Preview.frag @@ -0,0 +1,22 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 fUv; +layout(location = 1) in flat uint fChannels; + +layout(location = 0) out vec4 result; + +layout(binding = 1) uniform Opt +{ + vec4 multiplier; +} opt; + +layout(binding = 2) uniform sampler2D render; + +void main() +{ + if (fChannels != 1) + return; + + result = vec4(texture(render, fUv).rrrr) * opt.multiplier; +} \ No newline at end of file diff --git a/resources/shaders/FA_Preview.vert b/resources/shaders/FA_Preview.vert new file mode 100644 index 0000000..cdcf03e --- /dev/null +++ b/resources/shaders/FA_Preview.vert @@ -0,0 +1,24 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec2 vUv; + +layout(location = 0) out vec2 fUv; +layout(location = 1) out flat uint fChannels; + +layout(binding = 0) uniform Transform +{ + mat4 proj; + mat4 view; + mat4 model; + int channels; +} trans; + +void main() +{ + gl_Position = trans.proj * trans.view * trans.model * vec4(vPos, 1.0); + + fUv = vUv; + fChannels = trans.channels; +} \ No newline at end of file diff --git a/resources/shaders/FA_Preview_Frag.spv b/resources/shaders/FA_Preview_Frag.spv new file mode 100644 index 0000000..0f24581 Binary files /dev/null and b/resources/shaders/FA_Preview_Frag.spv differ diff --git a/resources/shaders/FA_Preview_Vert.spv b/resources/shaders/FA_Preview_Vert.spv new file mode 100644 index 0000000..9ef0482 Binary files /dev/null and b/resources/shaders/FA_Preview_Vert.spv differ diff --git a/resources/shaders/FBO.frag b/resources/shaders/FBO.frag new file mode 100644 index 0000000..1c3867b --- /dev/null +++ b/resources/shaders/FBO.frag @@ -0,0 +1,12 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 vUv; + +layout(location = 0) out vec4 outColor; + +layout(binding = 1) uniform sampler2D render; + +void main() { + outColor = texture(render, vUv); +} \ No newline at end of file diff --git a/resources/shaders/FBO.vert b/resources/shaders/FBO.vert new file mode 100644 index 0000000..afebe65 --- /dev/null +++ b/resources/shaders/FBO.vert @@ -0,0 +1,17 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec2 vUv; + +layout(location = 0) out vec2 fUv; + +layout(binding = 0) uniform UniformBufferObject { + mat4 mvp; +} ubo; + +void main() { + gl_Position = ubo.mvp * vec4(vPos, 1.0); + + fUv = vUv; +} \ No newline at end of file diff --git a/resources/shaders/FBO_Frag.spv b/resources/shaders/FBO_Frag.spv new file mode 100644 index 0000000..e28ec3e Binary files /dev/null and b/resources/shaders/FBO_Frag.spv differ diff --git a/resources/shaders/FBO_Vert.spv b/resources/shaders/FBO_Vert.spv new file mode 100644 index 0000000..6609c5f Binary files /dev/null and b/resources/shaders/FBO_Vert.spv differ diff --git a/resources/shaders/Label.frag b/resources/shaders/Label.frag new file mode 100644 index 0000000..c30eca6 --- /dev/null +++ b/resources/shaders/Label.frag @@ -0,0 +1,21 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 glyphUV; +layout(location = 1) in vec4 glyphColor; + +layout(location = 0) out vec4 result; + +layout(std140, binding = 1) uniform Opt +{ + bool preMultiply; +} opt; + +layout(binding = 2) uniform sampler2D atlas; + +void main() +{ + result = vec4(glyphColor.r, glyphColor.g, glyphColor.b, glyphColor.a * texture(atlas, glyphUV).r); + if (opt.preMultiply) + result = vec4(result.rgb * result.a, result.a); +} \ No newline at end of file diff --git a/resources/shaders/Label.vert b/resources/shaders/Label.vert new file mode 100644 index 0000000..123f703 --- /dev/null +++ b/resources/shaders/Label.vert @@ -0,0 +1,23 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec2 vUv; + +layout(location = 0) out vec2 glyphUV; +layout(location = 1) out vec4 glyphColor; + +layout(std140, binding = 0) uniform Data +{ + mat4 proj; + mat4 view; + mat4 model; + vec4 color; +} data; + +void main() { + gl_Position = data.proj * data.view * data.model * vec4(vPos, 1.0); + + glyphUV = vUv; + glyphColor = data.color; +} \ No newline at end of file diff --git a/resources/shaders/Label_Frag.spv b/resources/shaders/Label_Frag.spv new file mode 100644 index 0000000..48c8bb0 Binary files /dev/null and b/resources/shaders/Label_Frag.spv differ diff --git a/resources/shaders/Label_Vert.spv b/resources/shaders/Label_Vert.spv new file mode 100644 index 0000000..338ea81 Binary files /dev/null and b/resources/shaders/Label_Vert.spv differ diff --git a/resources/shaders/Light.frag b/resources/shaders/Light.frag new file mode 100644 index 0000000..7bd1a36 --- /dev/null +++ b/resources/shaders/Light.frag @@ -0,0 +1,21 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 fUv; + +layout(location = 0) out vec4 outColor; + +layout(binding = 1) uniform Material +{ + vec3 lightColor; +} material; + +layout(binding = 2) uniform sampler2D render; + +void main() { + vec4 result = texture(render, fUv); + if (result.rgb == vec3(1.0f, 1.0f, 1.0f)) + result = vec4(material.lightColor, 1.0f); + + outColor = vec4(result.rgb, 1.0f); +} \ No newline at end of file diff --git a/resources/shaders/Light.vert b/resources/shaders/Light.vert new file mode 100644 index 0000000..4d6a933 --- /dev/null +++ b/resources/shaders/Light.vert @@ -0,0 +1,17 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(binding = 0) uniform Transform { + mat4 mvp; +} transform; + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec2 vUv; + +layout(location = 0) out vec2 fUv; + +void main() { + gl_Position = transform.mvp * vec4(vPos, 1.0); + + fUv = vUv; +} \ No newline at end of file diff --git a/resources/shaders/LightBillboard.frag b/resources/shaders/LightBillboard.frag new file mode 100644 index 0000000..afc9789 --- /dev/null +++ b/resources/shaders/LightBillboard.frag @@ -0,0 +1,26 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 fUv; + +layout(location = 0) out vec4 result; + +layout(binding = 1) uniform Opt +{ + vec3 color; + bool preMultiply; +} opt; + +layout(binding = 2) uniform sampler2D render; + +void main() +{ + result = texture(render, fUv).rgba; + + if (result.rgb == vec3(1.0f, 1.0f, 1.0f)) + result *= vec4(opt.color, 1.0f); + + + if (opt.preMultiply) + result = vec4(result.rgb * result.a, result.a); +} diff --git a/resources/shaders/LightBillboard.vert b/resources/shaders/LightBillboard.vert new file mode 100644 index 0000000..1f49808 --- /dev/null +++ b/resources/shaders/LightBillboard.vert @@ -0,0 +1,50 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec2 vUv; + +layout(location = 0) out vec2 fUv; + +layout(binding = 0) uniform Transform +{ + mat4 viewProj; + vec3 pos; + vec2 size; +} trans; + +mat4 RemoveRotation(mat4 inMat) +{ + inMat[0][0] = 1.0; + inMat[0][1] = 0.0; + inMat[0][2] = 0.0; + inMat[1][0] = 0.0; + inMat[1][1] = 1.0; + inMat[1][2] = 0.0; + inMat[2][0] = 0.0; + inMat[2][1] = 0.0; + inMat[2][2] = 1.0; + + return inMat; +} + +void main() +{ + // The vec4 we will use to set gl_Position + vec4 pos = vec4(trans.pos, 1.0f); + + // Adjust the position based on the camera view + // Extract the right and up vectors from the view matrix + vec3 right = vec3(trans.viewProj[0][0], trans.viewProj[1][0], trans.viewProj[2][0]); + vec3 up = vec3(trans.viewProj[0][1], trans.viewProj[1][1], trans.viewProj[2][1]); + + // Adjust the quad vertices to face the camera + // The inPosition.xy should be in NDC space, from -1 to 1 + pos.xyz += (right * vPos.x * trans.size.x) + (up * vPos.y * trans.size.y); + + // Output position + gl_Position = trans.viewProj * pos; + + // Pass through the texture coordinates + fUv = vUv; +} diff --git a/resources/shaders/LightBillboard_Frag.spv b/resources/shaders/LightBillboard_Frag.spv new file mode 100644 index 0000000..4677c66 Binary files /dev/null and b/resources/shaders/LightBillboard_Frag.spv differ diff --git a/resources/shaders/LightBillboard_Vert.spv b/resources/shaders/LightBillboard_Vert.spv new file mode 100644 index 0000000..52dfe54 Binary files /dev/null and b/resources/shaders/LightBillboard_Vert.spv differ diff --git a/resources/shaders/Light_Frag.spv b/resources/shaders/Light_Frag.spv new file mode 100644 index 0000000..59f1682 Binary files /dev/null and b/resources/shaders/Light_Frag.spv differ diff --git a/resources/shaders/Light_Vert.spv b/resources/shaders/Light_Vert.spv new file mode 100644 index 0000000..13b8e1e Binary files /dev/null and b/resources/shaders/Light_Vert.spv differ diff --git a/resources/shaders/Phong.frag b/resources/shaders/Phong.frag new file mode 100644 index 0000000..cb81844 --- /dev/null +++ b/resources/shaders/Phong.frag @@ -0,0 +1,128 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +#define MAX_LIGHTS 4 + +struct AmbientPointLight +{ + vec3 color; + vec3 pos; +}; + +struct PointLight +{ + vec3 color; + float constant; + vec3 pos; + float linear; + float quadratic; +}; + +struct SpotLight +{ + vec3 color; + float innerCutOff; + vec3 pos; + float outerCutOff; + vec3 dir; + float constant; + float linear; + float quadratic; +}; + +layout(std140, binding = 2) uniform Data +{ + vec3 ambient; + bool preMultiply; + vec4 multiplier; + uint ambientPointLightCount; + uint pointLightCount; + uint spotLightCount; + AmbientPointLight ambientLights[MAX_LIGHTS]; + PointLight pointLights[MAX_LIGHTS]; + SpotLight spotLights[MAX_LIGHTS]; +} data; + +layout(binding = 3) uniform sampler2D colorMap; +layout(binding = 4) uniform sampler2D normalMap; +layout(binding = 5) uniform sampler2D specularMap; + +layout(location = 0) in vec4 fVertPos; +layout(location = 1) in vec3 fTanPos; +layout(location = 2) in vec2 fUV; +layout(location = 3) in vec3 fViewPos; +layout(location = 4) in mat3 fTBN; + +layout(location = 0) out vec4 result; + +vec3 CalcAmbientPointLight(vec3 normal, vec3 vertexPos, vec3 viewDir, AmbientPointLight light) +{ + vec3 lightDir = normalize(light.pos - vertexPos); + + vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f); + + vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), texture(specularMap, fUV).r); + + return diffuse + specular; +} + +vec3 CalcPointLight(vec3 normal, vec3 vertexPos, vec3 viewDir, PointLight light) +{ + vec3 lightDir = normalize(light.pos - vertexPos); + + float dist = length(light.pos - vertexPos); + + float attenuation = 1.0f / (light.constant + light.linear * dist + light.quadratic * (dist * dist)); + + vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f); + + vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), texture(specularMap, fUV).r); + + return (diffuse + specular) * attenuation; +} + +vec3 CalcSpotLight(vec3 normal, vec3 vertexPos, vec3 viewDir, SpotLight light) +{ + vec3 lightDir = normalize(light.pos - vertexPos); + + float dist = length(light.pos - vertexPos); + + float attenuation = 1.0f / (light.constant + light.linear * dist + light.quadratic * (dist * dist)); + + float theta = dot(lightDir, normalize(-light.dir)); + float epsilon = light.innerCutOff - light.outerCutOff; + float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0f, 1.0f); + + vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f); + + vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), texture(specularMap, fUV).r); + + return (diffuse + specular) * intensity * attenuation; +} + +void main() +{ + vec3 viewDir = normalize(fViewPos - fTanPos); + vec3 nNorm = normalize(texture(normalMap, fUV).rgb * 2.0f - 1.0f); + + vec3 final = data.ambient; + + //Ambient Point Lights + for (uint i = 0; i < data.ambientPointLightCount; ++i) + final += CalcAmbientPointLight(nNorm, fVertPos.xyz, viewDir, data.ambientLights[i]); + + //Point Lights + for (uint i = 0; i < data.pointLightCount; ++i) + final += CalcPointLight(nNorm, fVertPos.xyz, viewDir, data.pointLights[i]); + + //Spot Lights + for (uint i = 0; i < data.spotLightCount; ++i) + final += CalcSpotLight(nNorm, fVertPos.xyz, viewDir, data.spotLights[i]); + + vec4 tColor = texture(colorMap, fUV); + + result = vec4(tColor.rgb * final * data.multiplier.rgb, tColor.a * data.multiplier.a); + + if (data.preMultiply) + result = vec4(result.rgb * result.a, result.a); +} diff --git a/resources/shaders/Phong.vert b/resources/shaders/Phong.vert new file mode 100644 index 0000000..b499dc8 --- /dev/null +++ b/resources/shaders/Phong.vert @@ -0,0 +1,62 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +struct Bone +{ + mat4 trans; +}; + +layout(std140, binding = 0) uniform Transform +{ + mat4 viewProj; + mat4 model; + vec3 viewPos; +} transform; + +layout(std140, binding = 1) uniform Skin +{ + Bone skeleton[255]; +} skin; + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec3 vNorm; +layout(location = 2) in vec2 vUV; +layout(location = 3) in vec3 vTan; +layout(location = 4) in vec3 vBiTan; +layout(location = 5) in uvec4 bones; +layout(location = 6) in vec4 weights; + +layout(location = 0) out vec4 fVertPos; +layout(location = 1) out vec3 fTanPos; +layout(location = 2) out vec2 fUV; +layout(location = 3) out vec3 fViewPos; +layout(location = 4) out mat3 fTBN; + +void main() +{ + vec4 totalPos = vec4(0.0f); + + for (uint i = 0; i < 4; ++i) + { + if (weights[i] == 0.0f) + continue; + + totalPos += skin.skeleton[bones[i]].trans * vec4(vPos, 1.0f) * weights[i]; + } + + fVertPos = transform.model * totalPos; + fUV = vUV; + + vec3 T = normalize(vec3(transform.model * vec4(vTan, 0.0f))); + vec3 B = normalize(vec3(transform.model * vec4(vBiTan, 0.0f))); + vec3 N = normalize(vec3(transform.model * vec4(vNorm, 0.0f))); + + T = normalize(T - dot(T, N) * N); + + fTBN = transpose(mat3(T, B, N)); + + fTanPos = fTBN * fVertPos.xyz; + fViewPos = fTBN * transform.viewPos; + + gl_Position = transform.viewProj * transform.model * totalPos; +} diff --git a/resources/shaders/Phong_Frag.spv b/resources/shaders/Phong_Frag.spv new file mode 100644 index 0000000..764aff0 Binary files /dev/null and b/resources/shaders/Phong_Frag.spv differ diff --git a/resources/shaders/Phong_Vert.spv b/resources/shaders/Phong_Vert.spv new file mode 100644 index 0000000..2d0f268 Binary files /dev/null and b/resources/shaders/Phong_Vert.spv differ diff --git a/resources/shaders/Portrait.frag b/resources/shaders/Portrait.frag new file mode 100644 index 0000000..b86c17f --- /dev/null +++ b/resources/shaders/Portrait.frag @@ -0,0 +1,31 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 fUv; +layout(location = 1) in flat uint fChannels; + +layout(location = 0) out vec4 result; + +layout(binding = 1) uniform Opt +{ + bool preMultiply; + vec4 multiplier; +} opt; + +layout(binding = 2) uniform sampler2D render; + +void main() +{ + result = opt.multiplier; + if (fChannels == 1) + result *= vec4(texture(render, fUv).rrr, 1.0f); + else if (fChannels == 2) + result *= vec4(texture(render, fUv).rrr, texture(render, fUv).g); + else if (fChannels == 3) + result *= vec4(texture(render, fUv).rgb, 1.0f); + else if (fChannels == 4) + result *= texture(render, fUv).rgba; + + if (opt.preMultiply) + result = vec4(result.rgb * result.a, result.a); +} \ No newline at end of file diff --git a/resources/shaders/Portrait.vert b/resources/shaders/Portrait.vert new file mode 100644 index 0000000..cdcf03e --- /dev/null +++ b/resources/shaders/Portrait.vert @@ -0,0 +1,24 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec2 vUv; + +layout(location = 0) out vec2 fUv; +layout(location = 1) out flat uint fChannels; + +layout(binding = 0) uniform Transform +{ + mat4 proj; + mat4 view; + mat4 model; + int channels; +} trans; + +void main() +{ + gl_Position = trans.proj * trans.view * trans.model * vec4(vPos, 1.0); + + fUv = vUv; + fChannels = trans.channels; +} \ No newline at end of file diff --git a/resources/shaders/Portrait_Frag.spv b/resources/shaders/Portrait_Frag.spv new file mode 100644 index 0000000..1f04250 Binary files /dev/null and b/resources/shaders/Portrait_Frag.spv differ diff --git a/resources/shaders/Portrait_Vert.spv b/resources/shaders/Portrait_Vert.spv new file mode 100644 index 0000000..9ef0482 Binary files /dev/null and b/resources/shaders/Portrait_Vert.spv differ diff --git a/resources/shaders/RigidBodyDebug.frag b/resources/shaders/RigidBodyDebug.frag new file mode 100644 index 0000000..dc41fdb --- /dev/null +++ b/resources/shaders/RigidBodyDebug.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(std140, binding = 1) uniform Data +{ + vec4 color; +} data; + +layout(location = 0) out vec4 result; + +void main() +{ + result = data.color; +} diff --git a/resources/shaders/RigidBodyDebug.vert b/resources/shaders/RigidBodyDebug.vert new file mode 100644 index 0000000..18ab37e --- /dev/null +++ b/resources/shaders/RigidBodyDebug.vert @@ -0,0 +1,15 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(std140, binding = 0) uniform Transform +{ + mat4 viewProj; + mat4 model; +} transform; + +layout(location = 0) in vec3 vPos; + +void main() +{ + gl_Position = transform.viewProj * transform.model * vec4(vPos, 1.0f); +} diff --git a/resources/shaders/RigidBodyDebug_Frag.spv b/resources/shaders/RigidBodyDebug_Frag.spv new file mode 100644 index 0000000..590db44 Binary files /dev/null and b/resources/shaders/RigidBodyDebug_Frag.spv differ diff --git a/resources/shaders/RigidBodyDebug_Vert.spv b/resources/shaders/RigidBodyDebug_Vert.spv new file mode 100644 index 0000000..c9ab3ca Binary files /dev/null and b/resources/shaders/RigidBodyDebug_Vert.spv differ diff --git a/resources/shaders/Skybox.frag b/resources/shaders/Skybox.frag new file mode 100644 index 0000000..80128e7 --- /dev/null +++ b/resources/shaders/Skybox.frag @@ -0,0 +1,20 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 skyboxUV; + +layout(location = 0) out vec4 result; + +layout(std140, binding = 1) uniform Opt +{ + bool preMultiply; +} opt; + +layout(binding = 2) uniform samplerCube skybox; + +void main() +{ + result = texture(skybox, skyboxUV); + if (opt.preMultiply) + result = vec4(result.rgb * result.a, result.a); +} \ No newline at end of file diff --git a/resources/shaders/Skybox.vert b/resources/shaders/Skybox.vert new file mode 100644 index 0000000..14d1a7e --- /dev/null +++ b/resources/shaders/Skybox.vert @@ -0,0 +1,20 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; + +layout(location = 0) out vec3 skyboxUV; + +layout(std140, binding = 0) uniform Data +{ + mat4 viewProj; +} data; + +void main() +{ + skyboxUV = vPos; + + vec4 pos = data.viewProj * vec4(vPos, 1.0); + + gl_Position = pos.xyww; +} \ No newline at end of file diff --git a/resources/shaders/Skybox_Frag.spv b/resources/shaders/Skybox_Frag.spv new file mode 100644 index 0000000..22f0c69 Binary files /dev/null and b/resources/shaders/Skybox_Frag.spv differ diff --git a/resources/shaders/Skybox_Vert.spv b/resources/shaders/Skybox_Vert.spv new file mode 100644 index 0000000..96c5869 Binary files /dev/null and b/resources/shaders/Skybox_Vert.spv differ diff --git a/resources/shaders/SolidColor.frag b/resources/shaders/SolidColor.frag new file mode 100644 index 0000000..03cc6a3 --- /dev/null +++ b/resources/shaders/SolidColor.frag @@ -0,0 +1,137 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +#define MAX_LIGHTS 4 + +struct Material +{ + vec4 color; + bool diffused; + float specular; + float shininess; +}; + +struct AmbientPointLight +{ + vec3 color; + vec3 pos; +}; + +struct PointLight +{ + vec3 color; + float constant; + vec3 pos; + float linear; + float quadratic; +}; + +struct SpotLight +{ + vec3 color; + float innerCutOff; + vec3 pos; + float outerCutOff; + vec3 dir; + float constant; + float linear; + float quadratic; +}; + +layout(std140, binding = 1) uniform Data +{ + vec3 ambient; + bool preMultiply; + vec3 camPos; + Material material; + uint ambientPointLightCount; + uint pointLightCount; + uint spotLightCount; + AmbientPointLight ambientLights[MAX_LIGHTS]; + PointLight pointLights[MAX_LIGHTS]; + SpotLight spotLights[MAX_LIGHTS]; +} data; + +layout(location = 1) in vec3 fNorm; +layout(location = 0) in vec4 fWorldPos; + +layout(location = 0) out vec4 result; + +vec3 CalcAmbientPointLight(vec3 normal, vec3 vertexPos, vec3 viewDir, Material material, AmbientPointLight light) +{ + vec3 lightDir = normalize(light.pos - vertexPos); + + vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f); + + vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), material.shininess); + + return diffuse + specular; +} + +vec3 CalcPointLight(vec3 normal, vec3 vertexPos, vec3 viewDir, Material material, PointLight light) +{ + vec3 lightDir = normalize(light.pos - vertexPos); + + float dist = length(light.pos - vertexPos); + + float attenuation = 1.0f / (light.constant + light.linear * dist + light.quadratic * (dist * dist)); + + vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f); + + vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), material.shininess); + + return (diffuse + specular) * attenuation; +} + +vec3 CalcSpotLight(vec3 normal, vec3 vertexPos, vec3 viewDir, Material material, SpotLight light) +{ + vec3 lightDir = normalize(light.pos - vertexPos); + + float dist = length(light.pos - vertexPos); + + float attenuation = 1.0f / (light.constant + light.linear * dist + light.quadratic * (dist * dist)); + + float theta = dot(lightDir, normalize(-light.dir)); + float epsilon = light.innerCutOff - light.outerCutOff; + float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0f, 1.0f); + + vec3 diffuse = light.color * max(dot(normal, lightDir), 0.0f); + + vec3 specular = light.color * pow(max(dot(normal, normalize(lightDir + viewDir)), 0.0), material.shininess); + + return (diffuse + specular) * intensity * attenuation; +} + +void main() +{ + if (data.material.diffused == true) + { + vec3 viewDir = normalize(data.camPos - fWorldPos.xyz); + vec3 nNorm = normalize(fNorm); + + vec3 final = data.ambient; + + //Ambient Point Lights + for (uint i = 0; i < data.ambientPointLightCount; ++i) + final += CalcAmbientPointLight(nNorm, fWorldPos.xyz, viewDir, data.material, data.ambientLights[i]); + + //Point Lights + for (uint i = 0; i < data.pointLightCount; ++i) + final += CalcPointLight(nNorm, fWorldPos.xyz, viewDir, data.material, data.pointLights[i]); + + //Spot Lights + for (uint i = 0; i < data.spotLightCount; ++i) + final += CalcSpotLight(nNorm, fWorldPos.xyz, viewDir, data.material, data.spotLights[i]); + + //outColor = vec4(data.spotLights[0].quadratic, 0.0f, 0.0f, 1.0f); + + result = vec4(data.material.color.rgb * final, data.material.color.a); + } + else + { + result = data.material.color; + } + + if (data.preMultiply) + result = vec4(result.rgb * result.a, result.a); +} \ No newline at end of file diff --git a/resources/shaders/SolidColor.vert b/resources/shaders/SolidColor.vert new file mode 100644 index 0000000..51d9431 --- /dev/null +++ b/resources/shaders/SolidColor.vert @@ -0,0 +1,22 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(std140, binding = 0) uniform Transform +{ + mat4 viewProj; + mat4 model; +} transform; + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec3 vNorm; + +layout(location = 1) out vec3 fNorm; +layout(location = 0) out vec4 fWorldPos; + +void main() +{ + fNorm = (transform.model * vec4(vNorm, 0.0f)).xyz; + fWorldPos = transform.model * vec4(vPos, 1.0f); + + gl_Position = transform.viewProj * fWorldPos; +} \ No newline at end of file diff --git a/resources/shaders/SolidColor2D.frag b/resources/shaders/SolidColor2D.frag new file mode 100644 index 0000000..200f70d --- /dev/null +++ b/resources/shaders/SolidColor2D.frag @@ -0,0 +1,20 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) out vec4 outColor; + +layout(binding = 1) uniform Shading +{ + vec4 color; + bool preMultiply; +} shading; + +layout(binding = 1) uniform sampler2D render; + +void main() +{ + outColor = shading.color; + + if (shading.preMultiply) + outColor = vec4(outColor.rgb * outColor.a, outColor.a); +} \ No newline at end of file diff --git a/resources/shaders/SolidColor2D.vert b/resources/shaders/SolidColor2D.vert new file mode 100644 index 0000000..d998360 --- /dev/null +++ b/resources/shaders/SolidColor2D.vert @@ -0,0 +1,15 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; + +layout(binding = 0) uniform UniformBufferObject +{ + mat4 viewProj; + mat4 model; +} ubo; + +void main() +{ + gl_Position = ubo.viewProj * ubo.model * vec4(vPos, 1.0); +} \ No newline at end of file diff --git a/resources/shaders/SolidColor2D_Frag.spv b/resources/shaders/SolidColor2D_Frag.spv new file mode 100644 index 0000000..747c5e0 Binary files /dev/null and b/resources/shaders/SolidColor2D_Frag.spv differ diff --git a/resources/shaders/SolidColor2D_Vert.spv b/resources/shaders/SolidColor2D_Vert.spv new file mode 100644 index 0000000..581bb3c Binary files /dev/null and b/resources/shaders/SolidColor2D_Vert.spv differ diff --git a/resources/shaders/SolidColorAnimated.vert b/resources/shaders/SolidColorAnimated.vert new file mode 100644 index 0000000..6284d31 --- /dev/null +++ b/resources/shaders/SolidColorAnimated.vert @@ -0,0 +1,38 @@ +#version 450 + +#extension GL_EXT_scalar_block_layout : enable + +#define MAX_WEIGHTS 3 +#define MAX_BONES 50 + +layout(binding = 0) uniform Transform +{ + mat4 viewProj; + mat4 model; + mat4 bones[MAX_BONES]; +} transform; + +layout(location = 0) in vec3 vNorm; +layout(location = 1) in vec3 vPos; +layout(location = 2) in uvec3 vBoneIndices; +layout(location = 3) in vec3 vWeights; + +layout(location = 0) out vec3 fNorm; +layout(location = 1) out vec4 fWorldPos; + +void main() +{ + vec4 totalLocalPos = vec4(0.0f); + vec4 totalNormal = vec4(0.0f); + + for (int i = 0; i < MAX_WEIGHTS; ++i) + { + totalLocalPos += transform.bones[vBoneIndices[i]] * vec4(vPos, 1.0f) * vWeights[i]; + totalNormal += transform.bones[vBoneIndices[i]] * vec4(vNorm, 0.0f) * vWeights[i]; + } + + fNorm = (transform.model * totalNormal).xyz; + fWorldPos = transform.model * totalLocalPos; + + gl_Position = transform.viewProj * fWorldPos; +} \ No newline at end of file diff --git a/resources/shaders/SolidColorAnimated_Vert.spv b/resources/shaders/SolidColorAnimated_Vert.spv new file mode 100644 index 0000000..9c60160 Binary files /dev/null and b/resources/shaders/SolidColorAnimated_Vert.spv differ diff --git a/resources/shaders/SolidColor_Frag.spv b/resources/shaders/SolidColor_Frag.spv new file mode 100644 index 0000000..e3db650 Binary files /dev/null and b/resources/shaders/SolidColor_Frag.spv differ diff --git a/resources/shaders/SolidColor_Vert.spv b/resources/shaders/SolidColor_Vert.spv new file mode 100644 index 0000000..c148fe4 Binary files /dev/null and b/resources/shaders/SolidColor_Vert.spv differ diff --git a/resources/shaders/Viewport.frag b/resources/shaders/Viewport.frag new file mode 100644 index 0000000..b0f7875 --- /dev/null +++ b/resources/shaders/Viewport.frag @@ -0,0 +1,21 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec2 vUv; + +layout(location = 0) out vec4 result; + +layout(binding = 1) uniform Opt +{ + bool preMultiply; + vec4 multiplier; +} opt; + +layout(binding = 2) uniform sampler2D render; + +void main() +{ + result = opt.multiplier * texture(render, vUv); + if (opt.preMultiply) + result = vec4(result.rgb * result.a, result.a); +} \ No newline at end of file diff --git a/resources/shaders/Viewport.vert b/resources/shaders/Viewport.vert new file mode 100644 index 0000000..bb4ee02 --- /dev/null +++ b/resources/shaders/Viewport.vert @@ -0,0 +1,21 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 vPos; +layout(location = 1) in vec2 vUv; + +layout(location = 0) out vec2 fUv; + +layout(binding = 0) uniform Transform +{ + mat4 proj; + mat4 view; + mat4 model; +} trans; + +void main() +{ + gl_Position = trans.proj * trans.view * trans.model * vec4(vPos, 1.0); + + fUv = vUv; +} \ No newline at end of file diff --git a/resources/shaders/Viewport_Frag.spv b/resources/shaders/Viewport_Frag.spv new file mode 100644 index 0000000..bf4757f Binary files /dev/null and b/resources/shaders/Viewport_Frag.spv differ diff --git a/resources/shaders/Viewport_Vert.spv b/resources/shaders/Viewport_Vert.spv new file mode 100644 index 0000000..8fd5673 Binary files /dev/null and b/resources/shaders/Viewport_Vert.spv differ diff --git a/resources/textures/AmbientPointLight.png b/resources/textures/AmbientPointLight.png new file mode 100644 index 0000000..1eb80ee Binary files /dev/null and b/resources/textures/AmbientPointLight.png differ diff --git a/resources/textures/Character_Diffuse.png b/resources/textures/Character_Diffuse.png new file mode 100644 index 0000000..ef6fa78 Binary files /dev/null and b/resources/textures/Character_Diffuse.png differ diff --git a/resources/textures/Character_Normal.png b/resources/textures/Character_Normal.png new file mode 100644 index 0000000..e3d1993 Binary files /dev/null and b/resources/textures/Character_Normal.png differ diff --git a/resources/textures/Character_Specular.png b/resources/textures/Character_Specular.png new file mode 100644 index 0000000..b28d73b Binary files /dev/null and b/resources/textures/Character_Specular.png differ diff --git a/resources/textures/Circle.qoi b/resources/textures/Circle.qoi new file mode 100644 index 0000000..2af4aa8 Binary files /dev/null and b/resources/textures/Circle.qoi differ diff --git a/resources/textures/Cube_Diffuse.png b/resources/textures/Cube_Diffuse.png new file mode 100644 index 0000000..8c9b0d0 Binary files /dev/null and b/resources/textures/Cube_Diffuse.png differ diff --git a/resources/textures/Cube_Normal.png b/resources/textures/Cube_Normal.png new file mode 100644 index 0000000..320ca5b Binary files /dev/null and b/resources/textures/Cube_Normal.png differ diff --git a/resources/textures/Cube_Specular.png b/resources/textures/Cube_Specular.png new file mode 100644 index 0000000..d932959 Binary files /dev/null and b/resources/textures/Cube_Specular.png differ diff --git a/resources/textures/DownArrow.png b/resources/textures/DownArrow.png new file mode 100644 index 0000000..a2b376b Binary files /dev/null and b/resources/textures/DownArrow.png differ diff --git a/resources/textures/LeftArrow.png b/resources/textures/LeftArrow.png new file mode 100644 index 0000000..5cae4c8 Binary files /dev/null and b/resources/textures/LeftArrow.png differ diff --git a/resources/textures/LightBulb.png b/resources/textures/LightBulb.png new file mode 100644 index 0000000..d73802d Binary files /dev/null and b/resources/textures/LightBulb.png differ diff --git a/resources/textures/LightBulb_Lit.png b/resources/textures/LightBulb_Lit.png new file mode 100644 index 0000000..6b63bfa Binary files /dev/null and b/resources/textures/LightBulb_Lit.png differ diff --git a/resources/textures/PointLight.png b/resources/textures/PointLight.png new file mode 100644 index 0000000..4423402 Binary files /dev/null and b/resources/textures/PointLight.png differ diff --git a/resources/textures/RightArrow.png b/resources/textures/RightArrow.png new file mode 100644 index 0000000..ca924de Binary files /dev/null and b/resources/textures/RightArrow.png differ diff --git a/resources/textures/SpotLight.png b/resources/textures/SpotLight.png new file mode 100644 index 0000000..f1ef1ba Binary files /dev/null and b/resources/textures/SpotLight.png differ diff --git a/resources/textures/Untitled.png b/resources/textures/Untitled.png new file mode 100644 index 0000000..117da81 Binary files /dev/null and b/resources/textures/Untitled.png differ diff --git a/resources/textures/UpArrow.png b/resources/textures/UpArrow.png new file mode 100644 index 0000000..76d920a Binary files /dev/null and b/resources/textures/UpArrow.png differ diff --git a/resources/textures/Vampire_Diffuse.png b/resources/textures/Vampire_Diffuse.png new file mode 100644 index 0000000..b5ca6f3 Binary files /dev/null and b/resources/textures/Vampire_Diffuse.png differ diff --git a/resources/textures/Vampire_Emission.png b/resources/textures/Vampire_Emission.png new file mode 100644 index 0000000..31bbc54 Binary files /dev/null and b/resources/textures/Vampire_Emission.png differ diff --git a/resources/textures/Vampire_Normal.png b/resources/textures/Vampire_Normal.png new file mode 100644 index 0000000..35dd260 Binary files /dev/null and b/resources/textures/Vampire_Normal.png differ diff --git a/resources/textures/Vampire_Specular.png b/resources/textures/Vampire_Specular.png new file mode 100644 index 0000000..0dde44e Binary files /dev/null and b/resources/textures/Vampire_Specular.png differ diff --git a/resources/textures/brickwall.png b/resources/textures/brickwall.png new file mode 100644 index 0000000..5a67cb1 Binary files /dev/null and b/resources/textures/brickwall.png differ diff --git a/resources/textures/brickwall_normal.png b/resources/textures/brickwall_normal.png new file mode 100644 index 0000000..7cd7763 Binary files /dev/null and b/resources/textures/brickwall_normal.png differ diff --git a/resources/textures/brickwall_specular.png b/resources/textures/brickwall_specular.png new file mode 100644 index 0000000..d46a384 Binary files /dev/null and b/resources/textures/brickwall_specular.png differ diff --git a/resources/textures/skybox/Back.qoi b/resources/textures/skybox/Back.qoi new file mode 100644 index 0000000..f4a0b9b Binary files /dev/null and b/resources/textures/skybox/Back.qoi differ diff --git a/resources/textures/skybox/Bottom.qoi b/resources/textures/skybox/Bottom.qoi new file mode 100644 index 0000000..403dc39 Binary files /dev/null and b/resources/textures/skybox/Bottom.qoi differ diff --git a/resources/textures/skybox/Front.qoi b/resources/textures/skybox/Front.qoi new file mode 100644 index 0000000..1265a83 Binary files /dev/null and b/resources/textures/skybox/Front.qoi differ diff --git a/resources/textures/skybox/Left.qoi b/resources/textures/skybox/Left.qoi new file mode 100644 index 0000000..7350080 Binary files /dev/null and b/resources/textures/skybox/Left.qoi differ diff --git a/resources/textures/skybox/Right.qoi b/resources/textures/skybox/Right.qoi new file mode 100644 index 0000000..fd81013 Binary files /dev/null and b/resources/textures/skybox/Right.qoi differ diff --git a/resources/textures/skybox/Top.qoi b/resources/textures/skybox/Top.qoi new file mode 100644 index 0000000..14d47f0 Binary files /dev/null and b/resources/textures/skybox/Top.qoi differ diff --git a/resources/textures/unknown.png b/resources/textures/unknown.png new file mode 100644 index 0000000..1d9d570 Binary files /dev/null and b/resources/textures/unknown.png differ