Added CI/CD.
Some checks failed
Build & Release / Linux-AARCH64-Build (push) Failing after 1m29s
Build & Release / Windows-AMD64-Build (push) Failing after 1m40s
Build & Release / Linux-AMD64-Build (push) Successful in 3m5s

This commit is contained in:
2024-07-01 19:55:24 -07:00
parent d6242a7fad
commit b905a949f2
106 changed files with 930 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

View File

@@ -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;
}

View File

@@ -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);
}

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}

Binary file not shown.

Binary file not shown.

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}

View File

@@ -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;
}

Binary file not shown.

Binary file not shown.