Skip to content

Commit eaed4c2

Browse files
author
Parsa Azari
committed
Fix shader loading: Use .txt extensions for GitHub Pages compatibility
1 parent d9b51a4 commit eaed4c2

15 files changed

+5977
-20
lines changed
39.6 KB
Binary file not shown.
9.32 KB
Loading

assets/main-BYSxBTd3.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/main-BllGijYf.js

Lines changed: 5391 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/main-BllGijYf.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Severance: The Game</title>
7-
<link rel="icon" href="./assets/lumon-logo-DACk_ks-.png" type="image/png">
7+
<link rel="icon" href="./assets/lumon-logo-DACk_ks--DACk_ks-.png" type="image/png">
88
<style>
99
body {
1010
margin: 0;
@@ -338,8 +338,8 @@ <h3>An error occurred</h3>
338338
}
339339
};
340340
</script>
341-
<script type="module" crossorigin src="./assets/main-DgERxilq.js"></script>
342-
<link rel="stylesheet" crossorigin href="./assets/main-D4FrnyUr.css">
341+
<script type="module" crossorigin src="./assets/main-BllGijYf.js"></script>
342+
<link rel="stylesheet" crossorigin href="./assets/main-BYSxBTd3.css">
343343
</head>
344344
<body>
345345
<div id="app-container">

src/core/rendering/environments/SeveranceEnvironment.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,10 @@ export class SeveranceEnvironment extends BaseEnvironment {
432432
// Use material system to load vertex shader instead of inline definition
433433
// This ensures we're following the project organization guidelines
434434
vertexShader: await this.materialSystem._loadShaderFile(
435-
"./src/shaders/common/vertex.glsl"
435+
"./src/shaders/common/vertex.txt"
436436
),
437437
fragmentShader: await this.materialSystem._loadShaderFile(
438-
"./src/shaders/wall.glsl"
438+
"./src/shaders/wall.txt"
439439
),
440440
side: THREE.DoubleSide,
441441
});
@@ -483,10 +483,10 @@ export class SeveranceEnvironment extends BaseEnvironment {
483483
},
484484
// Use material system to load vertex shader instead of inline definition
485485
vertexShader: await this.materialSystem._loadShaderFile(
486-
"./src/shaders/common/vertex.glsl"
486+
"./src/shaders/common/vertex.txt"
487487
),
488488
fragmentShader: await this.materialSystem._loadShaderFile(
489-
"./src/shaders/corridor.glsl"
489+
"./src/shaders/corridor.txt"
490490
),
491491
transparent: true,
492492
blending: THREE.AdditiveBlending,

