mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Vulcan Nightmare
Experimentally bringing up vulcan support
This commit is contained in:
parent
863a786c48
commit
83b576e8d9
189 changed files with 12147 additions and 7820 deletions
49
assets/shaders/basic.frag.glsl
Normal file
49
assets/shaders/basic.frag.glsl
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D uTexture;
|
||||
|
||||
layout(set = 1, binding = 1) uniform BasicMaterial {
|
||||
vec4 color;
|
||||
vec3 lightPos;
|
||||
int useTexture;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 FragPos;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec2 TexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec3 ambient = 0.3 * vec3(1.0);
|
||||
vec3 norm = normalize(Normal);
|
||||
vec3 lightDir2 = normalize(lightPos - FragPos);
|
||||
float diff = max(dot(norm, lightDir2), 0.0);
|
||||
vec3 diffuse = diff * vec3(1.0);
|
||||
|
||||
vec3 viewDir2 = normalize(viewPos.xyz - FragPos);
|
||||
vec3 reflectDir = reflect(-lightDir2, norm);
|
||||
float spec = pow(max(dot(viewDir2, reflectDir), 0.0), 32.0);
|
||||
vec3 specular = 0.5 * spec * vec3(1.0);
|
||||
|
||||
vec3 result = ambient + diffuse + specular;
|
||||
|
||||
if (useTexture != 0) {
|
||||
outColor = texture(uTexture, TexCoord) * vec4(result, 1.0);
|
||||
} else {
|
||||
outColor = color * vec4(result, 1.0);
|
||||
}
|
||||
}
|
||||
BIN
assets/shaders/basic.frag.spv
Normal file
BIN
assets/shaders/basic.frag.spv
Normal file
Binary file not shown.
34
assets/shaders/basic.vert.glsl
Normal file
34
assets/shaders/basic.vert.glsl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 model;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
layout(location = 2) in vec2 aTexCoord;
|
||||
|
||||
layout(location = 0) out vec3 FragPos;
|
||||
layout(location = 1) out vec3 Normal;
|
||||
layout(location = 2) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
vec4 worldPos = push.model * vec4(aPosition, 1.0);
|
||||
FragPos = worldPos.xyz;
|
||||
Normal = mat3(push.model) * aNormal;
|
||||
TexCoord = aTexCoord;
|
||||
gl_Position = projection * view * worldPos;
|
||||
}
|
||||
BIN
assets/shaders/basic.vert.spv
Normal file
BIN
assets/shaders/basic.vert.spv
Normal file
Binary file not shown.
49
assets/shaders/celestial.frag.glsl
Normal file
49
assets/shaders/celestial.frag.glsl
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 model;
|
||||
vec4 celestialColor; // xyz = color, w = unused
|
||||
float intensity;
|
||||
float moonPhase;
|
||||
float animTime;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec2 TexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
float valueNoise(vec2 p) {
|
||||
vec2 i = floor(p);
|
||||
vec2 f = fract(p);
|
||||
f = f * f * (3.0 - 2.0 * f);
|
||||
float a = fract(sin(dot(i, vec2(127.1, 311.7))) * 43758.5453);
|
||||
float b = fract(sin(dot(i + vec2(1.0, 0.0), vec2(127.1, 311.7))) * 43758.5453);
|
||||
float c = fract(sin(dot(i + vec2(0.0, 1.0), vec2(127.1, 311.7))) * 43758.5453);
|
||||
float d = fract(sin(dot(i + vec2(1.0, 1.0), vec2(127.1, 311.7))) * 43758.5453);
|
||||
return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = TexCoord - 0.5;
|
||||
float dist = length(uv);
|
||||
float disc = smoothstep(0.42, 0.38, dist);
|
||||
float glow = exp(-dist * dist * 12.0) * 0.6;
|
||||
float alpha = max(disc, glow) * push.intensity;
|
||||
vec3 color = push.celestialColor.rgb;
|
||||
|
||||
// Animated haze/turbulence overlay for the sun disc
|
||||
if (push.intensity > 0.5) {
|
||||
float noise = valueNoise(uv * 8.0 + vec2(push.animTime * 0.3, push.animTime * 0.2));
|
||||
float noise2 = valueNoise(uv * 16.0 - vec2(push.animTime * 0.5, push.animTime * 0.15));
|
||||
float turbulence = (noise * 0.6 + noise2 * 0.4) * disc;
|
||||
color += vec3(turbulence * 0.3, turbulence * 0.15, 0.0);
|
||||
}
|
||||
|
||||
// Moon phase shadow (only applied when intensity < 0.5, i.e. for moons)
|
||||
float phaseX = uv.x * 2.0 + push.moonPhase;
|
||||
float phaseShadow = smoothstep(-0.1, 0.1, phaseX);
|
||||
alpha *= mix(phaseShadow, 1.0, step(0.5, push.intensity));
|
||||
|
||||
if (alpha < 0.001) discard;
|
||||
outColor = vec4(color, alpha);
|
||||
}
|
||||
BIN
assets/shaders/celestial.frag.spv
Normal file
BIN
assets/shaders/celestial.frag.spv
Normal file
Binary file not shown.
34
assets/shaders/celestial.vert.glsl
Normal file
34
assets/shaders/celestial.vert.glsl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 model;
|
||||
vec4 celestialColor; // xyz = color, w = unused
|
||||
float intensity;
|
||||
float moonPhase;
|
||||
float animTime;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec2 aTexCoord;
|
||||
|
||||
layout(location = 0) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
TexCoord = aTexCoord;
|
||||
// Sky object: remove camera translation so celestial bodies are at infinite distance
|
||||
mat4 rotView = mat4(mat3(view));
|
||||
gl_Position = projection * rotView * push.model * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/celestial.vert.spv
Normal file
BIN
assets/shaders/celestial.vert.spv
Normal file
Binary file not shown.
83
assets/shaders/character.frag.glsl
Normal file
83
assets/shaders/character.frag.glsl
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D uTexture;
|
||||
|
||||
layout(set = 1, binding = 1) uniform CharMaterial {
|
||||
float opacity;
|
||||
int alphaTest;
|
||||
int colorKeyBlack;
|
||||
int unlit;
|
||||
float emissiveBoost;
|
||||
vec3 emissiveTint;
|
||||
float specularIntensity;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1) uniform sampler2DShadow uShadowMap;
|
||||
|
||||
layout(location = 0) in vec3 FragPos;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec2 TexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec4 texColor = texture(uTexture, TexCoord);
|
||||
|
||||
if (alphaTest != 0 && texColor.a < 0.5) discard;
|
||||
if (colorKeyBlack != 0) {
|
||||
float lum = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));
|
||||
float ck = smoothstep(0.12, 0.30, lum);
|
||||
texColor.a *= ck;
|
||||
if (texColor.a < 0.01) discard;
|
||||
}
|
||||
|
||||
vec3 norm = normalize(Normal);
|
||||
if (!gl_FrontFacing) norm = -norm;
|
||||
|
||||
vec3 result;
|
||||
|
||||
if (unlit != 0) {
|
||||
vec3 warm = emissiveTint * emissiveBoost;
|
||||
result = texColor.rgb * (1.0 + warm);
|
||||
} else {
|
||||
vec3 ldir = normalize(-lightDir.xyz);
|
||||
float diff = max(dot(norm, ldir), 0.0);
|
||||
|
||||
vec3 viewDir = normalize(viewPos.xyz - FragPos);
|
||||
vec3 halfDir = normalize(ldir + viewDir);
|
||||
float spec = pow(max(dot(norm, halfDir), 0.0), 32.0) * specularIntensity;
|
||||
|
||||
float shadow = 1.0;
|
||||
if (shadowParams.x > 0.5) {
|
||||
vec4 lsPos = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
vec3 proj = lsPos.xyz / lsPos.w * 0.5 + 0.5;
|
||||
if (proj.z <= 1.0) {
|
||||
float bias = max(0.005 * (1.0 - dot(norm, ldir)), 0.001);
|
||||
shadow = texture(uShadowMap, vec3(proj.xy, proj.z - bias));
|
||||
}
|
||||
shadow = mix(1.0, shadow, shadowParams.y);
|
||||
}
|
||||
|
||||
result = ambientColor.rgb * texColor.rgb
|
||||
+ shadow * (diff * lightColor.rgb * texColor.rgb + spec * lightColor.rgb);
|
||||
}
|
||||
|
||||
float dist = length(viewPos.xyz - FragPos);
|
||||
float fogFactor = clamp((fogParams.y - dist) / (fogParams.y - fogParams.x), 0.0, 1.0);
|
||||
result = mix(fogColor.rgb, result, fogFactor);
|
||||
|
||||
outColor = vec4(result, texColor.a * opacity);
|
||||
}
|
||||
BIN
assets/shaders/character.frag.spv
Normal file
BIN
assets/shaders/character.frag.spv
Normal file
Binary file not shown.
49
assets/shaders/character.vert.glsl
Normal file
49
assets/shaders/character.vert.glsl
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 model;
|
||||
} push;
|
||||
|
||||
layout(set = 2, binding = 0) readonly buffer BoneSSBO {
|
||||
mat4 bones[];
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec4 aBoneWeights;
|
||||
layout(location = 2) in ivec4 aBoneIndices;
|
||||
layout(location = 3) in vec3 aNormal;
|
||||
layout(location = 4) in vec2 aTexCoord;
|
||||
|
||||
layout(location = 0) out vec3 FragPos;
|
||||
layout(location = 1) out vec3 Normal;
|
||||
layout(location = 2) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
mat4 skinMat = bones[aBoneIndices.x] * aBoneWeights.x
|
||||
+ bones[aBoneIndices.y] * aBoneWeights.y
|
||||
+ bones[aBoneIndices.z] * aBoneWeights.z
|
||||
+ bones[aBoneIndices.w] * aBoneWeights.w;
|
||||
|
||||
vec4 skinnedPos = skinMat * vec4(aPos, 1.0);
|
||||
vec3 skinnedNorm = mat3(skinMat) * aNormal;
|
||||
|
||||
vec4 worldPos = push.model * skinnedPos;
|
||||
FragPos = worldPos.xyz;
|
||||
Normal = mat3(push.model) * skinnedNorm;
|
||||
TexCoord = aTexCoord;
|
||||
|
||||
gl_Position = projection * view * worldPos;
|
||||
}
|
||||
BIN
assets/shaders/character.vert.spv
Normal file
BIN
assets/shaders/character.vert.spv
Normal file
Binary file not shown.
19
assets/shaders/character_shadow.frag.glsl
Normal file
19
assets/shaders/character_shadow.frag.glsl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D uTexture;
|
||||
|
||||
layout(set = 1, binding = 1) uniform ShadowParams {
|
||||
int alphaTest;
|
||||
int colorKeyBlack;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
vec4 texColor = texture(uTexture, TexCoord);
|
||||
if (alphaTest != 0 && texColor.a < 0.5) discard;
|
||||
if (colorKeyBlack != 0) {
|
||||
float lum = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));
|
||||
if (lum < 0.12) discard;
|
||||
}
|
||||
}
|
||||
BIN
assets/shaders/character_shadow.frag.spv
Normal file
BIN
assets/shaders/character_shadow.frag.spv
Normal file
Binary file not shown.
27
assets/shaders/character_shadow.vert.glsl
Normal file
27
assets/shaders/character_shadow.vert.glsl
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 lightSpaceMatrix;
|
||||
mat4 model;
|
||||
} push;
|
||||
|
||||
layout(set = 2, binding = 0) readonly buffer BoneSSBO {
|
||||
mat4 bones[];
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec4 aBoneWeights;
|
||||
layout(location = 2) in ivec4 aBoneIndices;
|
||||
layout(location = 3) in vec2 aTexCoord;
|
||||
|
||||
layout(location = 0) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
mat4 skinMat = bones[aBoneIndices.x] * aBoneWeights.x
|
||||
+ bones[aBoneIndices.y] * aBoneWeights.y
|
||||
+ bones[aBoneIndices.z] * aBoneWeights.z
|
||||
+ bones[aBoneIndices.w] * aBoneWeights.w;
|
||||
vec4 skinnedPos = skinMat * vec4(aPos, 1.0);
|
||||
TexCoord = aTexCoord;
|
||||
gl_Position = push.lightSpaceMatrix * push.model * skinnedPos;
|
||||
}
|
||||
BIN
assets/shaders/character_shadow.vert.spv
Normal file
BIN
assets/shaders/character_shadow.vert.spv
Normal file
Binary file not shown.
13
assets/shaders/charge_dust.frag.glsl
Normal file
13
assets/shaders/charge_dust.frag.glsl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vAlpha;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 p = gl_PointCoord - vec2(0.5);
|
||||
float dist = length(p);
|
||||
if (dist > 0.5) discard;
|
||||
float alpha = smoothstep(0.5, 0.1, dist) * vAlpha * 0.45;
|
||||
outColor = vec4(0.65, 0.55, 0.40, alpha);
|
||||
}
|
||||
BIN
assets/shaders/charge_dust.frag.spv
Normal file
BIN
assets/shaders/charge_dust.frag.spv
Normal file
Binary file not shown.
26
assets/shaders/charge_dust.vert.glsl
Normal file
26
assets/shaders/charge_dust.vert.glsl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in float aSize;
|
||||
layout(location = 2) in float aAlpha;
|
||||
|
||||
layout(location = 0) out float vAlpha;
|
||||
|
||||
void main() {
|
||||
gl_PointSize = aSize;
|
||||
vAlpha = aAlpha;
|
||||
gl_Position = projection * view * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/charge_dust.vert.spv
Normal file
BIN
assets/shaders/charge_dust.vert.spv
Normal file
Binary file not shown.
16
assets/shaders/charge_ribbon.frag.glsl
Normal file
16
assets/shaders/charge_ribbon.frag.glsl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vAlpha;
|
||||
layout(location = 1) in float vHeat;
|
||||
layout(location = 2) in float vHeight;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec3 top = vec3(1.0, 0.2, 0.0);
|
||||
vec3 mid = vec3(1.0, 0.5, 0.0);
|
||||
vec3 color = mix(mid, top, vHeight);
|
||||
color = mix(color, vec3(1.0, 0.8, 0.3), vHeat * 0.5);
|
||||
float alpha = vAlpha * smoothstep(0.0, 0.3, vHeight);
|
||||
outColor = vec4(color, alpha);
|
||||
}
|
||||
BIN
assets/shaders/charge_ribbon.frag.spv
Normal file
BIN
assets/shaders/charge_ribbon.frag.spv
Normal file
Binary file not shown.
30
assets/shaders/charge_ribbon.vert.glsl
Normal file
30
assets/shaders/charge_ribbon.vert.glsl
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in float aAlpha;
|
||||
layout(location = 2) in float aHeat;
|
||||
layout(location = 3) in float aHeight;
|
||||
|
||||
layout(location = 0) out float vAlpha;
|
||||
layout(location = 1) out float vHeat;
|
||||
layout(location = 2) out float vHeight;
|
||||
|
||||
void main() {
|
||||
vAlpha = aAlpha;
|
||||
vHeat = aHeat;
|
||||
vHeight = aHeight;
|
||||
gl_Position = projection * view * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/charge_ribbon.vert.spv
Normal file
BIN
assets/shaders/charge_ribbon.vert.spv
Normal file
Binary file not shown.
63
assets/shaders/clouds.frag.glsl
Normal file
63
assets/shaders/clouds.frag.glsl
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
vec4 cloudColor;
|
||||
float density;
|
||||
float windOffset;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 vWorldDir;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
float hash(vec2 p) {
|
||||
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
|
||||
}
|
||||
|
||||
float noise(vec2 p) {
|
||||
vec2 i = floor(p);
|
||||
vec2 f = fract(p);
|
||||
f = f * f * (3.0 - 2.0 * f);
|
||||
float a = hash(i);
|
||||
float b = hash(i + vec2(1.0, 0.0));
|
||||
float c = hash(i + vec2(0.0, 1.0));
|
||||
float d = hash(i + vec2(1.0, 1.0));
|
||||
return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
|
||||
}
|
||||
|
||||
float fbm(vec2 p) {
|
||||
float val = 0.0;
|
||||
float amp = 0.5;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
val += amp * noise(p);
|
||||
p *= 2.0;
|
||||
amp *= 0.5;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 dir = normalize(vWorldDir);
|
||||
float altitude = dir.y;
|
||||
if (altitude < 0.0) discard;
|
||||
|
||||
vec2 uv = dir.xz / (altitude + 0.001);
|
||||
uv += push.windOffset;
|
||||
|
||||
float cloud1 = fbm(uv * 0.8);
|
||||
float cloud2 = fbm(uv * 1.6 + 5.0);
|
||||
float cloud = cloud1 * 0.7 + cloud2 * 0.3;
|
||||
cloud = smoothstep(0.35, 0.65, cloud) * push.density;
|
||||
|
||||
float edgeBreak = noise(uv * 4.0);
|
||||
cloud *= smoothstep(0.2, 0.5, edgeBreak);
|
||||
|
||||
float horizonFade = smoothstep(0.0, 0.15, altitude);
|
||||
cloud *= horizonFade;
|
||||
|
||||
float edgeSoftness = smoothstep(0.0, 0.3, cloud);
|
||||
float alpha = cloud * edgeSoftness;
|
||||
|
||||
if (alpha < 0.01) discard;
|
||||
outColor = vec4(push.cloudColor.rgb, alpha);
|
||||
}
|
||||
BIN
assets/shaders/clouds.frag.spv
Normal file
BIN
assets/shaders/clouds.frag.spv
Normal file
Binary file not shown.
25
assets/shaders/clouds.vert.glsl
Normal file
25
assets/shaders/clouds.vert.glsl
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
|
||||
layout(location = 0) out vec3 vWorldDir;
|
||||
|
||||
void main() {
|
||||
vWorldDir = aPos;
|
||||
mat4 rotView = mat4(mat3(view));
|
||||
vec4 pos = projection * rotView * vec4(aPos, 1.0);
|
||||
gl_Position = pos.xyww;
|
||||
}
|
||||
BIN
assets/shaders/clouds.vert.spv
Normal file
BIN
assets/shaders/clouds.vert.spv
Normal file
Binary file not shown.
22
assets/shaders/lens_flare.frag.glsl
Normal file
22
assets/shaders/lens_flare.frag.glsl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
vec2 position;
|
||||
float size;
|
||||
float aspectRatio;
|
||||
vec4 color; // rgb + brightness in w
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec2 UV;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 center = UV - 0.5;
|
||||
float dist = length(center);
|
||||
float alpha = smoothstep(0.5, 0.0, dist);
|
||||
float glow = exp(-dist * dist * 8.0) * 0.5;
|
||||
alpha = max(alpha, glow) * push.color.w;
|
||||
if (alpha < 0.01) discard;
|
||||
outColor = vec4(push.color.rgb, alpha);
|
||||
}
|
||||
BIN
assets/shaders/lens_flare.frag.spv
Normal file
BIN
assets/shaders/lens_flare.frag.spv
Normal file
Binary file not shown.
19
assets/shaders/lens_flare.vert.glsl
Normal file
19
assets/shaders/lens_flare.vert.glsl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
vec2 position;
|
||||
float size;
|
||||
float aspectRatio;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec2 aPos;
|
||||
layout(location = 1) in vec2 aUV;
|
||||
|
||||
layout(location = 0) out vec2 UV;
|
||||
|
||||
void main() {
|
||||
UV = aUV;
|
||||
vec2 scaled = aPos * push.size;
|
||||
scaled.x /= push.aspectRatio;
|
||||
gl_Position = vec4(scaled + push.position, 0.0, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/lens_flare.vert.spv
Normal file
BIN
assets/shaders/lens_flare.vert.spv
Normal file
Binary file not shown.
10
assets/shaders/lightning_bolt.frag.glsl
Normal file
10
assets/shaders/lightning_bolt.frag.glsl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vBrightness;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec3 color = mix(vec3(0.6, 0.8, 1.0), vec3(1.0), vBrightness * 0.5);
|
||||
outColor = vec4(color, vBrightness);
|
||||
}
|
||||
BIN
assets/shaders/lightning_bolt.frag.spv
Normal file
BIN
assets/shaders/lightning_bolt.frag.spv
Normal file
Binary file not shown.
27
assets/shaders/lightning_bolt.vert.glsl
Normal file
27
assets/shaders/lightning_bolt.vert.glsl
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
float brightness;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
|
||||
layout(location = 0) out float vBrightness;
|
||||
|
||||
void main() {
|
||||
vBrightness = push.brightness;
|
||||
gl_Position = projection * view * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/lightning_bolt.vert.spv
Normal file
BIN
assets/shaders/lightning_bolt.vert.spv
Normal file
Binary file not shown.
11
assets/shaders/lightning_flash.frag.glsl
Normal file
11
assets/shaders/lightning_flash.frag.glsl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
float intensity;
|
||||
} push;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = vec4(1.0, 1.0, 1.0, push.intensity * 0.6);
|
||||
}
|
||||
BIN
assets/shaders/lightning_flash.frag.spv
Normal file
BIN
assets/shaders/lightning_flash.frag.spv
Normal file
Binary file not shown.
7
assets/shaders/lightning_flash.vert.glsl
Normal file
7
assets/shaders/lightning_flash.vert.glsl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in vec2 aPos;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(aPos, 0.0, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/lightning_flash.vert.spv
Normal file
BIN
assets/shaders/lightning_flash.vert.spv
Normal file
Binary file not shown.
86
assets/shaders/m2.frag.glsl
Normal file
86
assets/shaders/m2.frag.glsl
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D uTexture;
|
||||
|
||||
layout(set = 1, binding = 2) uniform M2Material {
|
||||
int hasTexture;
|
||||
int alphaTest;
|
||||
int colorKeyBlack;
|
||||
float colorKeyThreshold;
|
||||
int unlit;
|
||||
int blendMode;
|
||||
float fadeAlpha;
|
||||
float interiorDarken;
|
||||
float specularIntensity;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1) uniform sampler2DShadow uShadowMap;
|
||||
|
||||
layout(location = 0) in vec3 FragPos;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec2 TexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec4 texColor = hasTexture != 0 ? texture(uTexture, TexCoord) : vec4(1.0);
|
||||
|
||||
if (alphaTest != 0 && texColor.a < 0.5) discard;
|
||||
if (colorKeyBlack != 0) {
|
||||
float lum = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));
|
||||
if (lum < colorKeyThreshold) discard;
|
||||
}
|
||||
if (blendMode == 1 && texColor.a < 0.004) discard;
|
||||
|
||||
vec3 norm = normalize(Normal);
|
||||
if (!gl_FrontFacing) norm = -norm;
|
||||
|
||||
vec3 ldir = normalize(-lightDir.xyz);
|
||||
float diff = max(dot(norm, ldir), 0.0);
|
||||
|
||||
vec3 result;
|
||||
if (unlit != 0) {
|
||||
result = texColor.rgb;
|
||||
} else {
|
||||
vec3 viewDir = normalize(viewPos.xyz - FragPos);
|
||||
vec3 halfDir = normalize(ldir + viewDir);
|
||||
float spec = pow(max(dot(norm, halfDir), 0.0), 32.0) * specularIntensity;
|
||||
|
||||
float shadow = 1.0;
|
||||
if (shadowParams.x > 0.5) {
|
||||
vec4 lsPos = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
vec3 proj = lsPos.xyz / lsPos.w * 0.5 + 0.5;
|
||||
if (proj.z <= 1.0) {
|
||||
float bias = max(0.005 * (1.0 - dot(norm, ldir)), 0.001);
|
||||
shadow = texture(uShadowMap, vec3(proj.xy, proj.z - bias));
|
||||
}
|
||||
shadow = mix(1.0, shadow, shadowParams.y);
|
||||
}
|
||||
|
||||
result = ambientColor.rgb * texColor.rgb
|
||||
+ shadow * (diff * lightColor.rgb * texColor.rgb + spec * lightColor.rgb);
|
||||
|
||||
if (interiorDarken > 0.0) {
|
||||
result *= mix(1.0, 0.5, interiorDarken);
|
||||
}
|
||||
}
|
||||
|
||||
float dist = length(viewPos.xyz - FragPos);
|
||||
float fogFactor = clamp((fogParams.y - dist) / (fogParams.y - fogParams.x), 0.0, 1.0);
|
||||
result = mix(fogColor.rgb, result, fogFactor);
|
||||
|
||||
outColor = vec4(result, texColor.a * fadeAlpha);
|
||||
}
|
||||
BIN
assets/shaders/m2.frag.spv
Normal file
BIN
assets/shaders/m2.frag.spv
Normal file
Binary file not shown.
59
assets/shaders/m2.vert.glsl
Normal file
59
assets/shaders/m2.vert.glsl
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 model;
|
||||
vec2 uvOffset;
|
||||
int texCoordSet;
|
||||
int useBones;
|
||||
} push;
|
||||
|
||||
layout(set = 2, binding = 0) readonly buffer BoneSSBO {
|
||||
mat4 bones[];
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
layout(location = 2) in vec2 aTexCoord;
|
||||
layout(location = 3) in vec4 aBoneWeights;
|
||||
layout(location = 4) in vec4 aBoneIndicesF;
|
||||
layout(location = 5) in vec2 aTexCoord2;
|
||||
|
||||
layout(location = 0) out vec3 FragPos;
|
||||
layout(location = 1) out vec3 Normal;
|
||||
layout(location = 2) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
vec4 pos = vec4(aPos, 1.0);
|
||||
vec4 norm = vec4(aNormal, 0.0);
|
||||
|
||||
if (push.useBones != 0) {
|
||||
ivec4 bi = ivec4(aBoneIndicesF);
|
||||
mat4 skinMat = bones[bi.x] * aBoneWeights.x
|
||||
+ bones[bi.y] * aBoneWeights.y
|
||||
+ bones[bi.z] * aBoneWeights.z
|
||||
+ bones[bi.w] * aBoneWeights.w;
|
||||
pos = skinMat * pos;
|
||||
norm = skinMat * norm;
|
||||
}
|
||||
|
||||
vec4 worldPos = push.model * pos;
|
||||
FragPos = worldPos.xyz;
|
||||
Normal = mat3(push.model) * norm.xyz;
|
||||
|
||||
TexCoord = (push.texCoordSet == 1 ? aTexCoord2 : aTexCoord) + push.uvOffset;
|
||||
|
||||
gl_Position = projection * view * worldPos;
|
||||
}
|
||||
BIN
assets/shaders/m2.vert.spv
Normal file
BIN
assets/shaders/m2.vert.spv
Normal file
Binary file not shown.
30
assets/shaders/m2_particle.frag.glsl
Normal file
30
assets/shaders/m2_particle.frag.glsl
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D uTexture;
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
vec2 tileCount;
|
||||
int alphaKey;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec4 vColor;
|
||||
layout(location = 1) in float vTile;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 p = gl_PointCoord;
|
||||
float tile = floor(vTile);
|
||||
float tx = mod(tile, push.tileCount.x);
|
||||
float ty = floor(tile / push.tileCount.x);
|
||||
vec2 uv = (vec2(tx, ty) + p) / push.tileCount;
|
||||
vec4 texColor = texture(uTexture, uv);
|
||||
|
||||
if (push.alphaKey != 0) {
|
||||
float lum = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));
|
||||
if (lum < 0.05) discard;
|
||||
}
|
||||
|
||||
float edge = smoothstep(0.5, 0.4, length(p - 0.5));
|
||||
outColor = texColor * vColor * vec4(vec3(1.0), edge);
|
||||
}
|
||||
BIN
assets/shaders/m2_particle.frag.spv
Normal file
BIN
assets/shaders/m2_particle.frag.spv
Normal file
Binary file not shown.
31
assets/shaders/m2_particle.vert.glsl
Normal file
31
assets/shaders/m2_particle.vert.glsl
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec4 aColor;
|
||||
layout(location = 2) in float aSize;
|
||||
layout(location = 3) in float aTile;
|
||||
|
||||
layout(location = 0) out vec4 vColor;
|
||||
layout(location = 1) out float vTile;
|
||||
|
||||
void main() {
|
||||
vec4 viewPos4 = view * vec4(aPos, 1.0);
|
||||
float dist = -viewPos4.z;
|
||||
gl_PointSize = clamp(aSize * 500.0 / max(dist, 1.0), 1.0, 128.0);
|
||||
vColor = aColor;
|
||||
vTile = aTile;
|
||||
gl_Position = projection * viewPos4;
|
||||
}
|
||||
BIN
assets/shaders/m2_particle.vert.spv
Normal file
BIN
assets/shaders/m2_particle.vert.spv
Normal file
Binary file not shown.
25
assets/shaders/m2_smoke.frag.glsl
Normal file
25
assets/shaders/m2_smoke.frag.glsl
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vLifeRatio;
|
||||
layout(location = 1) in float vIsSpark;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 p = gl_PointCoord - vec2(0.5);
|
||||
float dist = length(p);
|
||||
if (dist > 0.5) discard;
|
||||
|
||||
if (vIsSpark > 0.5) {
|
||||
float glow = smoothstep(0.5, 0.0, dist);
|
||||
float life = 1.0 - vLifeRatio;
|
||||
vec3 color = mix(vec3(1.0, 0.6, 0.1), vec3(1.0, 0.2, 0.0), vLifeRatio);
|
||||
outColor = vec4(color * glow, glow * life);
|
||||
} else {
|
||||
float edge = smoothstep(0.5, 0.3, dist);
|
||||
float fadeIn = smoothstep(0.0, 0.2, vLifeRatio);
|
||||
float fadeOut = 1.0 - smoothstep(0.6, 1.0, vLifeRatio);
|
||||
float alpha = edge * fadeIn * fadeOut * 0.4;
|
||||
outColor = vec4(vec3(0.5), alpha);
|
||||
}
|
||||
}
|
||||
BIN
assets/shaders/m2_smoke.frag.spv
Normal file
BIN
assets/shaders/m2_smoke.frag.spv
Normal file
Binary file not shown.
36
assets/shaders/m2_smoke.vert.glsl
Normal file
36
assets/shaders/m2_smoke.vert.glsl
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
float screenHeight;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in float aLifeRatio;
|
||||
layout(location = 2) in float aSize;
|
||||
layout(location = 3) in float aIsSpark;
|
||||
|
||||
layout(location = 0) out float vLifeRatio;
|
||||
layout(location = 1) out float vIsSpark;
|
||||
|
||||
void main() {
|
||||
vec4 viewPos4 = view * vec4(aPos, 1.0);
|
||||
float dist = -viewPos4.z;
|
||||
float scale = aIsSpark > 0.5 ? 0.12 : 0.3;
|
||||
gl_PointSize = clamp(aSize * scale * push.screenHeight / max(dist, 1.0), 1.0, 64.0);
|
||||
vLifeRatio = aLifeRatio;
|
||||
vIsSpark = aIsSpark;
|
||||
gl_Position = projection * viewPos4;
|
||||
}
|
||||
BIN
assets/shaders/m2_smoke.vert.spv
Normal file
BIN
assets/shaders/m2_smoke.vert.spv
Normal file
Binary file not shown.
67
assets/shaders/minimap_display.frag.glsl
Normal file
67
assets/shaders/minimap_display.frag.glsl
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D uComposite;
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
vec4 rect;
|
||||
vec2 playerUV;
|
||||
float rotation;
|
||||
float arrowRotation;
|
||||
float zoomRadius;
|
||||
int squareShape;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec2 TexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
float cross2d(vec2 a, vec2 b) {
|
||||
return a.x * b.y - a.y * b.x;
|
||||
}
|
||||
|
||||
bool pointInTriangle(vec2 p, vec2 a, vec2 b, vec2 c) {
|
||||
float d1 = cross2d(b - a, p - a);
|
||||
float d2 = cross2d(c - b, p - b);
|
||||
float d3 = cross2d(a - c, p - c);
|
||||
bool hasNeg = (d1 < 0.0) || (d2 < 0.0) || (d3 < 0.0);
|
||||
bool hasPos = (d1 > 0.0) || (d2 > 0.0) || (d3 > 0.0);
|
||||
return !(hasNeg && hasPos);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 center = TexCoord - 0.5;
|
||||
float dist = length(center);
|
||||
|
||||
if (push.squareShape == 0) {
|
||||
if (dist > 0.5) discard;
|
||||
}
|
||||
|
||||
float cs = cos(push.rotation);
|
||||
float sn = sin(push.rotation);
|
||||
vec2 rotated = vec2(center.x * cs - center.y * sn, center.x * sn + center.y * cs);
|
||||
vec2 mapUV = push.playerUV + rotated * push.zoomRadius * 2.0;
|
||||
|
||||
vec4 mapColor = texture(uComposite, mapUV);
|
||||
|
||||
// Player arrow
|
||||
float acs = cos(push.arrowRotation);
|
||||
float asn = sin(push.arrowRotation);
|
||||
vec2 ac = center;
|
||||
vec2 arrowPos = vec2(ac.x * acs - ac.y * asn, ac.x * asn + ac.y * acs);
|
||||
|
||||
vec2 tip = vec2(0.0, -0.04);
|
||||
vec2 left = vec2(-0.02, 0.02);
|
||||
vec2 right = vec2(0.02, 0.02);
|
||||
|
||||
if (pointInTriangle(arrowPos, tip, left, right)) {
|
||||
mapColor = vec4(1.0, 0.8, 0.0, 1.0);
|
||||
}
|
||||
|
||||
// Dark border ring
|
||||
float border = smoothstep(0.48, 0.5, dist);
|
||||
if (push.squareShape == 0) {
|
||||
mapColor.rgb *= 1.0 - border * 0.7;
|
||||
}
|
||||
|
||||
outColor = mapColor;
|
||||
}
|
||||
BIN
assets/shaders/minimap_display.frag.spv
Normal file
BIN
assets/shaders/minimap_display.frag.spv
Normal file
Binary file not shown.
16
assets/shaders/minimap_display.vert.glsl
Normal file
16
assets/shaders/minimap_display.vert.glsl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
vec4 rect; // x, y, w, h in 0..1 screen space
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec2 aPos;
|
||||
layout(location = 1) in vec2 aUV;
|
||||
|
||||
layout(location = 0) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
TexCoord = aUV;
|
||||
vec2 screenPos = push.rect.xy + aPos * push.rect.zw;
|
||||
gl_Position = vec4(screenPos * 2.0 - 1.0, 0.0, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/minimap_display.vert.spv
Normal file
BIN
assets/shaders/minimap_display.vert.spv
Normal file
Binary file not shown.
11
assets/shaders/minimap_tile.frag.glsl
Normal file
11
assets/shaders/minimap_tile.frag.glsl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D uTileTexture;
|
||||
|
||||
layout(location = 0) in vec2 TexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = texture(uTileTexture, vec2(TexCoord.y, TexCoord.x));
|
||||
}
|
||||
BIN
assets/shaders/minimap_tile.frag.spv
Normal file
BIN
assets/shaders/minimap_tile.frag.spv
Normal file
Binary file not shown.
17
assets/shaders/minimap_tile.vert.glsl
Normal file
17
assets/shaders/minimap_tile.vert.glsl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
vec2 gridOffset;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec2 aPos;
|
||||
layout(location = 1) in vec2 aUV;
|
||||
|
||||
layout(location = 0) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
TexCoord = aUV;
|
||||
vec2 pos = (aPos + push.gridOffset) / 3.0;
|
||||
pos = pos * 2.0 - 1.0;
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/minimap_tile.vert.spv
Normal file
BIN
assets/shaders/minimap_tile.vert.spv
Normal file
Binary file not shown.
13
assets/shaders/mount_dust.frag.glsl
Normal file
13
assets/shaders/mount_dust.frag.glsl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vAlpha;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 p = gl_PointCoord - vec2(0.5);
|
||||
float dist = length(p);
|
||||
if (dist > 0.5) discard;
|
||||
float alpha = smoothstep(0.5, 0.1, dist) * vAlpha * 0.4;
|
||||
outColor = vec4(0.7, 0.65, 0.55, alpha);
|
||||
}
|
||||
BIN
assets/shaders/mount_dust.frag.spv
Normal file
BIN
assets/shaders/mount_dust.frag.spv
Normal file
Binary file not shown.
26
assets/shaders/mount_dust.vert.glsl
Normal file
26
assets/shaders/mount_dust.vert.glsl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in float aSize;
|
||||
layout(location = 2) in float aAlpha;
|
||||
|
||||
layout(location = 0) out float vAlpha;
|
||||
|
||||
void main() {
|
||||
gl_PointSize = aSize;
|
||||
vAlpha = aAlpha;
|
||||
gl_Position = projection * view * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/mount_dust.vert.spv
Normal file
BIN
assets/shaders/mount_dust.vert.spv
Normal file
Binary file not shown.
20
assets/shaders/postprocess.frag.glsl
Normal file
20
assets/shaders/postprocess.frag.glsl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D uScene;
|
||||
|
||||
layout(location = 0) in vec2 TexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec3 hdr = texture(uScene, TexCoord).rgb;
|
||||
// Shoulder tone map
|
||||
vec3 mapped = hdr;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (mapped[i] > 0.9) {
|
||||
float excess = mapped[i] - 0.9;
|
||||
mapped[i] = 0.9 + 0.1 * excess / (excess + 0.1);
|
||||
}
|
||||
}
|
||||
outColor = vec4(mapped, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/postprocess.frag.spv
Normal file
BIN
assets/shaders/postprocess.frag.spv
Normal file
Binary file not shown.
10
assets/shaders/postprocess.vert.glsl
Normal file
10
assets/shaders/postprocess.vert.glsl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
// Fullscreen triangle trick: 3 vertices, no vertex buffer
|
||||
TexCoord = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
|
||||
gl_Position = vec4(TexCoord * 2.0 - 1.0, 0.0, 1.0);
|
||||
TexCoord.y = 1.0 - TexCoord.y; // flip Y for Vulkan
|
||||
}
|
||||
BIN
assets/shaders/postprocess.vert.spv
Normal file
BIN
assets/shaders/postprocess.vert.spv
Normal file
Binary file not shown.
18
assets/shaders/quest_marker.frag.glsl
Normal file
18
assets/shaders/quest_marker.frag.glsl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D markerTexture;
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 model;
|
||||
float alpha;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec2 TexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec4 texColor = texture(markerTexture, TexCoord);
|
||||
if (texColor.a < 0.1) discard;
|
||||
outColor = vec4(texColor.rgb, texColor.a * push.alpha);
|
||||
}
|
||||
BIN
assets/shaders/quest_marker.frag.spv
Normal file
BIN
assets/shaders/quest_marker.frag.spv
Normal file
Binary file not shown.
28
assets/shaders/quest_marker.vert.glsl
Normal file
28
assets/shaders/quest_marker.vert.glsl
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 model;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec2 aTexCoord;
|
||||
|
||||
layout(location = 0) out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
TexCoord = aTexCoord;
|
||||
gl_Position = projection * view * push.model * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/quest_marker.vert.spv
Normal file
BIN
assets/shaders/quest_marker.vert.spv
Normal file
Binary file not shown.
19
assets/shaders/selection_circle.frag.glsl
Normal file
19
assets/shaders/selection_circle.frag.glsl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 mvp;
|
||||
vec4 color;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec2 vLocalPos;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
float r = length(vLocalPos);
|
||||
float ring = smoothstep(0.93, 0.97, r) * smoothstep(1.0, 0.97, r);
|
||||
float inward = (1.0 - smoothstep(0.0, 0.93, r)) * 0.15;
|
||||
float alpha = max(ring, inward);
|
||||
if (alpha < 0.01) discard;
|
||||
outColor = vec4(push.color.rgb, alpha);
|
||||
}
|
||||
BIN
assets/shaders/selection_circle.frag.spv
Normal file
BIN
assets/shaders/selection_circle.frag.spv
Normal file
Binary file not shown.
14
assets/shaders/selection_circle.vert.glsl
Normal file
14
assets/shaders/selection_circle.vert.glsl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 mvp;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
|
||||
layout(location = 0) out vec2 vLocalPos;
|
||||
|
||||
void main() {
|
||||
vLocalPos = aPos.xz;
|
||||
gl_Position = push.mvp * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/selection_circle.vert.spv
Normal file
BIN
assets/shaders/selection_circle.vert.spv
Normal file
Binary file not shown.
37
assets/shaders/shadow.frag.glsl
Normal file
37
assets/shaders/shadow.frag.glsl
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D uTexture;
|
||||
|
||||
layout(set = 1, binding = 1) uniform ShadowParams {
|
||||
int useBones;
|
||||
int useTexture;
|
||||
int alphaTest;
|
||||
int foliageSway;
|
||||
float windTime;
|
||||
float foliageMotionDamp;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec2 TexCoord;
|
||||
layout(location = 1) in vec3 WorldPos;
|
||||
|
||||
void main() {
|
||||
if (useTexture != 0) {
|
||||
vec2 uv = TexCoord;
|
||||
if (foliageSway != 0) {
|
||||
float sway = sin(windTime + WorldPos.x * 0.5) * 0.02 * foliageMotionDamp;
|
||||
uv += vec2(sway, sway * 0.5);
|
||||
}
|
||||
vec4 texColor = textureLod(uTexture, uv, 0.0);
|
||||
if (alphaTest != 0 && texColor.a < 0.5) discard;
|
||||
|
||||
if (foliageSway != 0) {
|
||||
vec2 uv2 = TexCoord + vec2(
|
||||
sin(windTime * 1.3 + WorldPos.z * 0.7) * 0.015 * foliageMotionDamp,
|
||||
sin(windTime * 0.9 + WorldPos.x * 0.6) * 0.01 * foliageMotionDamp
|
||||
);
|
||||
vec4 texColor2 = textureLod(uTexture, uv2, 0.0);
|
||||
float blended = (texColor.a + texColor2.a) * 0.5;
|
||||
if (alphaTest != 0 && blended < 0.5) discard;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
assets/shaders/shadow.frag.spv
Normal file
BIN
assets/shaders/shadow.frag.spv
Normal file
Binary file not shown.
45
assets/shaders/shadow.vert.glsl
Normal file
45
assets/shaders/shadow.vert.glsl
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#version 450
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 lightSpaceMatrix;
|
||||
mat4 model;
|
||||
} push;
|
||||
|
||||
layout(set = 2, binding = 0) readonly buffer BoneSSBO {
|
||||
mat4 bones[];
|
||||
};
|
||||
|
||||
layout(set = 1, binding = 1) uniform ShadowParams {
|
||||
int useBones;
|
||||
int useTexture;
|
||||
int alphaTest;
|
||||
int foliageSway;
|
||||
float windTime;
|
||||
float foliageMotionDamp;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec2 aTexCoord;
|
||||
layout(location = 2) in vec4 aBoneWeights;
|
||||
layout(location = 3) in vec4 aBoneIndicesF;
|
||||
|
||||
layout(location = 0) out vec2 TexCoord;
|
||||
layout(location = 1) out vec3 WorldPos;
|
||||
|
||||
void main() {
|
||||
vec4 pos = vec4(aPos, 1.0);
|
||||
|
||||
if (useBones != 0) {
|
||||
ivec4 bi = ivec4(aBoneIndicesF);
|
||||
mat4 skinMat = bones[bi.x] * aBoneWeights.x
|
||||
+ bones[bi.y] * aBoneWeights.y
|
||||
+ bones[bi.z] * aBoneWeights.z
|
||||
+ bones[bi.w] * aBoneWeights.w;
|
||||
pos = skinMat * pos;
|
||||
}
|
||||
|
||||
vec4 worldPos = push.model * pos;
|
||||
WorldPos = worldPos.xyz;
|
||||
TexCoord = aTexCoord;
|
||||
gl_Position = push.lightSpaceMatrix * worldPos;
|
||||
}
|
||||
BIN
assets/shaders/shadow.vert.spv
Normal file
BIN
assets/shaders/shadow.vert.spv
Normal file
Binary file not shown.
34
assets/shaders/skybox.frag.glsl
Normal file
34
assets/shaders/skybox.frag.glsl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
vec4 horizonColor;
|
||||
vec4 zenithColor;
|
||||
float timeOfDay;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 WorldPos;
|
||||
layout(location = 1) in float Altitude;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
float t = clamp(Altitude, 0.0, 1.0);
|
||||
t = pow(t, 1.5);
|
||||
vec3 sky = mix(push.horizonColor.rgb, push.zenithColor.rgb, t);
|
||||
float scatter = max(0.0, 1.0 - t * 2.0) * 0.15;
|
||||
sky += vec3(scatter * 0.8, scatter * 0.4, scatter * 0.1);
|
||||
outColor = vec4(sky, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/skybox.frag.spv
Normal file
BIN
assets/shaders/skybox.frag.spv
Normal file
Binary file not shown.
27
assets/shaders/skybox.vert.glsl
Normal file
27
assets/shaders/skybox.vert.glsl
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams; // x=fogStart, y=fogEnd, z=time
|
||||
vec4 shadowParams; // x=enabled, y=strength
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
|
||||
layout(location = 0) out vec3 WorldPos;
|
||||
layout(location = 1) out float Altitude;
|
||||
|
||||
void main() {
|
||||
WorldPos = aPos;
|
||||
Altitude = aPos.y;
|
||||
mat4 rotView = mat4(mat3(view)); // strip translation
|
||||
vec4 pos = projection * rotView * vec4(aPos, 1.0);
|
||||
gl_Position = pos.xyww; // force far plane
|
||||
}
|
||||
BIN
assets/shaders/skybox.vert.spv
Normal file
BIN
assets/shaders/skybox.vert.spv
Normal file
Binary file not shown.
13
assets/shaders/starfield.frag.glsl
Normal file
13
assets/shaders/starfield.frag.glsl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vBrightness;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 p = gl_PointCoord - vec2(0.5);
|
||||
float dist = length(p);
|
||||
if (dist > 0.5) discard;
|
||||
float alpha = vBrightness * smoothstep(0.5, 0.2, dist);
|
||||
outColor = vec4(vec3(0.9, 0.95, 1.0) * vBrightness, alpha);
|
||||
}
|
||||
BIN
assets/shaders/starfield.frag.spv
Normal file
BIN
assets/shaders/starfield.frag.spv
Normal file
Binary file not shown.
33
assets/shaders/starfield.vert.glsl
Normal file
33
assets/shaders/starfield.vert.glsl
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
float time;
|
||||
float intensity;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in float aBrightness;
|
||||
layout(location = 2) in float aTwinklePhase;
|
||||
|
||||
layout(location = 0) out float vBrightness;
|
||||
|
||||
void main() {
|
||||
mat4 rotView = mat4(mat3(view));
|
||||
float twinkle = 0.7 + 0.3 * sin(push.time * 1.5 + aTwinklePhase);
|
||||
vBrightness = aBrightness * twinkle * push.intensity;
|
||||
gl_PointSize = mix(2.0, 4.0, aBrightness);
|
||||
gl_Position = projection * rotView * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/starfield.vert.spv
Normal file
BIN
assets/shaders/starfield.vert.spv
Normal file
Binary file not shown.
15
assets/shaders/swim_bubble.frag.glsl
Normal file
15
assets/shaders/swim_bubble.frag.glsl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vAlpha;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 p = gl_PointCoord - vec2(0.5);
|
||||
float dist = length(p);
|
||||
if (dist > 0.5) discard;
|
||||
float ring = smoothstep(0.5, 0.4, dist) - smoothstep(0.38, 0.28, dist);
|
||||
float highlight = smoothstep(0.3, 0.1, length(p - vec2(-0.15, 0.15))) * 0.5;
|
||||
float alpha = (ring + highlight) * vAlpha;
|
||||
outColor = vec4(0.8, 0.9, 1.0, alpha);
|
||||
}
|
||||
BIN
assets/shaders/swim_bubble.frag.spv
Normal file
BIN
assets/shaders/swim_bubble.frag.spv
Normal file
Binary file not shown.
26
assets/shaders/swim_bubble.vert.glsl
Normal file
26
assets/shaders/swim_bubble.vert.glsl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in float aSize;
|
||||
layout(location = 2) in float aAlpha;
|
||||
|
||||
layout(location = 0) out float vAlpha;
|
||||
|
||||
void main() {
|
||||
gl_PointSize = aSize;
|
||||
vAlpha = aAlpha;
|
||||
gl_Position = projection * view * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/swim_bubble.vert.spv
Normal file
BIN
assets/shaders/swim_bubble.vert.spv
Normal file
Binary file not shown.
13
assets/shaders/swim_ripple.frag.glsl
Normal file
13
assets/shaders/swim_ripple.frag.glsl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vAlpha;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 p = gl_PointCoord - vec2(0.5);
|
||||
float dist = length(p);
|
||||
if (dist > 0.5) discard;
|
||||
float alpha = smoothstep(0.5, 0.1, dist) * vAlpha;
|
||||
outColor = vec4(0.85, 0.92, 1.0, alpha);
|
||||
}
|
||||
BIN
assets/shaders/swim_ripple.frag.spv
Normal file
BIN
assets/shaders/swim_ripple.frag.spv
Normal file
Binary file not shown.
26
assets/shaders/swim_ripple.vert.glsl
Normal file
26
assets/shaders/swim_ripple.vert.glsl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in float aSize;
|
||||
layout(location = 2) in float aAlpha;
|
||||
|
||||
layout(location = 0) out float vAlpha;
|
||||
|
||||
void main() {
|
||||
gl_PointSize = aSize;
|
||||
vAlpha = aAlpha;
|
||||
gl_Position = projection * view * vec4(aPos, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/swim_ripple.vert.spv
Normal file
BIN
assets/shaders/swim_ripple.vert.spv
Normal file
Binary file not shown.
96
assets/shaders/terrain.frag.glsl
Normal file
96
assets/shaders/terrain.frag.glsl
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D uBaseTexture;
|
||||
layout(set = 1, binding = 1) uniform sampler2D uLayer1Texture;
|
||||
layout(set = 1, binding = 2) uniform sampler2D uLayer2Texture;
|
||||
layout(set = 1, binding = 3) uniform sampler2D uLayer3Texture;
|
||||
layout(set = 1, binding = 4) uniform sampler2D uLayer1Alpha;
|
||||
layout(set = 1, binding = 5) uniform sampler2D uLayer2Alpha;
|
||||
layout(set = 1, binding = 6) uniform sampler2D uLayer3Alpha;
|
||||
|
||||
layout(set = 1, binding = 7) uniform TerrainParams {
|
||||
int layerCount;
|
||||
int hasLayer1;
|
||||
int hasLayer2;
|
||||
int hasLayer3;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1) uniform sampler2DShadow uShadowMap;
|
||||
|
||||
layout(location = 0) in vec3 FragPos;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec2 TexCoord;
|
||||
layout(location = 3) in vec2 LayerUV;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
float sampleAlpha(sampler2D tex, vec2 uv) {
|
||||
vec2 edge = min(uv, 1.0 - uv);
|
||||
float border = min(edge.x, edge.y);
|
||||
float doBlur = step(border, 2.0 / 64.0);
|
||||
if (doBlur < 0.5) {
|
||||
return texture(tex, uv).r;
|
||||
}
|
||||
vec2 texel = vec2(1.0 / 64.0);
|
||||
float a = 0.0;
|
||||
a += texture(tex, uv + vec2(-texel.x, 0.0)).r;
|
||||
a += texture(tex, uv + vec2(texel.x, 0.0)).r;
|
||||
a += texture(tex, uv + vec2(0.0, -texel.y)).r;
|
||||
a += texture(tex, uv + vec2(0.0, texel.y)).r;
|
||||
return a * 0.25;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 baseColor = texture(uBaseTexture, TexCoord);
|
||||
float a1 = hasLayer1 != 0 ? sampleAlpha(uLayer1Alpha, LayerUV) : 0.0;
|
||||
float a2 = hasLayer2 != 0 ? sampleAlpha(uLayer2Alpha, LayerUV) : 0.0;
|
||||
float a3 = hasLayer3 != 0 ? sampleAlpha(uLayer3Alpha, LayerUV) : 0.0;
|
||||
|
||||
float w0 = 1.0, w1 = a1, w2 = a2, w3 = a3;
|
||||
float sum = w0 + w1 + w2 + w3;
|
||||
if (sum > 0.0) { w0 /= sum; w1 /= sum; w2 /= sum; w3 /= sum; }
|
||||
|
||||
vec4 finalColor = baseColor * w0;
|
||||
if (hasLayer1 != 0) finalColor += texture(uLayer1Texture, TexCoord) * w1;
|
||||
if (hasLayer2 != 0) finalColor += texture(uLayer2Texture, TexCoord) * w2;
|
||||
if (hasLayer3 != 0) finalColor += texture(uLayer3Texture, TexCoord) * w3;
|
||||
|
||||
vec3 norm = normalize(Normal);
|
||||
vec3 lightDir2 = normalize(-lightDir.xyz);
|
||||
vec3 ambient = ambientColor.rgb * finalColor.rgb;
|
||||
float diff = max(abs(dot(norm, lightDir2)), 0.2);
|
||||
vec3 diffuse = diff * lightColor.rgb * finalColor.rgb;
|
||||
|
||||
float shadow = 1.0;
|
||||
if (shadowParams.x > 0.5) {
|
||||
vec4 lsPos = lightSpaceMatrix * vec4(FragPos, 1.0);
|
||||
vec3 proj = lsPos.xyz / lsPos.w;
|
||||
proj.xy = proj.xy * 0.5 + 0.5;
|
||||
if (proj.x >= 0.0 && proj.x <= 1.0 && proj.y >= 0.0 && proj.y <= 1.0 && proj.z <= 1.0) {
|
||||
float bias = 0.002;
|
||||
shadow = texture(uShadowMap, vec3(proj.xy, proj.z - bias));
|
||||
shadow = mix(1.0, shadow, shadowParams.y);
|
||||
}
|
||||
}
|
||||
|
||||
vec3 result = ambient + shadow * diffuse;
|
||||
|
||||
float distance = length(viewPos.xyz - FragPos);
|
||||
float fogFactor = clamp((fogParams.y - distance) / (fogParams.y - fogParams.x), 0.0, 1.0);
|
||||
result = mix(fogColor.rgb, result, fogFactor);
|
||||
|
||||
outColor = vec4(result, 1.0);
|
||||
}
|
||||
BIN
assets/shaders/terrain.frag.spv
Normal file
BIN
assets/shaders/terrain.frag.spv
Normal file
Binary file not shown.
37
assets/shaders/terrain.vert.glsl
Normal file
37
assets/shaders/terrain.vert.glsl
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform PerFrame {
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 lightSpaceMatrix;
|
||||
vec4 lightDir;
|
||||
vec4 lightColor;
|
||||
vec4 ambientColor;
|
||||
vec4 viewPos;
|
||||
vec4 fogColor;
|
||||
vec4 fogParams;
|
||||
vec4 shadowParams;
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat4 model;
|
||||
} push;
|
||||
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
layout(location = 2) in vec2 aTexCoord;
|
||||
layout(location = 3) in vec2 aLayerUV;
|
||||
|
||||
layout(location = 0) out vec3 FragPos;
|
||||
layout(location = 1) out vec3 Normal;
|
||||
layout(location = 2) out vec2 TexCoord;
|
||||
layout(location = 3) out vec2 LayerUV;
|
||||
|
||||
void main() {
|
||||
vec4 worldPos = push.model * vec4(aPosition, 1.0);
|
||||
FragPos = worldPos.xyz;
|
||||
Normal = aNormal;
|
||||
TexCoord = aTexCoord;
|
||||
LayerUV = aLayerUV;
|
||||
gl_Position = projection * view * worldPos;
|
||||
}
|
||||
BIN
assets/shaders/terrain.vert.spv
Normal file
BIN
assets/shaders/terrain.vert.spv
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue