Upgrade all astral studies with flowing shaders and comparison frames
This commit is contained in:
1 parent
458f4fb5eb
commit
09e5e7e76d
10 files changed
+393
-20
No files matched your search
@@ -36,15 +36,22 @@ shows an exterior awareness point (not an exit); Rope shows reaching/climbing;
|
||||
Roll-Out shows left/right whole-body turns. Physical muscles stay still.
|
||||
Return/recall cues stop the technique. These are guided-imagery illustrations.
|
||||
|
||||
The shared `design/promo-film/three/src/character-shaders.js` provides warm wrapped
|
||||
lighting, a cool Fresnel rim and lightweight subsurface approximation; astral
|
||||
figures use two flowing noise layers, translucent bands, veins and HDR bloom.
|
||||
Pathways and the silver cord reuse ribbon buffers; cord slack decreases with
|
||||
separation. Rope hands alternate two-bone reaches, the torso peels upward,
|
||||
then the double floats and rejoins the physical body on the return cue.
|
||||
Painted Lumi and
|
||||
both Tai Chi teachers use the same palette and alpha-gradient relief shading,
|
||||
preserving their source artwork and premultiplied edges. No new normal textures.
|
||||
The astral studies now use dedicated `src/surfaces.js` GLSL materials: warm
|
||||
wrapped skin lighting with a red backscatter approximation, cool moon rim,
|
||||
small specular highlights and procedural skin variation; the double has
|
||||
three-scale flowing noise, luminous contour bands, Fresnel transparency and
|
||||
an inner travelling pulse. A separate translucent energy field follows the
|
||||
technique: a localized touch sphere, longitudinal current, ascending elevator
|
||||
bands, orbital spin and a shell around the separating/returning double.
|
||||
Ribbons have a luminous core, soft halo, helical detail and travelling packets.
|
||||
The bedroom uses feathered moonlight shafts, drifting dust, woven linen and a
|
||||
soft floor pool. These are inexpensive scattering approximations, not ray-marched
|
||||
volumes. `src/finish.js` adds technique-specific colour separation, tint,
|
||||
vignette and deterministic grain; bloom strength is also tuned per exercise.
|
||||
Cameras, cue times, captions and the underlying technique poses are preserved.
|
||||
|
||||
The earlier shared promo-film shaders still shade painted Lumi and both Tai Chi
|
||||
teachers; this upgrade leaves their source artwork and materials intact.
|
||||
The preview caps render width at 1280px (720px in **Phone** quality), pixel
|
||||
ratio at 1. Static sculpted pieces are merged per material while preserving
|
||||
the arm pivots. No shadow maps or external textures are added. Real phone GPU
|
||||
@@ -61,3 +68,19 @@ boundary, tests controls and captures several cue times in all six exercises,
|
||||
plus exit/return poses, changing animation pixels, highlights pause/scrub,
|
||||
computed styles, portrait framing, reduced-motion autoplay and promo character
|
||||
shader compilation. No audio plays.
|
||||
|
||||
For matching before/after review, preserve the previous six `showcase-*.png`
|
||||
frames and `portrait-rope-1500.png` in `build/astral-compare/before/`, then run:
|
||||
|
||||
```sh
|
||||
ASTRAL_COMPARE=1 build-queue -- node design/astral-projection/three/tools/verify.mjs
|
||||
build-queue -- python3 design/astral-projection/three/tools/compare.py
|
||||
```
|
||||
|
||||
The comparison option renders the same cue seconds and directed camera poses,
|
||||
matching each original's viewport width. It writes seven new captures to
|
||||
`build/astral-compare/after/`. The Pillow comparison tool labels before on the
|
||||
left and after on the right without resizing either source; a taller page is
|
||||
padded below, preserving the complete captions. Results are in
|
||||
`build/astral-compare/side-by-side/`; `comparison.json` records source hashes,
|
||||
cue times, camera names and stage differences. Before files are read only.
|
||||
@@ -19,7 +19,13 @@ export function filament(color, { width = 0.016, segments = 64, opacity = 1 } =
|
||||
const material = new T.ShaderMaterial({
|
||||
uniforms: { time: { value: 0 }, color: { value: color }, opacity: { value: opacity } },
|
||||
vertexShader: 'varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}',
|
||||
fragmentShader: `uniform float time;uniform vec3 color;uniform float opacity;varying vec2 vUv;void main(){float core=pow(1.0-abs(vUv.y*2.0-1.0),1.8);float packet=pow(0.5+0.5*sin(vUv.x*40.0-time*3.0),8.0);gl_FragColor=vec4(color*(0.9+packet*1.8),core*opacity);}`,
|
||||
fragmentShader: `uniform float time;uniform vec3 color;uniform float opacity;varying vec2 vUv;void main(){float crossSection=abs(vUv.y*2.0-1.0);
|
||||
float core=exp(-crossSection*crossSection*35.0);
|
||||
float halo=exp(-crossSection*crossSection*3.5);
|
||||
float packet=pow(0.5+0.5*sin(vUv.x*55.0-time*5.0),12.0);
|
||||
float helix=pow(0.5+0.5*cos(vUv.x*120.0-time*7.0+vUv.y*14.0),8.0);
|
||||
vec3 light=mix(color,vec3(0.88,0.95,1.0),core*0.7);
|
||||
gl_FragColor=vec4(light*(0.9+core*1.5+packet*2.4+helix*0.5),(halo*0.35+core*0.65)*opacity);}`,
|
||||
transparent: true, blending: T.AdditiveBlending, depthWrite: false, side: T.DoubleSide,
|
||||
})
|
||||
const mesh = new T.Mesh(geometry, material)
|
||||
@@ -54,7 +60,10 @@ export function aura(color) {
|
||||
const material = new T.ShaderMaterial({
|
||||
uniforms: { color: { value: color }, time: { value: 0 }, opacity: { value: 0.6 } },
|
||||
vertexShader: 'varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}',
|
||||
fragmentShader: `uniform vec3 color;uniform float time;uniform float opacity;varying vec2 vUv;void main(){float r=length((vUv-0.5)*2.0);float glow=exp(-r*r*5.0)*(1.0-smoothstep(0.5,1.0,r));float ring=exp(-pow((r-0.50-sin(time*1.2)*0.03)*30.0,2.0));gl_FragColor=vec4(color*(0.5+ring),glow*opacity);}`,
|
||||
fragmentShader: `uniform vec3 color;uniform float time;uniform float opacity;varying vec2 vUv;void main(){float r=length((vUv-0.5)*2.0);float glow=exp(-r*r*5.0)*(1.0-smoothstep(0.5,1.0,r));float ring=pow(0.5+0.5*cos(r*45.0-time*3.5),20.0)*exp(-r*2.0);
|
||||
float angle=atan(vUv.y-0.5,vUv.x-0.5);
|
||||
float rays=pow(0.5+0.5*sin(angle*9.0-r*15.0+time),16.0);
|
||||
gl_FragColor=vec4(color*(0.5+ring*2.0)+vec3(0.5,0.7,1.0)*rays*glow,(glow*0.6+ring*0.45+rays*glow*0.25)*opacity);}`,
|
||||
transparent: true, depthWrite: false, blending: T.AdditiveBlending, side: T.DoubleSide,
|
||||
})
|
||||
return new T.Mesh(new T.PlaneGeometry(1, 1), material)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import * as T from 'three'
|
||||
import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js'
|
||||
|
||||
// One full-screen pass. Small radial colour separation stays outside the focus;
|
||||
// grain is deterministic at a session second, so pause and scrubbing are stable.
|
||||
export function createFinish() {
|
||||
return new ShaderPass({
|
||||
uniforms: {
|
||||
tDiffuse: { value: null }, time: { value: 0 },
|
||||
tint: { value: new T.Color('#9ed5ff') }, strength: { value: 0.5 },
|
||||
},
|
||||
vertexShader: `varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}`,
|
||||
fragmentShader: /* glsl */ `
|
||||
uniform sampler2D tDiffuse;
|
||||
uniform float time, strength;
|
||||
uniform vec3 tint;
|
||||
varying vec2 vUv;
|
||||
void main() {
|
||||
vec2 q=vUv-0.5;
|
||||
float radius=dot(q,q);
|
||||
vec2 shift=q*radius*0.008*strength;
|
||||
vec3 c=texture2D(tDiffuse,vUv).rgb;
|
||||
c.r=texture2D(tDiffuse,vUv+shift).r;
|
||||
c.b=texture2D(tDiffuse,vUv-shift).b;
|
||||
c=mix(c,c*vec3(0.84,0.94,1.12),0.26);
|
||||
c+=tint*max(vec3(0.0),vec3(0.12)-c)*0.12;
|
||||
c*=1.0-smoothstep(0.06,0.48,radius)*0.43;
|
||||
float grain=fract(sin(dot(vUv*vec2(1453.0,997.0)+floor(time*24.0),vec2(12.9898,78.233)))*43758.5453)-0.5;
|
||||
c+=grain*0.014;
|
||||
gl_FragColor=vec4(c,1.0);
|
||||
}`,
|
||||
})
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { RenderPass } from 'three/addons/postprocessing/RenderPass.js'
|
||||
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js'
|
||||
import { OutputPass } from 'three/addons/postprocessing/OutputPass.js'
|
||||
import { createExercise } from './scenes.js'
|
||||
import { createFinish } from './finish.js'
|
||||
|
||||
// The existing film server has no CSS MIME entry. Install the stylesheet from
|
||||
// text so this static page works there without changing its shared server.
|
||||
@@ -23,8 +24,11 @@ renderer.info.autoReset = false
|
||||
const composer = new EffectComposer(renderer)
|
||||
const renderPass = new RenderPass(new T.Scene(), new T.Camera())
|
||||
composer.addPass(renderPass)
|
||||
composer.addPass(new UnrealBloomPass(new T.Vector2(640, 360), 0.65, 0.6, 0.9))
|
||||
const bloom = new UnrealBloomPass(new T.Vector2(640, 360), 0.75, 0.55, 0.95)
|
||||
composer.addPass(bloom)
|
||||
composer.addPass(new OutputPass())
|
||||
const finish = createFinish()
|
||||
composer.addPass(finish)
|
||||
const scenes = items.map((item, index) => createExercise(item, index))
|
||||
const picker = document.querySelector('#exercise')
|
||||
const seek = document.querySelector('#seek')
|
||||
@@ -67,6 +71,10 @@ function draw() {
|
||||
state = view.update(time, { directed: document.querySelector('#camera').value === 'directed' })
|
||||
renderPass.scene = view.scene
|
||||
renderPass.camera = view.camera
|
||||
bloom.strength = [0.45, 0.67, 0.62, 0.60, 0.76, 0.68][selected]
|
||||
finish.uniforms.time.value = time
|
||||
finish.uniforms.tint.value.set(colors[selected])
|
||||
finish.uniforms.strength.value = [0.22, 0.5, 0.7, 1.0, 0.65, 0.75][selected]
|
||||
renderer.info.reset()
|
||||
composer.render()
|
||||
seek.value = time
|
||||
|
||||
@@ -8,8 +8,8 @@ export function createRoom(scene, index) {
|
||||
const accent = palette(index)
|
||||
scene.background = new T.Color('#080d1b')
|
||||
scene.fog = new T.FogExp2('#0b1224', 0.027)
|
||||
scene.add(new T.HemisphereLight('#b7c8ed', '#342e39', 1.25))
|
||||
const moonlight = new T.DirectionalLight('#adc8ff', 2.4)
|
||||
scene.add(new T.HemisphereLight('#91a8ce', '#231a25', 0.65))
|
||||
const moonlight = new T.DirectionalLight('#adc8ff', 3.1)
|
||||
moonlight.position.set(-3, 5, -3)
|
||||
scene.add(moonlight)
|
||||
const lampLight = new T.PointLight('#ffd2a0', 17, 9, 2)
|
||||
@@ -17,7 +17,15 @@ export function createRoom(scene, index) {
|
||||
scene.add(lampLight)
|
||||
const wood = new T.MeshStandardMaterial({ color: '#433743', roughness: 0.77 })
|
||||
const wall = new T.MeshStandardMaterial({ color: '#253047', roughness: 1 })
|
||||
const linen = new T.MeshStandardMaterial({ color: '#a5a4b7', roughness: 1 })
|
||||
const linen = new T.MeshStandardMaterial({ color: '#77869e', roughness: 1 })
|
||||
linen.onBeforeCompile = shader => {
|
||||
shader.vertexShader = 'varying vec3 fabricPosition;\n' + shader.vertexShader.replace('#include <begin_vertex>', '#include <begin_vertex>\nfabricPosition = position;')
|
||||
shader.fragmentShader = 'varying vec3 fabricPosition;\n' + shader.fragmentShader.replace('#include <color_fragment>', `#include <color_fragment>
|
||||
float weave=sin(fabricPosition.x*600.0)*sin(fabricPosition.z*600.0);
|
||||
float folds=sin(fabricPosition.z*14.0+sin(fabricPosition.x*9.0))*0.08;
|
||||
diffuseColor.rgb*=0.93+weave*0.025+folds;
|
||||
`)
|
||||
}
|
||||
function box(size, position, material) {
|
||||
const mesh = new T.Mesh(new T.BoxGeometry(...size), material)
|
||||
mesh.position.set(...position)
|
||||
@@ -66,16 +74,54 @@ export function createRoom(scene, index) {
|
||||
seed = (seed * 1664525 + 1013904223) >>> 0
|
||||
return seed / 4294967296
|
||||
}
|
||||
const positions = new Float32Array(200 * 3)
|
||||
for (let n = 0; n < 200; n += 1) positions.set([(random() - 0.5) * 6, 0.4 + random() * 3.6, (random() - 0.5) * 6], n * 3)
|
||||
const positions = new Float32Array(420 * 3)
|
||||
for (let n = 0; n < 420; n += 1) positions.set([(random() - 0.5) * 6, 0.4 + random() * 3.6, (random() - 0.5) * 6], n * 3)
|
||||
const geometry = new T.BufferGeometry()
|
||||
geometry.setAttribute('position', new T.BufferAttribute(positions, 3))
|
||||
const dust = new T.Points(geometry, new T.ShaderMaterial({
|
||||
uniforms: { time: { value: 0 }, color: { value: accent } },
|
||||
vertexShader: `uniform float time;varying float alpha;void main(){vec3 p=position;p.y+=sin(time*0.15+p.x)*0.14;p.x+=sin(time*0.12+p.z)*0.08;vec4 mv=modelViewMatrix*vec4(p,1.0);gl_Position=projectionMatrix*mv;gl_PointSize=clamp(12.0/-mv.z,1.0,4.0);alpha=0.3+0.3*sin(time*0.6+position.y*4.0);}`,
|
||||
vertexShader: `uniform float time;varying float alpha;void main(){vec3 p=position;p.y+=sin(time*0.15+p.x)*0.14;p.x+=sin(time*0.12+p.z)*0.08;vec4 mv=modelViewMatrix*vec4(p,1.0);gl_Position=projectionMatrix*mv;gl_PointSize=clamp(19.0/-mv.z,1.0,5.0);alpha=(0.25+0.25*sin(time*0.6+position.y*4.0))*smoothstep(-3.0,0.0,p.z);}`,
|
||||
fragmentShader: `uniform vec3 color;varying float alpha;void main(){float d=length(gl_PointCoord-0.5);gl_FragColor=vec4(color*1.5,pow(max(0.0,1.0-d*2.0),3.0)*alpha);}`,
|
||||
transparent: true, blending: T.AdditiveBlending, depthWrite: false,
|
||||
}))
|
||||
scene.add(dust)
|
||||
return { update(t) { dust.material.uniforms.time.value = t } }
|
||||
// Layered translucent shafts approximate light scattering without a volume
|
||||
// texture or ray march. The window end and floor end both feather to zero.
|
||||
const shafts = new T.Group()
|
||||
const shaftMaterial = new T.ShaderMaterial({
|
||||
uniforms: { time: { value: 0 } },
|
||||
vertexShader: 'varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}',
|
||||
fragmentShader: `
|
||||
uniform float time;varying vec2 vUv;
|
||||
void main(){
|
||||
float edge=pow(max(0.0,sin(vUv.x*3.14159265)),2.0);
|
||||
float lengthFade=sin(vUv.y*3.14159265);
|
||||
float haze=0.75+0.12*sin(vUv.y*21.0+vUv.x*7.0-time*0.14);
|
||||
float bars=0.6+0.4*pow(0.5+0.5*sin(vUv.x*21.0),3.0);
|
||||
gl_FragColor=vec4(vec3(0.32,0.54,1.0),edge*lengthFade*haze*bars*0.085);
|
||||
}`,
|
||||
transparent: true, depthWrite: false, side: T.DoubleSide, blending: T.AdditiveBlending,
|
||||
})
|
||||
for (let n = 0; n < 4; n += 1) {
|
||||
const shaft = new T.Mesh(new T.PlaneGeometry(1.0, 6.2), shaftMaterial)
|
||||
shaft.position.set(-1.5+n*0.64, 1.8, -1.5+n*0.11)
|
||||
shaft.rotation.set(-0.71, 0, -0.24)
|
||||
shafts.add(shaft)
|
||||
}
|
||||
scene.add(shafts)
|
||||
// Soft moonlight pools ground the bed and contrast the warm skin.
|
||||
const pool = new T.Mesh(new T.PlaneGeometry(4.3, 4.8), new T.ShaderMaterial({
|
||||
vertexShader: 'varying vec2 p;void main(){p=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}',
|
||||
fragmentShader: 'varying vec2 p;void main(){vec2 q=(p-0.5)*2.0;float a=exp(-dot(q,q)*3.0)*(1.0-smoothstep(0.5,1.0,length(q)));gl_FragColor=vec4(0.19,0.39,0.75,a*0.24);}',
|
||||
transparent: true, depthWrite: false, blending: T.AdditiveBlending,
|
||||
}))
|
||||
pool.rotation.x = -Math.PI / 2
|
||||
pool.position.set(0.3, -0.045, 0.7)
|
||||
scene.add(pool)
|
||||
return {
|
||||
update(t) {
|
||||
dust.material.uniforms.time.value = t
|
||||
shaftMaterial.uniforms.time.value = t
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as T from 'three'
|
||||
import { bodyMaterial } from '../../../promo-film/three/src/character-shaders.js'
|
||||
import { studyBodyMaterial as bodyMaterial, energyShell } from './surfaces.js'
|
||||
import { sample } from './timeline.js'
|
||||
import { createFigure } from './figure.js'
|
||||
import { createRoom, palette } from './room.js'
|
||||
@@ -33,6 +33,9 @@ export function createExercise(item, exerciseIndex = 0) {
|
||||
const energy = createFigure(energyMaterial, { astral: true })
|
||||
energy.root.scale.setScalar(1.025)
|
||||
scene.add(physical.root, energy.root)
|
||||
const field = energyShell(accent)
|
||||
field.position.set(0, 0.75, 0)
|
||||
scene.add(field)
|
||||
const focus = aura(accent)
|
||||
focus.rotation.x = -Math.PI / 2
|
||||
scene.add(focus)
|
||||
@@ -103,6 +106,19 @@ export function createExercise(item, exerciseIndex = 0) {
|
||||
const grounded = i === last || kind === 'current' && i >= 11 || kind === 'elevator' && i >= 13
|
||||
const activity = grounded ? 1 - smooth(elapsed / 8) : 1
|
||||
room.update(t)
|
||||
field.visible = !grounded && i > 0 && (kind !== 'spin' || i >= 4) && (kind !== 'elevator' || i >= 6)
|
||||
field.material.uniforms.time.value = t
|
||||
field.material.uniforms.mode.value = kind === 'spin' ? 1 : kind === 'elevator' ? 2 : 0
|
||||
field.material.uniforms.opacity.value = activity * (kind === 'foundation' ? 0.24 : 0.7)
|
||||
field.scale.set(0.62, 0.30, 1.62)
|
||||
field.rotation.y = 0
|
||||
if (kind === 'spin') {
|
||||
field.scale.set(2.55, 1.0, 2.55)
|
||||
field.rotation.y = -t * 0.5
|
||||
}
|
||||
if (kind === 'elevator') {
|
||||
field.scale.set(1.9, 2.6, 1.9)
|
||||
}
|
||||
physical.breathe(t)
|
||||
physicalMaterial.uniforms.time.value = t
|
||||
energyMaterial.uniforms.time.value = t
|
||||
@@ -313,6 +329,14 @@ export function createExercise(item, exerciseIndex = 0) {
|
||||
}, t, 0.6)
|
||||
})
|
||||
}
|
||||
if (kind === 'foundation') {
|
||||
field.position.copy(focus.position)
|
||||
field.scale.setScalar(i <= 4 ? 0.10 : 0.25)
|
||||
} else if (kind === 'rope' || kind === 'roll') {
|
||||
field.position.copy(energy.root.position)
|
||||
field.position.y += 0.12
|
||||
field.visible = energy.root.visible
|
||||
}
|
||||
const now = cameraFrame(kind, i)
|
||||
const before = cameraFrame(kind, Math.max(0, i - 1))
|
||||
const transition = smooth(elapsed / 7)
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import * as T from 'three'
|
||||
|
||||
// Bounded, texture-free value noise shared by the skin and spirit surfaces.
|
||||
export const flowNoise = /* glsl */ `
|
||||
float hash(vec3 p) {
|
||||
p = fract(p * 0.3183099 + vec3(0.1, 0.2, 0.3));
|
||||
p *= 17.0;
|
||||
return fract(p.x * p.y * p.z * (p.x + p.y + p.z));
|
||||
}
|
||||
float noise(vec3 p) {
|
||||
vec3 i = floor(p), f = fract(p);
|
||||
f = f*f*(3.0-2.0*f);
|
||||
return mix(mix(mix(hash(i),hash(i+vec3(1,0,0)),f.x),
|
||||
mix(hash(i+vec3(0,1,0)),hash(i+vec3(1,1,0)),f.x),f.y),
|
||||
mix(mix(hash(i+vec3(0,0,1)),hash(i+vec3(1,0,1)),f.x),
|
||||
mix(hash(i+vec3(0,1,1)),hash(i+vec3(1,1,1)),f.x),f.y),f.z);
|
||||
}
|
||||
float flow(vec3 p) {
|
||||
return noise(p)*0.65 + noise(p*2.03+4.1)*0.25 + noise(p*4.07)*0.1;
|
||||
}
|
||||
`
|
||||
|
||||
export function studyBodyMaterial({ astral = false, accent } = {}) {
|
||||
return new T.ShaderMaterial({
|
||||
uniforms: {
|
||||
accent: { value: accent }, time: { value: 0 }, opacity: { value: 1 },
|
||||
},
|
||||
defines: astral ? { SPIRIT: 1 } : {},
|
||||
vertexShader: /* glsl */ `
|
||||
varying vec3 normalView, eyeView, local, world;
|
||||
void main() {
|
||||
vec4 p = modelViewMatrix * vec4(position, 1.0);
|
||||
normalView = normalMatrix * normal;
|
||||
eyeView = -p.xyz;
|
||||
local = position;
|
||||
world = (modelMatrix * vec4(position, 1.0)).xyz;
|
||||
gl_Position = projectionMatrix * p;
|
||||
}`,
|
||||
fragmentShader: /* glsl */ `
|
||||
uniform vec3 accent;
|
||||
uniform float time, opacity;
|
||||
varying vec3 normalView, eyeView, local, world;
|
||||
${flowNoise}
|
||||
void main() {
|
||||
vec3 n = normalize(normalView), eye = normalize(eyeView);
|
||||
float facing = abs(dot(n, eye));
|
||||
float rim = pow(1.0-facing, 2.3);
|
||||
#ifdef SPIRIT
|
||||
vec3 p = world*3.8 + vec3(time*0.04, -time*0.23, 0.0);
|
||||
float mist = flow(p + flow(p*0.6)*2.0);
|
||||
float contours = pow(0.5+0.5*sin(mist*32.0+world.y*9.0-time*1.6), 14.0);
|
||||
float pulse = exp(-pow((fract(world.y*0.34-time*0.16)-0.5)*9.0, 2.0));
|
||||
vec3 core = mix(vec3(0.12,0.22,0.6), accent, mist);
|
||||
vec3 c = core*(0.45+mist*0.8) + accent*rim*2.7;
|
||||
c += mix(accent,vec3(1.0,0.87,0.66),0.45)*contours*0.85;
|
||||
c += vec3(0.42,0.66,1.0)*pulse*0.5;
|
||||
gl_FragColor = vec4(c, opacity*(0.13+rim*0.6+mist*0.15+contours*0.16));
|
||||
#else
|
||||
vec3 key = normalize(vec3(0.65,0.6,0.9));
|
||||
vec3 moon = normalize(vec3(-0.9,0.4,-0.2));
|
||||
float wrapped = max(0.0,(dot(n,key)+0.38)/1.38);
|
||||
float scatter = pow(max(0.0,dot(-n,key)+0.45),2.0);
|
||||
float spec = pow(max(0.0,dot(n,normalize(key+eye))),42.0);
|
||||
float pores = noise(world*210.0);
|
||||
float skinVariation = flow(world*7.0);
|
||||
vec3 skin = mix(vec3(0.44,0.23,0.16),vec3(0.60,0.34,0.24),skinVariation);
|
||||
vec3 c = skin*(0.25+wrapped*1.25);
|
||||
c += vec3(0.42,0.08,0.035)*scatter;
|
||||
c += vec3(0.22,0.43,0.72)*pow(max(0.0,dot(n,moon)),1.5)*0.65;
|
||||
c += vec3(0.75,0.85,1.0)*rim*0.20;
|
||||
c += vec3(1.0,0.78,0.58)*spec*0.28;
|
||||
c *= 0.97+pores*0.03;
|
||||
gl_FragColor = vec4(c,1.0);
|
||||
#endif
|
||||
#include <tonemapping_fragment>
|
||||
#include <colorspace_fragment>
|
||||
}`,
|
||||
transparent: astral,
|
||||
depthWrite: !astral,
|
||||
side: T.FrontSide,
|
||||
})
|
||||
}
|
||||
|
||||
export function energyShell(accent) {
|
||||
const material = new T.ShaderMaterial({
|
||||
uniforms: { time: { value: 0 }, opacity: { value: 0 }, color: { value: accent }, mode: { value: 0 } },
|
||||
vertexShader: /* glsl */ `
|
||||
varying vec3 p, n, e;
|
||||
void main(){p=position;n=normalMatrix*normal;vec4 v=modelViewMatrix*vec4(position,1.0);e=-v.xyz;gl_Position=projectionMatrix*v;}`,
|
||||
fragmentShader: /* glsl */ `
|
||||
uniform float time, opacity, mode;
|
||||
uniform vec3 color;
|
||||
varying vec3 p,n,e;
|
||||
void main() {
|
||||
float rim=pow(1.0-abs(dot(normalize(n),normalize(e))),2.8);
|
||||
float latitude=mode>1.5 ? p.y*19.0+time*3.5 : p.z*19.0-time*3.5;
|
||||
float longitude=atan(p.y,p.x)*6.0+p.z*11.0-time*2.5;
|
||||
float bands=pow(0.5+0.5*sin(mix(latitude,longitude,mode>0.5 && mode<1.5 ? 1.0 : 0.0)),24.0);
|
||||
float sparks=pow(0.5+0.5*sin(longitude*3.0+latitude),36.0);
|
||||
float a=opacity*(rim*0.18+bands*0.34+sparks*rim*0.7);
|
||||
gl_FragColor=vec4(color*(1.0+bands*1.3)+vec3(0.5,0.7,1.0)*sparks,a);
|
||||
}`,
|
||||
transparent: true, blending: T.AdditiveBlending, depthWrite: false,
|
||||
})
|
||||
return new T.Mesh(new T.SphereGeometry(1, 48, 32), material)
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Label immutable before/after captures without resizing their source pixels."""
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageChops, ImageDraw, ImageFont, ImageStat
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[4]
|
||||
BASE = ROOT / 'build/astral-compare'
|
||||
OUTPUT = BASE / 'side-by-side'
|
||||
OUTPUT.mkdir(exist_ok=True)
|
||||
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 24)
|
||||
results = []
|
||||
for capture in json.loads((BASE / 'after/captures.json').read_text()):
|
||||
name = capture['name'] + '.png'
|
||||
before_path = BASE / 'before' / name
|
||||
after_path = BASE / 'after' / name
|
||||
before = Image.open(before_path).convert('RGB')
|
||||
after = Image.open(after_path).convert('RGB')
|
||||
assert before.width == after.width == capture['width'], name
|
||||
width = before.width
|
||||
height = max(before.height, after.height)
|
||||
comparison = Image.new('RGB', (width * 2, height + 58), '#101728')
|
||||
comparison.paste(before, (0, 58))
|
||||
comparison.paste(after, (width, 58))
|
||||
draw = ImageDraw.Draw(comparison)
|
||||
draw.text((22, 16), 'BEFORE', font=font, fill='#b5c1d0')
|
||||
draw.text((width + 22, 16), 'AFTER · SHADER STUDY', font=font, fill='#a1ecdf')
|
||||
comparison.save(OUTPUT / name)
|
||||
# Same stage crop, excluding the unchanged player and narration. This
|
||||
# detects accidental capture of the old page, not subjective visual quality.
|
||||
crop = (12, 340, width - 12, 780) if width < 650 else (40, 240, width - 40, 745)
|
||||
difference = ImageChops.difference(before.crop(crop), after.crop(crop))
|
||||
mean_change = sum(ImageStat.Stat(difference).mean) / 3
|
||||
assert mean_change > 3, f'Unchanged stage: {name}: {mean_change}'
|
||||
results.append({
|
||||
**capture,
|
||||
'before_sha256': hashlib.sha256(before_path.read_bytes()).hexdigest(),
|
||||
'after_sha256': hashlib.sha256(after_path.read_bytes()).hexdigest(),
|
||||
'stage_mean_channel_change': round(mean_change, 3),
|
||||
'comparison': str((OUTPUT / name).relative_to(ROOT)),
|
||||
})
|
||||
(BASE / 'comparison.json').write_text(json.dumps(results, indent=2) + '\n')
|
||||
print(f'PASS: {len(results)} labelled comparisons; matching widths, cue times and cameras; before originals untouched.')
|
||||
@@ -172,6 +172,43 @@ try {
|
||||
await until('Boolean(window.astral)')
|
||||
assert(!(await evaluate('window.astral.state()')).playing, 'Reduced motion disables autoplay')
|
||||
await cdp('Emulation.setEmulatedMedia', { features: [] })
|
||||
if (process.env.ASTRAL_COMPARE === '1') {
|
||||
const comparison = join(root, 'build/astral-compare')
|
||||
const after = join(comparison, 'after')
|
||||
mkdirSync(after, { recursive: true })
|
||||
const samples = [
|
||||
['showcase-foundation-hand-169', 0, 169],
|
||||
['showcase-current-912', 1, 912],
|
||||
['showcase-elevator-912', 2, 912],
|
||||
['showcase-spin-1012', 3, 1012],
|
||||
['showcase-rope-ascent-1611', 4, 1611.3],
|
||||
['showcase-roll-right', 5, items[5].cues[8].second + 9.5],
|
||||
['portrait-rope-1500', 4, 1500],
|
||||
]
|
||||
const captures = []
|
||||
await cdp('Emulation.setScrollbarsHidden', { hidden: true })
|
||||
for (const [name, n, second] of samples) {
|
||||
// Original screenshots include both scrollbar-width variants. Match
|
||||
// their CSS viewport without stretching either comparison image.
|
||||
const before = readFileSync(join(comparison, 'before', `${name}.png`))
|
||||
const width = before.readUInt32BE(16)
|
||||
await cdp('Emulation.setDeviceMetricsOverride', {
|
||||
width, height: width < 650 ? 844 : 1000,
|
||||
deviceScaleFactor: 1, mobile: width < 650,
|
||||
})
|
||||
await evaluate('window.dispatchEvent(new Event("resize"))')
|
||||
const state = await pose(n, second)
|
||||
assert.equal(state.cue, sample(items[n], second).cue.key)
|
||||
const pixels = await evaluate('window.astral.pixels()')
|
||||
assert(pixels.bright > 300)
|
||||
const { data } = await cdp('Page.captureScreenshot', { format: 'png', captureBeyondViewport: true })
|
||||
writeFileSync(join(after, `${name}.png`), Buffer.from(data, 'base64'))
|
||||
captures.push({ name, second, width, viewName: state.viewName, cue: state.cue, pixels })
|
||||
}
|
||||
writeFileSync(join(after, 'captures.json'), JSON.stringify(captures, null, 2) + '\n')
|
||||
await cdp('Emulation.clearDeviceMetricsOverride')
|
||||
await cdp('Emulation.setScrollbarsHidden', { hidden: false })
|
||||
}
|
||||
// The real promo loads Lumi, the monk and Tibetan woman; shader compile
|
||||
// errors are collected from the WebGL console rather than inferred from source.
|
||||
await cdp('Page.navigate', { url: `http://127.0.0.1:${port}/design/promo-film/three/index.html?t=38&width=960&height=540` })
|
||||
@@ -181,6 +218,7 @@ try {
|
||||
assert.deepEqual(errors, [], 'Browser/GLSL errors')
|
||||
report.result = 'PASS'
|
||||
writeFileSync(join(out, 'verification.json'), JSON.stringify(report, null, 2) + '\n')
|
||||
if (process.env.ASTRAL_COMPARE === '1') writeFileSync(join(root, 'build/astral-compare/after/verification.json'), JSON.stringify(report, null, 2) + '\n')
|
||||
console.log(`PASS: ${report.cueBoundaries} cue boundaries; ${report.frames.length} frames; animation/poses/returns, highlights, controls, portrait, reduced motion and promo shaders. Report: build/astral-threejs/verification.json`)
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify(report.errors), diagnostics.slice(-1500))
|
||||
|
||||
@@ -155,3 +155,44 @@ Private-display frames (local artifacts, not committed):
|
||||
- `build/astral-threejs/showcase-spin-1012.png`
|
||||
- `build/astral-threejs/showcase-rope-ascent-1611.png`
|
||||
- `build/astral-threejs/showcase-roll-right.png`
|
||||
|
||||
## Shader upgrade and before/after review — owner follow-up
|
||||
|
||||
- Implemented dedicated astral-study skin and spirit GLSL surfaces, with wrapped
|
||||
lighting/backscatter, moon rim, restrained skin variation, layered flowing
|
||||
noise, luminous contours and an inner travelling pulse. Added technique-shaped
|
||||
translucent fields: local touch, longitudinal current, ascending descent bands,
|
||||
orbital spin and a field that follows the separating/returning double.
|
||||
- Rebuilt ribbon shading with a bright core, soft halo, helical detail and flow
|
||||
packets for both the current and silver cord. The bedroom now has layered
|
||||
feathered moonlight shafts, more drifting motes, woven linen and a floor pool.
|
||||
A dedicated finishing pass adds restrained chromatic shift, vignette, tint and
|
||||
deterministic grain, with bloom and shift tuned per technique. These are
|
||||
bounded procedural shader approximations; no volume ray march or textures.
|
||||
- Preserved cue timing, captions, original directed-camera poses, hand-over-hand
|
||||
ascent, left/right roll, float and return. The shared promo material remains
|
||||
unchanged by this follow-up. Native app integration and banners still wait.
|
||||
- Final local test: `ASTRAL_COMPARE=1 build-queue -- node
|
||||
design/astral-projection/three/tools/verify.mjs` — PASS, all 88 cue boundaries,
|
||||
32 standard frames and seven additional matched comparison captures. Controls,
|
||||
pause/scrub, highlights, return poses, portrait layout, reduced motion and the
|
||||
actual promo shaders passed; no JavaScript/GLSL errors (favicon 404 excluded).
|
||||
- Comparison local test: `build-queue -- python3
|
||||
design/astral-projection/three/tools/compare.py` — PASS, seven labelled pairs,
|
||||
matched viewport widths and visible stage differences. `before/` is read only;
|
||||
`build/astral-compare/comparison.json` stores source hashes, cue seconds, camera
|
||||
names and pixel differences. Images are joined without resizing; a longer
|
||||
caption/page gets padding below. All seven pairs were visually inspected.
|
||||
- Before: `build/astral-compare/before/`; new captures and report:
|
||||
`build/astral-compare/after/`. Comparison images:
|
||||
- `build/astral-compare/side-by-side/showcase-foundation-hand-169.png`
|
||||
- `build/astral-compare/side-by-side/showcase-current-912.png`
|
||||
- `build/astral-compare/side-by-side/showcase-elevator-912.png`
|
||||
- `build/astral-compare/side-by-side/showcase-spin-1012.png`
|
||||
- `build/astral-compare/side-by-side/showcase-rope-ascent-1611.png`
|
||||
- `build/astral-compare/side-by-side/showcase-roll-right.png`
|
||||
- `build/astral-compare/side-by-side/portrait-rope-1500.png`
|
||||
- Opened the first comparison in native Gwenview; the launch result confirmed
|
||||
`running: true`. The owner can page through all seven. No live desktop pixels
|
||||
were captured and no mouse input was used. Owner acceptance and real phone GPU
|
||||
frame rate remain unverified; the web preview is not installed in Breeze.
|
||||
Reference in new issue
Block a user