src/core/rendering/materials/SeveranceMaterials.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export class SeveranceMaterials {
253253
"Attempting to load vertex shader from src/shaders/common/vertex.glsl"
254254
);
255255
commonVertexShader = await this._loadShaderFile(
256-
"./src/shaders/common/vertex.glsl"
256+
"./src/shaders/common/vertex.txt"
257257
);
258258
console.log("Successfully loaded vertex shader");
259259
} catch (e) {
@@ -271,7 +271,7 @@ export class SeveranceMaterials {
271271
"Attempting to load wall shader from src/shaders/wall.glsl"
272272
);
273273
wallFragmentShader = await this._loadShaderFile(
274-
"./src/shaders/wall.glsl"
274+
"./src/shaders/wall.txt"
275275
);
276276
console.log("Successfully loaded wall shader");
277277
console.log(
@@ -303,7 +303,7 @@ export class SeveranceMaterials {
303303
"Attempting to load corridor shader from src/shaders/corridor.glsl"
304304
);
305305
corridorFragmentShader = await this._loadShaderFile(
306-
"./src/shaders/corridor.glsl"
306+
"./src/shaders/corridor.txt"
307307
);
308308
console.log("Successfully loaded corridor shader");
309309
} catch (e) {
@@ -413,7 +413,7 @@ export class SeveranceMaterials {
413413
// Load wall shaders
414414
let wallVertexShader;
415415
try {
416-
wallVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.glsl');
416+
wallVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.txt');
417417
console.log('Successfully loaded wall vertex shader');
418418
} catch (error) {
419419
console.error('Failed to load wall vertex shader:', error);
@@ -422,7 +422,7 @@ export class SeveranceMaterials {
422422

423423
let wallFragmentShader;
424424
try {
425-
wallFragmentShader = await this._loadShaderFile('./src/shaders/wall.glsl');
425+
wallFragmentShader = await this._loadShaderFile('./src/shaders/wall.txt');
426426
console.log('Successfully loaded wall fragment shader');
427427
} catch (error) {
428428
console.error('Failed to load wall fragment shader:', error);
@@ -461,7 +461,7 @@ export class SeveranceMaterials {
461461
// Load corridor shaders
462462
let corridorVertexShader;
463463
try {
464-
corridorVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.glsl');
464+
corridorVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.txt');
465465
console.log('Successfully loaded corridor vertex shader');
466466
} catch (error) {
467467
console.error('Failed to load corridor vertex shader:', error);
@@ -470,7 +470,7 @@ export class SeveranceMaterials {
470470

471471
let corridorFragmentShader;
472472
try {
473-
corridorFragmentShader = await this._loadShaderFile('./src/shaders/corridor.glsl');
473+
corridorFragmentShader = await this._loadShaderFile('./src/shaders/corridor.txt');
474474
console.log('Successfully loaded corridor fragment shader');
475475
} catch (error) {
476476
console.error('Failed to load corridor fragment shader:', error);
@@ -510,15 +510,15 @@ export class SeveranceMaterials {
510510
// --- Add Tim Rodenbröker-inspired corridor wall shader ---
511511
let corridorWallVertexShader;
512512
try {
513-
corridorWallVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.glsl');
513+
corridorWallVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.txt');
514514
console.log('Successfully loaded corridor wall vertex shader');
515515
} catch (error) {
516516
console.error('Failed to load corridor wall vertex shader:', error);
517517
throw error;
518518
}
519519
let corridorWallFragmentShader;
520520
try {
521-
corridorWallFragmentShader = await this._loadShaderFile('./src/shaders/corridor_wall.glsl');
521+
corridorWallFragmentShader = await this._loadShaderFile('./src/shaders/corridor_wall.txt');
522522
console.log('Successfully loaded corridor wall fragment shader');
523523
} catch (error) {
524524
console.error('Failed to load corridor wall fragment shader:', error);
@@ -555,15 +555,15 @@ export class SeveranceMaterials {
555555
// --- Add Twin Peaks-inspired zigzag corridor floor shader ---
556556
let corridorFloorVertexShader;
557557
try {
558-
corridorFloorVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.glsl');
558+
corridorFloorVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.txt');
559559
console.log('Successfully loaded corridor floor vertex shader');
560560
} catch (error) {
561561
console.error('Failed to load corridor floor vertex shader:', error);
562562
throw error;
563563
}
564564
let corridorFloorFragmentShader;
565565
try {
566-
corridorFloorFragmentShader = await this._loadShaderFile('./src/shaders/corridor_floor.glsl');
566+
corridorFloorFragmentShader = await this._loadShaderFile('./src/shaders/corridor_floor.txt');
567567
console.log('Successfully loaded corridor floor fragment shader');
568568
} catch (error) {
569569
console.error('Failed to load corridor floor fragment shader:', error);
@@ -595,15 +595,15 @@ export class SeveranceMaterials {
595595
// --- Dreamy Night Sky Shader ---
596596
let skyVertexShader;
597597
try {
598-
skyVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.glsl');
598+
skyVertexShader = await this._loadShaderFile('./src/shaders/common/vertex.txt');
599599
console.log('Successfully loaded sky vertex shader');
600600
} catch (error) {
601601
console.error('Failed to load sky vertex shader:', error);
602602
throw error;
603603
}
604604
let skyFragmentShader;
605605
try {
606-
skyFragmentShader = await this._loadShaderFile('./src/shaders/sky_night_dreamy.glsl');
606+
skyFragmentShader = await this._loadShaderFile('./src/shaders/sky_night_dreamy.txt');
607607
console.log('Successfully loaded dreamy night sky fragment shader');
608608
} catch (error) {
609609
console.error('Failed to load dreamy night sky fragment shader:', error);

src/shaders/code_room_floor.txt

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// CODE Room Floor Shader (Tim Rodenbroeker style)
2+
// Generative grid pattern with dynamic highlights based on player position
3+
4+
uniform float time;
5+
uniform vec3 playerPos;
6+
varying vec2 vUv;
7+
8+
// Pattern constants
9+
#define GRID_SIZE 20.0
10+
#define SMALL_GRID_SIZE 4.0
11+
#define LINE_WIDTH 0.03
12+
#define NODE_RADIUS 0.15
13+
#define MAX_NODES 5
14+
15+
// Helper for anti-aliasing
16+
float aastep(float threshold, float value) {
17+
float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;
18+
return smoothstep(threshold-afwidth, threshold+afwidth, value);
19+
}
20+
21+
// Create a grid pattern
22+
float grid(vec2 uv, float size, float lineWidth) {
23+
vec2 grid = fract(uv * size);
24+
vec2 smoothWidth = vec2(lineWidth) / size;
25+
vec2 gridLines = smoothstep(vec2(0.0), smoothWidth, grid) *
26+
(1.0 - smoothstep(vec2(1.0) - smoothWidth, vec2(1.0), grid));
27+
return max(gridLines.x, gridLines.y);
28+
}
29+
30+
// Create a circular node
31+
float node(vec2 uv, vec2 position, float radius) {
32+
float dist = distance(uv, position);
33+
return 1.0 - smoothstep(radius - 0.01, radius, dist);
34+
}
35+
36+
// Generate stable random value
37+
float random(vec2 st) {
38+
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
39+
}
40+
41+
void main() {
42+
// Get normalized UV coordinates
43+
vec2 uv = vUv;
44+
45+
// Create base grid
46+
float mainGrid = grid(uv, GRID_SIZE, LINE_WIDTH);
47+
float subGrid = grid(uv, GRID_SIZE * SMALL_GRID_SIZE, LINE_WIDTH * 0.5);
48+
49+
// Calculate base color from grid
50+
vec3 baseColor = vec3(0.1, 0.1, 0.12);
51+
vec3 gridColor = vec3(0.34, 0.85, 0.53); // green similar to 0x34a853
52+
vec3 color = mix(baseColor, gridColor, mainGrid * 0.7);
53+
color = mix(color, gridColor * 0.7, subGrid * 0.3);
54+
55+
// Add nodes at grid intersections
56+
for (int i = 0; i < MAX_NODES; i++) {
57+
// Stable node positions based on index
58+
float ix = float(i) / float(MAX_NODES);
59+
vec2 nodePos = vec2(
60+
0.1 + 0.8 * fract(sin(ix * 234.5) * 43758.5453123),
61+
0.1 + 0.8 * fract(cos(ix * 598.3) * 13758.5123891)
62+
);
63+
64+
// Make nodes pulse based on time
65+
float pulse = 0.5 + 0.5 * sin(time * (0.5 + ix) + ix * 10.0);
66+
float nodeSize = NODE_RADIUS * (0.7 + 0.3 * pulse);
67+
68+
// Create node and add to color
69+
float nodeValue = node(uv, nodePos, nodeSize);
70+
vec3 nodeColor = mix(
71+
gridColor,
72+
vec3(0.7, 0.9, 0.8),
73+
pulse
74+
);
75+
color = mix(color, nodeColor, nodeValue * pulse);
76+
77+
// Add subtle glow around node
78+
float glowRadius = nodeSize * 3.0;
79+
float glow = (1.0 - smoothstep(nodeSize, glowRadius, distance(uv, nodePos))) * 0.15 * pulse;
80+
color += nodeColor * glow;
81+
}
82+
83+
// Add player highlight effect
84+
vec2 playerUV = playerPos.xz / 20.0 + vec2(0.5); // Convert player position to UV space
85+
float distToPlayer = distance(uv, playerUV);
86+
87+
// Create radial highlight around player position
88+
float playerHighlight = 1.0 - smoothstep(0.0, 0.2, distToPlayer);
89+
color = mix(color, gridColor * 1.5, playerHighlight * 0.3);
90+
91+
// Add subtle ripple effect from player
92+
float ripple = sin(distToPlayer * 20.0 - time * 2.0) * 0.5 + 0.5;
93+
ripple *= smoothstep(0.5, 0.0, distToPlayer); // Fade out with distance
94+
color += gridColor * ripple * 0.15;
95+
96+
// Output final color
97+
gl_FragColor = vec4(color, 1.0);
98+
}

src/shaders/common/vertex.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Common vertex shader for Severance environments
2+
// Used by walls, corridors, and other surfaces
3+
4+
// Varying outputs passed to fragment shader
5+
varying vec3 vNormal;
6+
varying vec2 vUv;
7+
varying vec3 vPosition;
8+
varying vec3 vViewDir;
9+
varying vec4 vWorldPosition;
10+
11+
void main() {
12+
// Pass texture coordinates to fragment shader
13+
vUv = uv;
14+
15+
// Transform normal into view space
16+
vNormal = normalize(normalMatrix * normal);
17+
18+
// Calculate view space position
19+
vPosition = (modelViewMatrix * vec4(position, 1.0)).xyz;
20+
21+
// Calculate view direction (not normalized)
22+
vViewDir = normalize(-vPosition);
23+
24+
// Calculate world position for effects that need it
25+
vWorldPosition = modelMatrix * vec4(position, 1.0);
26+
27+
// Output clip space position
28+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
29+
}

0 commit comments

Comments
 (0)