@@ -254,7 +254,7 @@ export class SeveranceMaterials {
254
254
"Attempting to load vertex shader from src/shaders/common/vertex.glsl"
255
255
) ;
256
256
commonVertexShader = await this . _loadShaderFile (
257
- "./src/shaders/common/vertex.txt"
257
+ getAssetPath ( "./src/shaders/common/vertex.glsl" )
258
258
) ;
259
259
console . log ( "Successfully loaded vertex shader" ) ;
260
260
} catch ( e ) {
@@ -272,7 +272,7 @@ export class SeveranceMaterials {
272
272
"Attempting to load wall shader from src/shaders/wall.glsl"
273
273
) ;
274
274
wallFragmentShader = await this . _loadShaderFile (
275
- "./src/shaders/wall.txt"
275
+ getAssetPath ( "./src/shaders/wall.glsl" )
276
276
) ;
277
277
console . log ( "Successfully loaded wall shader" ) ;
278
278
console . log (
@@ -288,7 +288,7 @@ export class SeveranceMaterials {
288
288
"Attempting to load wall shader from public/src/shaders/wall.glsl"
289
289
) ;
290
290
wallFragmentShader = await this . _loadShaderFile (
291
- "./public/src/shaders/wall.glsl"
291
+ getAssetPath ( "./public/src/shaders/wall.glsl" )
292
292
) ;
293
293
console . log ( "Successfully loaded wall shader from public path" ) ;
294
294
} catch ( e2 ) {
@@ -304,7 +304,7 @@ export class SeveranceMaterials {
304
304
"Attempting to load corridor shader from src/shaders/corridor.glsl"
305
305
) ;
306
306
corridorFragmentShader = await this . _loadShaderFile (
307
- "./src/shaders/corridor.txt"
307
+ getAssetPath ( "./src/shaders/corridor.glsl" )
308
308
) ;
309
309
console . log ( "Successfully loaded corridor shader" ) ;
310
310
} catch ( e ) {
@@ -316,7 +316,7 @@ export class SeveranceMaterials {
316
316
// Try fallback from /shaders/corridor.glsl (without src prefix)
317
317
try {
318
318
corridorFragmentShader = await this . _loadShaderFile (
319
- "/shaders/corridor.glsl"
319
+ getAssetPath ( "/shaders/corridor.glsl" )
320
320
) ;
321
321
} catch ( e2 ) {
322
322
console . warn ( "Could not load corridor shader from any location" ) ;
@@ -413,241 +413,119 @@ export class SeveranceMaterials {
413
413
try {
414
414
// Load wall shaders
415
415
let wallVertexShader ;
416
- try {
417
- wallVertexShader = await this . _loadShaderFile ( './src/shaders/common/vertex.txt' ) ;
418
- console . log ( 'Successfully loaded wall vertex shader' ) ;
419
- } catch ( error ) {
420
- console . error ( 'Failed to load wall vertex shader:' , error ) ;
421
- throw error ;
422
- }
423
-
424
416
let wallFragmentShader ;
417
+
425
418
try {
426
- wallFragmentShader = await this . _loadShaderFile ( './src/shaders/wall.txt' ) ;
427
- console . log ( 'Successfully loaded wall fragment shader' ) ;
428
- } catch ( error ) {
429
- console . error ( 'Failed to load wall fragment shader:' , error ) ;
430
- throw error ;
431
- }
432
-
433
- // Create wall material with uniforms
434
- const wallMaterial = new THREE . ShaderMaterial ( {
435
- uniforms : {
436
- wallColor : { value : new THREE . Color ( 0xf5f5f5 ) } ,
437
- wallRoughness : { value : 0.85 } ,
438
- time : { value : 0.0 }
439
- } ,
440
- vertexShader : wallVertexShader ,
441
- fragmentShader : wallFragmentShader ,
442
- side : THREE . DoubleSide ,
443
- transparent : false
444
- } ) ;
419
+ wallVertexShader = await this . _loadShaderFile ( getAssetPath ( './src/shaders/common/vertex.glsl' ) ) ;
420
+ wallFragmentShader = await this . _loadShaderFile ( getAssetPath ( './src/shaders/wall.glsl' ) ) ;
421
+ console . log ( 'Successfully loaded wall shaders' ) ;
422
+
423
+ // Create wall material with uniforms
424
+ const wallMaterial = new THREE . ShaderMaterial ( {
425
+ uniforms : {
426
+ wallColor : { value : new THREE . Color ( 0xf5f5f5 ) } ,
427
+ wallRoughness : { value : 0.85 } ,
428
+ time : { value : 0.0 }
429
+ } ,
430
+ vertexShader : wallVertexShader ,
431
+ fragmentShader : wallFragmentShader ,
432
+ side : THREE . DoubleSide ,
433
+ transparent : false
434
+ } ) ;
445
435
446
- // Validate wall shader compilation
447
- if ( ! this . _checkShaderCompilation ( wallMaterial , 'Wall' ) ) {
448
- console . error ( 'Wall shader compilation failed, using fallback material' ) ;
449
- // Create fallback material
450
- const fallbackWallMaterial = new THREE . MeshStandardMaterial ( {
436
+ // Validate wall shader compilation
437
+ if ( ! this . _checkShaderCompilation ( wallMaterial , 'Wall' ) ) {
438
+ throw new Error ( 'Wall shader compilation failed' ) ;
439
+ }
440
+
441
+ this . materials . set ( 'wall' , wallMaterial ) ;
442
+ console . log ( 'Wall shader material created successfully' ) ;
443
+
444
+ } catch ( error ) {
445
+ console . warn ( 'Failed to load wall shaders, using fallback material:' , error ) ;
446
+ this . materials . set ( 'wall' , new THREE . MeshStandardMaterial ( {
451
447
color : 0xf5f5f5 ,
452
448
roughness : 0.85 ,
453
449
metalness : 0.1 ,
454
450
side : THREE . DoubleSide
455
- } ) ;
456
- this . materials . set ( 'wall' , fallbackWallMaterial ) ;
457
- } else {
458
- this . materials . set ( 'wall' , wallMaterial ) ;
459
- console . log ( 'Wall shader material created successfully' ) ;
451
+ } ) ) ;
460
452
}
461
453
462
454
// Load corridor shaders
463
455
let corridorVertexShader ;
464
- try {
465
- corridorVertexShader = await this . _loadShaderFile ( './src/shaders/common/vertex.txt' ) ;
466
- console . log ( 'Successfully loaded corridor vertex shader' ) ;
467
- } catch ( error ) {
468
- console . error ( 'Failed to load corridor vertex shader:' , error ) ;
469
- throw error ;
470
- }
471
-
472
456
let corridorFragmentShader ;
457
+
473
458
try {
474
- corridorFragmentShader = await this . _loadShaderFile ( './src/shaders/corridor.txt' ) ;
475
- console . log ( 'Successfully loaded corridor fragment shader' ) ;
476
- } catch ( error ) {
477
- console . error ( 'Failed to load corridor fragment shader:' , error ) ;
478
- throw error ;
479
- }
480
-
481
- // Create corridor material with uniforms
482
- const corridorMaterial = new THREE . ShaderMaterial ( {
483
- uniforms : {
484
- lightColor : { value : new THREE . Color ( 0xffffff ) } ,
485
- intensity : { value : 1.0 } ,
486
- time : { value : 0.0 }
487
- } ,
488
- vertexShader : corridorVertexShader ,
489
- fragmentShader : corridorFragmentShader ,
490
- transparent : true ,
491
- blending : THREE . AdditiveBlending
492
- } ) ;
459
+ corridorVertexShader = await this . _loadShaderFile ( getAssetPath ( './src/shaders/common/vertex.glsl' ) ) ;
460
+ corridorFragmentShader = await this . _loadShaderFile ( getAssetPath ( './src/shaders/corridor.glsl' ) ) ;
461
+ console . log ( 'Successfully loaded corridor shaders' ) ;
462
+
463
+ // Create corridor material with uniforms
464
+ const corridorMaterial = new THREE . ShaderMaterial ( {
465
+ uniforms : {
466
+ lightColor : { value : new THREE . Color ( 0xffffff ) } ,
467
+ intensity : { value : 1.0 } ,
468
+ time : { value : 0.0 }
469
+ } ,
470
+ vertexShader : corridorVertexShader ,
471
+ fragmentShader : corridorFragmentShader ,
472
+ transparent : true ,
473
+ blending : THREE . AdditiveBlending
474
+ } ) ;
493
475
494
- // Validate corridor shader compilation
495
- if ( ! this . _checkShaderCompilation ( corridorMaterial , 'Corridor' ) ) {
496
- console . error ( 'Corridor shader compilation failed, using fallback material' ) ;
497
- // Create fallback material
498
- const fallbackCorridorMaterial = new THREE . MeshStandardMaterial ( {
476
+ // Validate corridor shader compilation
477
+ if ( ! this . _checkShaderCompilation ( corridorMaterial , 'Corridor' ) ) {
478
+ throw new Error ( 'Corridor shader compilation failed' ) ;
479
+ }
480
+
481
+ this . materials . set ( 'corridor' , corridorMaterial ) ;
482
+ console . log ( 'Corridor shader material created successfully' ) ;
483
+
484
+ } catch ( error ) {
485
+ console . warn ( 'Failed to load corridor shaders, using fallback material:' , error ) ;
486
+ this . materials . set ( 'corridor' , new THREE . MeshStandardMaterial ( {
499
487
color : 0xffffff ,
500
488
emissive : 0xffffff ,
501
489
emissiveIntensity : 0.5 ,
502
490
transparent : true ,
503
491
opacity : 0.5
504
- } ) ;
505
- this . materials . set ( 'corridor' , fallbackCorridorMaterial ) ;
506
- } else {
507
- this . materials . set ( 'corridor' , corridorMaterial ) ;
508
- console . log ( 'Corridor shader material created successfully' ) ;
509
- }
510
-
511
- // --- Add Tim Rodenbröker-inspired corridor wall shader ---
512
- let corridorWallVertexShader ;
513
- try {
514
- corridorWallVertexShader = await this . _loadShaderFile ( './src/shaders/common/vertex.txt' ) ;
515
- console . log ( 'Successfully loaded corridor wall vertex shader' ) ;
516
- } catch ( error ) {
517
- console . error ( 'Failed to load corridor wall vertex shader:' , error ) ;
518
- throw error ;
519
- }
520
- let corridorWallFragmentShader ;
521
- try {
522
- corridorWallFragmentShader = await this . _loadShaderFile ( './src/shaders/corridor_wall.txt' ) ;
523
- console . log ( 'Successfully loaded corridor wall fragment shader' ) ;
524
- } catch ( error ) {
525
- console . error ( 'Failed to load corridor wall fragment shader:' , error ) ;
526
- throw error ;
527
- }
528
- const corridorWallMaterial = new THREE . ShaderMaterial ( {
529
- uniforms : {
530
- u_time : { value : 0.0 } ,
531
- u_resolution : { value : new THREE . Vector2 ( window . innerWidth , window . innerHeight ) } ,
532
- u_mouse : { value : new THREE . Vector2 ( 0.5 , 0.5 ) } ,
533
- u_depth : { value : 1.0 } ,
534
- playerPos : { value : new THREE . Vector3 ( 0 , 0 , 0 ) } ,
535
- wallScale : { value : new THREE . Vector2 ( 1.0 , 1.0 ) } ,
536
- uPrevFrame : { value : null }
537
- } ,
538
- vertexShader : corridorWallVertexShader ,
539
- fragmentShader : corridorWallFragmentShader ,
540
- side : THREE . DoubleSide ,
541
- transparent : false
542
- } ) ;
543
- if ( ! this . _checkShaderCompilation ( corridorWallMaterial , 'CorridorWall' ) ) {
544
- console . error ( 'CorridorWall shader compilation failed, using fallback material' ) ;
545
- this . materials . set ( 'corridorWall' , new THREE . MeshStandardMaterial ( {
546
- color : 0xe10600 ,
547
- roughness : 0.5 ,
548
- metalness : 0.2 ,
549
- side : THREE . DoubleSide
550
492
} ) ) ;
551
- } else {
552
- this . materials . set ( 'corridorWall' , corridorWallMaterial ) ;
553
- console . log ( 'CorridorWall shader material created successfully' ) ;
554
493
}
555
494
556
- // --- Add Twin Peaks-inspired zigzag corridor floor shader ---
557
- let corridorFloorVertexShader ;
558
- try {
559
- corridorFloorVertexShader = await this . _loadShaderFile ( './src/shaders/common/vertex.txt' ) ;
560
- console . log ( 'Successfully loaded corridor floor vertex shader' ) ;
561
- } catch ( error ) {
562
- console . error ( 'Failed to load corridor floor vertex shader:' , error ) ;
563
- throw error ;
564
- }
565
- let corridorFloorFragmentShader ;
566
- try {
567
- corridorFloorFragmentShader = await this . _loadShaderFile ( './src/shaders/corridor_floor.txt' ) ;
568
- console . log ( 'Successfully loaded corridor floor fragment shader' ) ;
569
- } catch ( error ) {
570
- console . error ( 'Failed to load corridor floor fragment shader:' , error ) ;
571
- throw error ;
572
- }
573
- const corridorFloorMaterial = new THREE . ShaderMaterial ( {
574
- uniforms : {
575
- time : { value : 0.0 } ,
576
- playerPos : { value : new THREE . Vector3 ( 0 , 0 , 0 ) }
577
- } ,
578
- vertexShader : corridorFloorVertexShader ,
579
- fragmentShader : corridorFloorFragmentShader ,
580
- side : THREE . FrontSide ,
581
- transparent : false
582
- } ) ;
583
- if ( ! this . _checkShaderCompilation ( corridorFloorMaterial , 'CorridorFloor' ) ) {
584
- console . error ( 'CorridorFloor shader compilation failed, using fallback material' ) ;
585
- this . materials . set ( 'floor' , new THREE . MeshStandardMaterial ( {
586
- color : 0xf0f0f0 ,
587
- roughness : 0.3 ,
588
- metalness : 0.4 ,
589
- side : THREE . FrontSide
590
- } ) ) ;
591
- } else {
592
- this . materials . set ( 'floor' , corridorFloorMaterial ) ;
593
- console . log ( 'CorridorFloor shader material created successfully' ) ;
594
- }
495
+ // Create fallback materials for shaders that don't exist
496
+ console . log ( 'Creating fallback materials for missing shaders...' ) ;
497
+
498
+ // CorridorWall material (Tim Rodenbröker-inspired)
499
+ this . materials . set ( 'corridorWall' , new THREE . MeshStandardMaterial ( {
500
+ color : 0xe10600 ,
501
+ roughness : 0.5 ,
502
+ metalness : 0.2 ,
503
+ side : THREE . DoubleSide
504
+ } ) ) ;
505
+ console . log ( 'Created fallback corridorWall material' ) ;
506
+
507
+ // Floor material (Twin Peaks-inspired)
508
+ this . materials . set ( 'floor' , new THREE . MeshStandardMaterial ( {
509
+ color : 0xf0f0f0 ,
510
+ roughness : 0.3 ,
511
+ metalness : 0.4 ,
512
+ side : THREE . FrontSide
513
+ } ) ) ;
514
+ console . log ( 'Created fallback floor material' ) ;
595
515
596
- // --- Dreamy Night Sky Shader ---
597
- let skyVertexShader ;
598
- try {
599
- skyVertexShader = await this . _loadShaderFile ( './src/shaders/common/vertex.txt' ) ;
600
- console . log ( 'Successfully loaded sky vertex shader' ) ;
601
- } catch ( error ) {
602
- console . error ( 'Failed to load sky vertex shader:' , error ) ;
603
- throw error ;
604
- }
605
- let skyFragmentShader ;
606
- try {
607
- skyFragmentShader = await this . _loadShaderFile ( './src/shaders/sky_night_dreamy.txt' ) ;
608
- console . log ( 'Successfully loaded dreamy night sky fragment shader' ) ;
609
- } catch ( error ) {
610
- console . error ( 'Failed to load dreamy night sky fragment shader:' , error ) ;
611
- throw error ;
612
- }
613
- const skyMaterial = new THREE . ShaderMaterial ( {
614
- uniforms : {
615
- time : { value : 0.0 }
616
- } ,
617
- vertexShader : skyVertexShader ,
618
- fragmentShader : skyFragmentShader ,
619
- side : THREE . DoubleSide ,
620
- transparent : false
621
- } ) ;
622
- if ( ! this . _checkShaderCompilation ( skyMaterial , 'Sky' ) ) {
623
- console . error ( 'Sky shader compilation failed, using fallback material' ) ;
624
- this . materials . set ( 'sky' , new THREE . MeshStandardMaterial ( {
625
- color : 0x7ec0ee ,
626
- metalness : 0.0 ,
627
- roughness : 1.0 ,
628
- side : THREE . DoubleSide
629
- } ) ) ;
630
- } else {
631
- this . materials . set ( 'sky' , skyMaterial ) ;
632
- console . log ( 'Dreamy night sky shader material created successfully' ) ;
633
- }
516
+ // Sky material
517
+ this . materials . set ( 'sky' , new THREE . MeshStandardMaterial ( {
518
+ color : 0x7ec0ee ,
519
+ metalness : 0.0 ,
520
+ roughness : 1.0 ,
521
+ side : THREE . DoubleSide
522
+ } ) ) ;
523
+ console . log ( 'Created fallback sky material' ) ;
634
524
525
+ console . log ( 'Shader material creation complete' ) ;
526
+
635
527
} catch ( error ) {
636
528
console . error ( 'Error creating shader materials:' , error ) ;
637
- // Create fallback materials
638
- this . materials . set ( 'wall' , new THREE . MeshStandardMaterial ( {
639
- color : 0xf5f5f5 ,
640
- roughness : 0.85 ,
641
- metalness : 0.1 ,
642
- side : THREE . DoubleSide
643
- } ) ) ;
644
- this . materials . set ( 'corridor' , new THREE . MeshStandardMaterial ( {
645
- color : 0xffffff ,
646
- emissive : 0xffffff ,
647
- emissiveIntensity : 0.5 ,
648
- transparent : true ,
649
- opacity : 0.5
650
- } ) ) ;
651
529
throw error ;
652
530
}
653
531
}
0 commit comments