Files
lucidia-metaverse/node_modules/three/examples/jsm/shaders/NormalMapShader.js
Alexa Louise 47cf47f624 Initial commit: Lucidia Metaverse
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>
2025-12-22 19:02:56 -06:00

56 lines
995 B
JavaScript

import {
Vector2
} from 'three';
/**
* Normal map shader
* - compute normals from heightmap
*/
const NormalMapShader = {
name: 'NormalMapShader',
uniforms: {
'heightMap': { value: null },
'resolution': { value: new Vector2( 512, 512 ) },
'scale': { value: new Vector2( 1, 1 ) },
'height': { value: 0.05 }
},
vertexShader: /* glsl */`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,
fragmentShader: /* glsl */`
uniform float height;
uniform vec2 resolution;
uniform sampler2D heightMap;
varying vec2 vUv;
void main() {
float val = texture2D( heightMap, vUv ).x;
float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;
float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;
gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );
}`
};
export { NormalMapShader };