feat: daybreak finale turns the contact arrival into a sunrise with a dawn chord
This commit is contained in:
27
src/scene/world/dawn-light.ts
Normal file
27
src/scene/world/dawn-light.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as THREE from 'three';
|
||||
|
||||
/**
|
||||
* END OF SHIFT: first light. A fixed low sun straight down the road throws a
|
||||
* warm rim on the terrain, the district facades and the asphalt as the dawn
|
||||
* rises. Shared uniform (one set for every generation), like the headlight
|
||||
* beam: the environment writes one float per frame, and 0 skips the term.
|
||||
*/
|
||||
export const dawnLightUniforms = {
|
||||
uDawnLight: { value: 0 },
|
||||
};
|
||||
|
||||
/** Toward the sun: low over the horizon, down the road (-z). */
|
||||
const SUN_DIRECTION = new THREE.Vector3(0, 0.2, -1).normalize();
|
||||
|
||||
/** GLSL: dawnRim(normal, toCamera) -> warm light to add (0 when uDawnLight is 0). */
|
||||
export const DAWN_PARS = /* glsl */ `
|
||||
uniform float uDawnLight;
|
||||
vec3 dawnRim(vec3 n, vec3 toCamera) {
|
||||
if (uDawnLight <= 0.0) return vec3(0.0);
|
||||
vec3 sunDir = vec3(${SUN_DIRECTION.x.toFixed(4)}, ${SUN_DIRECTION.y.toFixed(4)}, ${SUN_DIRECTION.z.toFixed(4)});
|
||||
float facing = abs(dot(n, sunDir));
|
||||
float rim = pow(1.0 - abs(dot(n, toCamera)), 2.0);
|
||||
float against = max(0.0, dot(-toCamera, sunDir));
|
||||
return vec3(1.0, 0.6, 0.36) * uDawnLight * (facing * 0.09 + rim * against * 0.24);
|
||||
}
|
||||
`;
|
||||
Reference in New Issue
Block a user