diff --git a/src/client/graphics/webgpu/core/ShaderLoader.ts b/src/client/graphics/webgpu/core/ShaderLoader.ts index c5b818d50..19ad380ec 100644 --- a/src/client/graphics/webgpu/core/ShaderLoader.ts +++ b/src/client/graphics/webgpu/core/ShaderLoader.ts @@ -1,28 +1,18 @@ /** - * Utility for loading WGSL shader files via Vite ?raw imports. - * Caches loaded shaders to avoid re-importing. + * Utility for loading WGSL shader sources bundled by Vite. + * Uses a static glob so production builds reliably include all shaders. */ -const shaderCache = new Map>(); +const shaderSources = import.meta.glob("../shaders/**/*.wgsl", { + as: "raw", + eager: true, +}) as Record; -/** - * Load a shader file from the shaders directory. - * @param path Relative path from shaders/ directory (e.g., "compute/state-update.wgsl") - * @returns Promise resolving to the shader code as a string - */ export async function loadShader(path: string): Promise { - // Check cache first - if (shaderCache.has(path)) { - return shaderCache.get(path)!; + const key = `../shaders/${path}`; + const src = shaderSources[key]; + if (!src) { + throw new Error(`Missing WGSL shader source: ${key}`); } - - // Import shader using Vite ?raw import - const shaderPromise = import(`../shaders/${path}?raw`).then( - (module) => module.default as string, - ); - - // Cache the promise - shaderCache.set(path, shaderPromise); - - return shaderPromise; + return src; } diff --git a/src/client/graphics/webgpu/shaders/render/territory.wgsl b/src/client/graphics/webgpu/shaders/render/territory.wgsl index 5f1d7c334..565dc00aa 100644 --- a/src/client/graphics/webgpu/shaders/render/territory.wgsl +++ b/src/client/graphics/webgpu/shaders/render/territory.wgsl @@ -57,7 +57,7 @@ fn fsMain(@builtin(position) pos: vec4f) -> @location(0) vec4f { territoryRgb = mix( territoryRgb, vec3f(1.0, 0.0, 1.0), - clamp(0.35 * defendedStrength, 0.0, 0.35), + clamp(0.8 * defendedStrength, 0.1, 0.35), ); if (hasFallout) { // Fallout color is at index 0