ugly-game 0.5.16 → 0.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,7 +107,7 @@ export declare class GpuShadowRenderer {
107
107
  depth: GPUTextureView;
108
108
  w: number;
109
109
  h: number;
110
- }, tint?: [number, number, number, number], extraShadow?: (sp: GPURenderPassEncoder, lightVP: Float32Array) => void, up?: [number, number, number]): void;
110
+ }, tint?: [number, number, number, number], extraShadow?: (sp: GPURenderPassEncoder, lightVP: Float32Array) => void, up?: [number, number, number], linearOut?: boolean): void;
111
111
  /** Read back the last frame's GPU cull result (camera-visible, light-visible). Does its OWN copy+submit so it's
112
112
  * safe to call from a live render loop (no per-frame readback cost, no race with the ongoing frames). IR/tests. */
113
113
  readCullStats(): Promise<{
package/dist/gpuShadow.js CHANGED
@@ -254,6 +254,7 @@ fn fixedFill(N: vec3<f32>, up: vec3<f32>) -> f32 {
254
254
  @fragment fn fs(i: VOut) -> @location(0) vec4<f32> {
255
255
  if (i.emis > 0.5) { // self-glowing effect cube: full-bright, unlit
256
256
  let g = mix(hsv(i.hue), vec3(1.0), 0.4);
257
+ if (cam.up.w > 0.5) { return vec4(g * 2.6, 1.0); } // linear-HDR path: push emissive >1 so it blooms
257
258
  return vec4(pow(clamp(g, vec3(0.0), vec3(1.0)), vec3(0.4545)), 1.0);
258
259
  }
259
260
  let N = normalize(i.nrm);
@@ -287,6 +288,9 @@ fn fixedFill(N: vec3<f32>, up: vec3<f32>) -> f32 {
287
288
  let fill = cam.sun.w * (0.5 + 0.85 * fixedFill(N, cam.up.xyz));
288
289
  let key = cam.sunCol.xyz * ndl * sh; // direct sun (shadowed) — primary light
289
290
  let lit = base * (fill + key) * ao;
291
+ // cam.up.w > 0.5 selects LINEAR-HDR output (unclamped, no gamma) for an HDR pipeline that tonemaps downstream;
292
+ // otherwise the classic gamma-encoded LDR path (all existing consumers). Keeps both looks from one shader.
293
+ if (cam.up.w > 0.5) { return vec4(max(lit, vec3(0.0)), 1.0); }
290
294
  return vec4(pow(clamp(lit, vec3(0.0), vec3(1.0)), vec3(0.4545)), 1.0); // gamma
291
295
  }
292
296
  `;
@@ -602,7 +606,7 @@ export class GpuShadowRenderer {
602
606
  /** camVP/lightVP: column-major Float32Array(16). sunDir: travel direction. Pass `occlusion` (the depth target +
603
607
  * its size) to enable Hi-Z occlusion culling on the camera pass — the renderer rebuilds a coarse Hi-Z from that
604
608
  * depth each frame and the NEXT frame's cull uses it (hole-free: the first frame + any resize skip occlusion). */
605
- frame(enc, colorView, sceneDepth, camVP, lightVP, sunDir, sunCol, ambient, load = false, occlusion, tint = [1, 1, 1, 0], extraShadow, up = [0, 1, 0]) {
609
+ frame(enc, colorView, sceneDepth, camVP, lightVP, sunDir, sunCol, ambient, load = false, occlusion, tint = [1, 1, 1, 0], extraShadow, up = [0, 1, 0], linearOut = false) {
606
610
  this.cam.set(camVP, 0);
607
611
  this.cam.set(lightVP, 16);
608
612
  this.cam[32] = sunDir[0];
@@ -621,6 +625,7 @@ export class GpuShadowRenderer {
621
625
  this.cam[48] = up[0];
622
626
  this.cam[49] = up[1];
623
627
  this.cam[50] = up[2];
628
+ this.cam[51] = linearOut ? 1 : 0; // up.w = linear-HDR output flag
624
629
  this.device.queue.writeBuffer(this.camBuf, 0, this.cam);
625
630
  if (occlusion)
626
631
  this.ensureHiZ(occlusion.w, occlusion.h);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.5.16",
3
+ "version": "0.5.17",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {