reze-engine 0.68.32 → 0.69.0

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.
@@ -93,7 +93,7 @@ struct Light { direction: vec4f, color: vec4f, };
93
93
  struct LightUniforms { ambientColor: vec4f, lights: array<Light, 4>, sh: array<vec4f, 9>, };
94
94
  struct GroundShadowMat {
95
95
  diffuseColor: vec3f, fadeStart: f32,
96
- fadeEnd: f32, shadowStrength: f32, _pad6: f32, gridSpacing: f32,
96
+ fadeEnd: f32, shadowStrength: f32, gridPattern: f32, gridSpacing: f32,
97
97
  gridLineWidth: f32, gridLineOpacity: f32, noiseStrength: f32, opacity: f32,
98
98
  gridLineColor: vec3f, mirror: f32,
99
99
  mirrorBlur: f32, _pad17: f32, shadowSoftness: f32, groundY: f32,
@@ -293,10 +293,18 @@ ${pcfWgsl("shadowAtlas", "suv", `${1 / SHADOW_ATLAS_SIZE}`, "compareZ", "acc", "
293
293
  // Grid lines — anti-aliased via screen-space derivatives
294
294
  let gridFrac = abs(fract(gp - 0.5) - 0.5);
295
295
  let halfLine = material.gridLineWidth * 0.5;
296
- let gridLine = 1.0 - min(
296
+ let lines = 1.0 - min(
297
297
  smoothstep(halfLine - gridDeriv.x, halfLine + gridDeriv.x, gridFrac.x),
298
298
  smoothstep(halfLine - gridDeriv.y, halfLine + gridDeriv.y, gridFrac.y)
299
299
  );
300
+ // Dots: one round dot on every crossing the lines would draw, its radius
301
+ // four line widths so the two patterns weigh about the same on the floor.
302
+ // Anti-aliased by the same derivative, so a far dot fades rather than
303
+ // shimmers.
304
+ let dotR = material.gridLineWidth * 4.0;
305
+ let dotAa = max(gridDeriv.x, gridDeriv.y);
306
+ let dots = 1.0 - smoothstep(dotR - dotAa, dotR + dotAa, length(gridFrac));
307
+ let gridLine = select(lines, dots, material.gridPattern > 0.5);
300
308
  let sun = rzWorldAmbient(n) + light.lights[0].color.xyz * light.lights[0].color.w * max(dot(n, -light.lights[0].direction.xyz), 0.0);
301
309
  // The positional layer reaches the floor too. A stage light that lit the
302
310
  // cast and not the ground under her would read as a sticker, which is the
@@ -341,8 +349,12 @@ ${pcfWgsl("shadowAtlas", "suv", `${1 / SHADOW_ATLAS_SIZE}`, "compareZ", "acc", "
341
349
  // reconstruct the reflected image point along the ray from the MIRRORED
342
350
  // eye through this fragment. Mirroring across the floor's own plane is a
343
351
  // sign flip on y about that height (the forward vector is a direction, so
344
- // it flips alone), and the image point's depth below the plane IS the
345
- // reflected object's height above it.
352
+ // it flips alone). From the MIRRORED eye that ray lands on the object
353
+ // itself, ABOVE the plane — the pass drew view × R, which is the real
354
+ // object seen from the mirrored camera — so its height is y − floor.
355
+ // (It read floor − y, the image point's depth below the plane, which is
356
+ // never positive from this eye: every texel took level 0 and the dial
357
+ // did nothing.)
346
358
  let dims = vec2f(textureDimensions(mirrorDepth));
347
359
  let texel = clamp(vec2i(muv * dims), vec2i(0), vec2i(dims) - vec2i(1));
348
360
  let z = textureLoad(mirrorDepth, texel, 0);
@@ -353,7 +365,7 @@ ${pcfWgsl("shadowAtlas", "suv", `${1 / SHADOW_ATLAS_SIZE}`, "compareZ", "acc", "
353
365
  let toFrag = i.worldPos - eyeM;
354
366
  let dir = toFrag * inverseSqrt(max(dot(toFrag, toFrag), 1e-8));
355
367
  let t = viewZ / max(dot(dir, fwdM), 1e-4);
356
- let height = max(material.groundY - (eyeM.y + dir.y * t), 0.0);
368
+ let height = max((eyeM.y + dir.y * t) - material.groundY, 0.0);
357
369
  // Full softness by BLUR_SPAN units above the floor — about a character's
358
370
  // height. The hardware clamps the level, so the nominal 5.0 needs no
359
371
  // knowledge of the real chain length, and blur 0 reads exactly level 0.
@@ -364,7 +376,11 @@ ${pcfWgsl("shadowAtlas", "suv", `${1 / SHADOW_ATLAS_SIZE}`, "compareZ", "acc", "
364
376
  // Still under the received shadow: a polished floor in shade shows a dim
365
377
  // reflection, and a mirror that ignored the shadow would glow in it.
366
378
  reflShadowed = refl.rgb * (1.0 - dark * 0.65);
367
- reflA = textureSampleLevel(mirrorMask, linearSampler, muv, 0.0).g;
379
+ // THE SAME LEVEL as the colour (the placed mirror's rule, mirror.ts): the
380
+ // colour is premultiplied by this coverage, so the two are one quantity in
381
+ // two textures. Coverage read sharp under a blurred colour is a reflection
382
+ // that darkens as the dial comes up, from the first level that spreads.
383
+ reflA = textureSampleLevel(mirrorMask, linearSampler, muv, lod).g;
368
384
  }
369
385
  // THREE LAYERS, composited premultiplied, bottom to top: the shadow the
370
386
  // catcher receives, the ground surface, and the grid.
@@ -374,7 +390,16 @@ ${pcfWgsl("shadowAtlas", "suv", `${1 / SHADOW_ATLAS_SIZE}`, "compareZ", "acc", "
374
390
  // with it — you could not have a bare grid over a photo, which is most of
375
391
  // what a grid is for. It is its own layer now: the ground plane keeps an
376
392
  // alpha, and the grid is simply on or off.
377
- let surfA = edgeFade * material.opacity;
393
+ // FRESNEL over the reflection. A real polished floor is mostly its own
394
+ // colour looking straight down and nearly a mirror toward the horizon
395
+ // (Schlick's falloff, (1 - cos)^5), so where the mirror has something to
396
+ // show, the surface thins as the view grazes. Opacity is therefore the
397
+ // floor's coverage LOOKING STRAIGHT DOWN. Where nothing reflected, and with
398
+ // the mirror off, the surface is untouched: the far floor does not dissolve
399
+ // into an empty target.
400
+ let viewCos = clamp(dot(n, normalize(camera.viewPos - i.worldPos)), 0.0, 1.0);
401
+ let fresnel = pow(1.0 - viewCos, 5.0);
402
+ let surfA = edgeFade * material.opacity * (1.0 - fresnel * material.mirror * reflA);
378
403
  let gridA = gridLine * material.gridLineOpacity * edgeFade;
379
404
  // The mirror covers only what it actually REFLECTS. The backdrop no longer
380
405
  // rides in the reflection target — it clears transparent — so the floor keeps
@@ -392,7 +417,11 @@ ${pcfWgsl("shadowAtlas", "suv", `${1 / SHADOW_ATLAS_SIZE}`, "compareZ", "acc", "
392
417
  // ground surface, grid. Each with its own coverage, none scaling another —
393
418
  // ground opacity REVEALS the mirror rather than the mirror carrying a
394
419
  // strength of its own.
395
- var pm = reflShadowed * mirrA;
420
+ // reflShadowed is ALREADY premultiplied by its coverage (reflA): the HDR
421
+ // target stores colour weighted by its own alpha. So the layer's colour takes
422
+ // the mirror's switch and the fade, not reflA a second time — that squared
423
+ // coverage dimmed every edge, and every pixel once the blur spread it.
424
+ var pm = reflShadowed * material.mirror * edgeFade;
396
425
  var cov = mirrA;
397
426
  // Shadow catcher over the reflection-or-nothing: black, it covers.
398
427
  pm = pm * (1.0 - catchA);