Complete 3D metaverse platform with: - Three.js 3D rendering - Cannon.js physics engine - Pointer lock controls - Procedural cityscape - Floating islands - Portal system - Particle effects - WebXR/VR support ready - Multiplayer ready (Socket.io) Features: - First-person controls (WASD + mouse) - Jump and run mechanics - Chat system - Real-time HUD - Loading screen - Responsive design Built with Vite for fast builds and hot reload. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
59 lines
903 B
JavaScript
59 lines
903 B
JavaScript
/**
|
|
* Afterimage shader
|
|
* I created this effect inspired by a demo on codepen:
|
|
* https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1&
|
|
*/
|
|
|
|
const AfterimageShader = {
|
|
|
|
name: 'AfterimageShader',
|
|
|
|
uniforms: {
|
|
|
|
'damp': { value: 0.96 },
|
|
'tOld': { value: null },
|
|
'tNew': { value: null }
|
|
|
|
},
|
|
|
|
vertexShader: /* glsl */`
|
|
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
|
|
vUv = uv;
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
|
|
}`,
|
|
|
|
fragmentShader: /* glsl */`
|
|
|
|
uniform float damp;
|
|
|
|
uniform sampler2D tOld;
|
|
uniform sampler2D tNew;
|
|
|
|
varying vec2 vUv;
|
|
|
|
vec4 when_gt( vec4 x, float y ) {
|
|
|
|
return max( sign( x - y ), 0.0 );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vec4 texelOld = texture2D( tOld, vUv );
|
|
vec4 texelNew = texture2D( tNew, vUv );
|
|
|
|
texelOld *= damp * when_gt( texelOld, 0.1 );
|
|
|
|
gl_FragColor = max(texelNew, texelOld);
|
|
|
|
}`
|
|
|
|
};
|
|
|
|
export { AfterimageShader };
|