#version 330 // FBC: NIGHT SHIFT — actor vertex stage (S9 look-dev). // raylib feeds vertexPosition/vertexNormal/vertexColor and the matModel uniform. // Procedural motion: saturated (corrupted) vertices jitter, the guard breathes. // uOutline expands back faces along the normal for the hero/boss ink outline. in vec3 vertexPosition; in vec3 vertexNormal; in vec2 vertexTexCoord; in vec4 vertexColor; uniform mat4 mvp; uniform mat4 matModel; uniform float uTime = 0.0; uniform float uOutline = 0.0; uniform float uWalk = 0.0; uniform float uStagger = 0.0; uniform float uPhase = 0.0; uniform vec4 uRig = vec4(0.0); // hipY, shoulderY, legX, armX uniform float uRigScale = 0.0; // amplitude / enable uniform float uRigMode = 0.0; // 0 none, 1 humanoid, 2 blob, 3 crystal vec3 rot_x(vec3 v, float a) { float c = cos(a), s = sin(a); return vec3(v.x, c * v.y - s * v.z, s * v.y + c * v.z); } out vec2 fragTexCoord; out vec4 fragColor; out vec3 vNormal; out vec3 vWorld; void main() { vec3 p = vertexPosition; // Recover the painted palette to tell a faction from its vertex colour. vec3 paint = pow(max(vertexColor.rgb, vec3(0.0)), vec3(1.0 / 2.2)); float sat = max(paint.r, max(paint.g, paint.b)) - min(paint.r, min(paint.g, paint.b)); float corrupt = smoothstep(0.18, 0.52, sat); // Hiss / Mold: nervous high-frequency micro-jitter, deterministic in space. vec3 jitter = vec3(sin(uTime * 9.3 + p.y * 17.0), sin(uTime * 6.1 + p.y * 11.0) * 0.35, cos(uTime * 8.1 + p.y * 13.0)) * (0.011 * corrupt); // The guard breathes instead of twitching. float breath = sin(uTime * 1.9) * 0.005 * (1.0 - corrupt) * step(0.25, p.y); p += jitter; p.y += breath; // Procedural rigs: classify vertices by local position — no skeleton, no // extra vertex attributes, no extra draw calls. Modes: 1 humanoid, // 2 blob (Mold), 3 crystal (Resonance shard). if (uRigMode > 2.5) { // Crystal: slow facet breathing along the normal plus a shimmer wobble. float shimmer = sin(uTime * 3.1 + uPhase + p.y * 9.0) * 0.5 + 0.5; p += vertexNormal * (0.008 + 0.018 * shimmer) * uRigScale; p.x += sin(uTime * 1.7 + uPhase) * 0.01 * uRigScale; } else if (uRigMode > 1.5) { // Mold blob: squash/stretch jelly with height-weighted wobble. float cycle = uTime * 4.0 + uPhase; float amp = (0.045 + 0.075 * uWalk) * uRigScale; float squash = sin(cycle) * amp; float h = clamp(p.y / 1.3, 0.0, 1.0); p.y *= 1.0 + squash * (0.35 + 0.65 * h); p.xz *= 1.0 - squash * 0.7 * (0.35 + 0.65 * h); p.x += sin(cycle * 1.7 + p.y * 6.0) * 0.025 * h * uRigScale; if (uStagger > 0.0) { p.y *= 1.0 - 0.22 * uStagger; p.x += sin(uTime * 26.0 + uPhase) * 0.04 * uStagger; } } else if (uRigMode > 0.5) { // Humanoid: arms counter-swing the legs. The flat base ring is a // marker, not anatomy: leave it planted. float base_ring = step(0.40, length(p.xz)) * step(p.y, 0.12); if (base_ring < 0.5) { float cycle = uTime * 8.0 + uPhase; float swing = sin(cycle) * 0.38 * uWalk * uRigScale; float side = p.x < 0.0 ? -1.0 : 1.0; if (abs(p.x) > uRig.w && p.y > 0.55 && p.y < uRig.y) { vec3 pivot = vec3(side * uRig.w, uRig.y, 0.0); p = rot_x(p - pivot, swing * side * 0.75) + pivot; } else if (p.y < uRig.x) { vec3 pivot = vec3(side * uRig.z, uRig.x, 0.0); p = rot_x(p - pivot, -swing * side) + pivot; } else { p.y += sin(cycle * 2.0) * 0.012 * uWalk * uRigScale; } if (uStagger > 0.0) { vec3 pivot = vec3(0.0, uRig.x, 0.0); p = rot_x(p - pivot, -0.38 * uStagger) + pivot; p.x += sin(uTime * 27.0 + uPhase) * 0.025 * uStagger; } } } if (uOutline > 0.5) p += vertexNormal * 0.022; vec4 world = matModel * vec4(p, 1.0); vNormal = normalize(mat3(matModel) * vertexNormal); vWorld = world.xyz; fragTexCoord = vertexTexCoord; fragColor = vertexColor; gl_Position = mvp * vec4(p, 1.0); }