Skip to content

Commit f8f2545

Browse files
committed
✨ Add Cyber Descent effect
Implement new cyberpunk city flying effect based on shadertoy This adds a complete WebGL-based effect featuring: - Three visual modes (Standard, Fast Descent, Neon) - Customizable flight speed, fog density, and lighting - Dynamic color controls including saturation adjustment - Interactive neon signs and building windows The implementation follows the modular architecture pattern with separate files for effect logic, types, utilities, and shaders. Fun fact: Cursor can one-shot this with the new rules framework
1 parent 21599f3 commit f8f2545

File tree

7 files changed

+679
-0
lines changed

7 files changed

+679
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* Cyber Descent - Main Effect Class
3+
* Implements the Cyber Descent effect using WebGL
4+
*/
5+
import { WebGLEffect } from "../../common/webgl-effect";
6+
import { CyberDescentControls } from "./types";
7+
import {
8+
getCyberDescentControls,
9+
initializeCyberDescentControls,
10+
} from "./utils";
11+
import * as THREE from "three";
12+
13+
// Import shader code
14+
import fragmentShader from "./fragment.glsl";
15+
16+
/**
17+
* Cyber Descent effect implementation using WebGL/Three.js
18+
*/
19+
export class CyberDescentEffect extends WebGLEffect<CyberDescentControls> {
20+
constructor() {
21+
super({
22+
id: "cyber-descent",
23+
name: "Cyber Descent",
24+
debug: true, // Enable debug mode
25+
fragmentShader,
26+
});
27+
28+
// Add direct console log to verify constructor is called
29+
console.log("👋 CyberDescentEffect constructor called");
30+
}
31+
32+
/**
33+
* Initialize the controls and their default values
34+
*/
35+
protected initializeControls(): void {
36+
console.log("🎛️ Initializing controls");
37+
initializeCyberDescentControls();
38+
}
39+
40+
/**
41+
* Get current control values from global scope
42+
*/
43+
protected getControlValues(): CyberDescentControls {
44+
return getCyberDescentControls();
45+
}
46+
47+
/**
48+
* Apply control values to the effect parameters
49+
*/
50+
protected updateParameters(controls: CyberDescentControls): void {
51+
// Update uniforms is handled by the updateUniforms method
52+
super.updateParameters(controls);
53+
}
54+
55+
/**
56+
* Create the uniforms for the shader
57+
*/
58+
protected createUniforms(): Record<string, THREE.IUniform> {
59+
return {
60+
iSpeed: { value: 1.0 },
61+
iZoom: { value: 1.0 },
62+
iCyberpunkMode: { value: 0 },
63+
iFogDensity: { value: 1.0 },
64+
iLightIntensity: { value: 1.0 },
65+
iColorSaturation: { value: 1.0 },
66+
iColorIntensity: { value: 1.0 },
67+
};
68+
}
69+
70+
/**
71+
* Update the shader uniforms with current control values
72+
*/
73+
protected updateUniforms(controls: CyberDescentControls): void {
74+
if (!this.material) {
75+
this.debug("error", "Material not available for updating uniforms");
76+
return;
77+
}
78+
79+
// Update all uniform values based on controls
80+
this.material.uniforms.iSpeed.value = controls.speed;
81+
this.material.uniforms.iZoom.value = controls.zoom;
82+
this.material.uniforms.iCyberpunkMode.value = controls.cyberpunkMode;
83+
this.material.uniforms.iFogDensity.value = controls.fogDensity;
84+
this.material.uniforms.iLightIntensity.value = controls.lightIntensity;
85+
this.material.uniforms.iColorSaturation.value = controls.colorSaturation;
86+
this.material.uniforms.iColorIntensity.value = controls.colorIntensity;
87+
}
88+
}

0 commit comments

Comments
 (0)