Lighting on the GPU in the WebGPU path (t88 phase 2b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 20:01:15 -04:00
co-authored by Claude Opus 5.5
parent fc05146887
commit 31e3005816
11 changed files with 247 additions and 16 deletions
+25
View File
@@ -0,0 +1,25 @@
// Frozen light comparisons, also used by the WebGPU browser regression suite.
window.lightScene = kind => {
const cx = (W / 2) & ~3, cy = (H / 2) & ~3;
window.CAM = [cx, cy];
SET.fog = false; SET.shake = false; SET.cameraLead = false;
SET.daylight = kind === 'fire' ? 0 : 1; SET.ambient = 0.12;
bot.lamp = kind === 'lamp'; weather.next = 1e15; R.rain = 0;
const x0 = Math.max(0,cx-550), x1 = Math.min(W,cx+550);
const y0 = Math.max(0,cy-330), y1 = Math.min(H,cy+330);
for(let y=y0;y<y1;y++) for(let x=x0;x<x1;x++) {
const i=y*W+x;
const cave = x>cx-95 && x<cx+95 && y>cy-38 && y<cy+36;
const opening = kind==='opening' && x>=cx+24 && x<cx+40 && y<cy;
setCell(i, cave || opening || y<cy-100 ? EMPTY : STONE,20,F_NAT);
bgm[i]=part[i]=mach[i]=occ[i]=0; blockP[(y>>2)*BW+(x>>2)]=0;
}
for(let x=x0;x<x1;x++) { surfY[x]=cy-100; dirtY[x]=cy-90; graniteY[x]=cy+100; basaltY[x]=cy+200; }
if(kind==='magma' || kind==='fire') {
for(let y=cy+15;y<cy+23;y++) for(let x=cx-25;x<cx-8;x++) setCell(y*W+x,kind==='magma'?MAGMA:FIRE,kind==='magma'?1450:1100,F_NAT);
}
// A ledge makes occlusion/turning light paths visible around each source.
for(let y=cy-5;y<cy+7;y++) for(let x=cx+12;x<cx+45;x++) setCell(y*W+x,STONE,20,F_NAT);
updateRoof(); buildSky();
};
lightScene('lamp');