Skip to content

Commit c91dd49

Browse files
author
Parsa Azari
committed
test
1 parent 9c77aec commit c91dd49

7 files changed

Lines changed: 564 additions & 0 deletions

File tree

dist/shaders/code_room_floor.glsl

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+
}

dist/shaders/common/vertex.glsl

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+
}

dist/shaders/corridor.glsl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Corridor shader for Severance environment
2+
// Provides subtle lighting effects and enhances the clinical atmosphere
3+
4+
uniform vec3 lightColor;
5+
uniform float lightIntensity;
6+
uniform vec3 ambientLight;
7+
uniform float time;
8+
9+
varying vec3 vNormal;
10+
varying vec3 vPosition;
11+
varying vec2 vUv;
12+
13+
void main() {
14+
// Calculate normal lighting
15+
vec3 normal = normalize(vNormal);
16+
vec3 viewDir = normalize(-vPosition);
17+
18+
// Calculate basic lighting
19+
float diffuse = max(dot(normal, vec3(0.0, -1.0, 0.0)), 0.0);
20+
21+
// Add flickering effect to simulate fluorescent lighting
22+
float flicker = 1.0 + 0.02 * sin(time * 10.0) * sin(time * 5.0);
23+
24+
// Subtle edge glow effect for that clinical Severance look
25+
float edgeGlow = pow(1.0 - max(dot(normal, viewDir), 0.0), 5.0) * 0.5;
26+
27+
// Calculate final color
28+
vec3 color = ambientLight + (lightColor * lightIntensity * diffuse * flicker);
29+
30+
// Add subtle white-blue tint that's characteristic of the Severance offices
31+
color = mix(color, vec3(0.9, 0.95, 1.0), 0.15);
32+
33+
// Add edge glow effect
34+
color += vec3(0.9, 0.95, 1.0) * edgeGlow;
35+
36+
// Add subtle vignette effect
37+
float vignetteAmount = 0.8;
38+
float vignette = smoothstep(0.0, vignetteAmount, length(vUv - 0.5) * 1.5);
39+
color = mix(color, color * 0.6, vignette);
40+
41+
gl_FragColor = vec4(color, 1.0);
42+
}

dist/shaders/corridor_floor.glsl

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Twin Peaks Lodge-inspired chevron floor shader (Tim Rodenbroeker style)
2+
// Perspective-corrected black and white chevron pattern for corridors
3+
4+
uniform float time;
5+
uniform vec3 playerPos;
6+
varying vec2 vUv;
7+
varying vec4 vWorldPosition;
8+
9+
// Perfect pattern constants
10+
#define CHEVRON_COUNT 10.0 // Increased density for more consistent pattern
11+
#define PERSPECTIVE_CORRECTION 0.85 // Corrects distortion in long corridors
12+
13+
// Anti-aliasing for crisp edges
14+
float smoothPattern(float value) {
15+
float width = fwidth(value) * 0.5;
16+
return smoothstep(0.5 - width, 0.5 + width, value);
17+
}
18+
19+
void main() {
20+
// Use world position for seamless pattern
21+
vec2 uv = vWorldPosition.xz;
22+
23+
// Normalize world coordinates to a reasonable scale for pattern tiling
24+
uv /= 5.0; // Adjust denominator for pattern scale as needed
25+
26+
// Scale UVs for pattern density
27+
uv.x *= CHEVRON_COUNT;
28+
29+
// Create a coordinate system where chevrons are regular regardless of corridor length
30+
float rowHeight = 0.2; // Height of each row as fraction of total height
31+
float y = uv.y / rowHeight;
32+
float row = floor(y);
33+
float fraction = fract(y);
34+
35+
// Alternate chevron direction each row
36+
float direction = mod(row, 2.0) * 2.0 - 1.0; // -1 or 1
37+
float offset = (fraction - 0.5) * 0.8; // Scaling factor for chevron steepness
38+
39+
// Calculate chevron pattern with consistent width-to-height ratio
40+
float chevronX = uv.x + direction * offset;
41+
42+
// Create sharp alternating black/white pattern
43+
float pattern = mod(floor(chevronX), 2.0);
44+
45+
// Anti-alias edges
46+
float patternSmooth = smoothPattern(fract(chevronX));
47+
pattern = mix(pattern, 1.0 - pattern, patternSmooth);
48+
49+
// Define crisp black and white colors
50+
vec3 black = vec3(0.03, 0.03, 0.04);
51+
vec3 white = vec3(0.97, 0.97, 0.97);
52+
53+
// Mix colors based on pattern
54+
vec3 color = mix(black, white, pattern);
55+
56+
// Add subtle glossy highlight near player position (in world coordinates)
57+
float distToPlayer = length((vWorldPosition.xz - playerPos.xz) / 5.0);
58+
float sheen = 0.04 * smoothstep(0.5, 0.0, distToPlayer);
59+
color += vec3(sheen);
60+
61+
// Extremely subtle red tint for the Severance/Twin Peaks mood
62+
color = mix(color, color + vec3(0.03, 0.0, 0.0), 0.05);
63+
64+
gl_FragColor = vec4(color, 1.0);
65+
}

0 commit comments

Comments
 (0)