Files
tsuki 831d96e562 Initial public source release
Split reusable rendering and format support into vectorail-core and vectorail-gc.
2026-08-02 17:05:27 +02:00

40 lines
1.4 KiB
GLSL

#version 450 core
out vec4 FragColor;
in vec2 vUv;
uniform float uTime;
uniform vec3 uResolution;
uniform sampler2D uBackdrop;
uniform bool uHasBackdrop;
uniform float uBackdropAspect;
uniform vec3 uBgTopRight;
uniform vec3 uBgTopLeft;
uniform vec3 uBgBottomRight;
uniform vec3 uBgBottomLeft;
void main() {
vec3 top = mix(uBgTopLeft, uBgTopRight, vUv.x);
vec3 bottom = mix(uBgBottomLeft, uBgBottomRight, vUv.x);
vec3 color = mix(bottom, top, vUv.y);
if (uHasBackdrop) {
// The useful jacket cell occupies the left square of GC's 512x256
// *_menu.dds atlas. Crop that cell and cover the portrait viewport.
float screenAspect = uResolution.x / uResolution.y;
vec2 imageUv = vUv - 0.5;
if (screenAspect < uBackdropAspect) {
imageUv.x *= screenAspect / uBackdropAspect;
} else {
imageUv.y *= uBackdropAspect / screenAspect;
}
imageUv += 0.5;
// Jacket cell bounds are 197x197 in the original 512x256 atlas.
vec2 atlasUv = vec2(imageUv.x * (197.0 / 512.0),
(1.0 - imageUv.y) * (197.0 / 256.0));
vec4 backdrop = texture(uBackdrop, atlasUv);
float vignette = 1.0 - smoothstep(0.18, 0.82, length(vUv - 0.5));
color = mix(color, backdrop.rgb * (0.08 + 0.05 * vignette), backdrop.a * 0.45);
}
FragColor = vec4(color, 1.0);
}