ugly-game 0.15.70 → 0.15.72
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.
- package/dist/assets/gpuProps.d.ts +3 -0
- package/dist/assets/gpuProps.js +14 -4
- package/package.json +1 -1
|
@@ -145,6 +145,9 @@ export interface PropMesh {
|
|
|
145
145
|
specularIntensity?: number;
|
|
146
146
|
/** Soft grazing-angle fiber reflection, 0..1; default 0. */
|
|
147
147
|
sheen?: number;
|
|
148
|
+
/** Fraction of solar diffuse light transmitted through a thin pigmented sheet
|
|
149
|
+
* (leaf, fin, petal). Keeps opaque depth and visibility. Default 0. */
|
|
150
|
+
diffuseTransmission?: number;
|
|
148
151
|
/** Roughness of the clear lacquer layer; default 0.12. */
|
|
149
152
|
clearcoatRoughness?: number;
|
|
150
153
|
/** Stable fine metallic flake strength; zero disables. */
|
package/dist/assets/gpuProps.js
CHANGED
|
@@ -345,8 +345,14 @@ fn linearToSrgb(c: vec3<f32>) -> vec3<f32> {
|
|
|
345
345
|
if(mtl.maps.x>0.5) {
|
|
346
346
|
let T=cross(py,N)*tx.x+cross(N,px)*ty.x;
|
|
347
347
|
let B=cross(py,N)*tx.y+cross(N,px)*ty.y;
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
// Both derivatives shrink with the pixel footprint. A fixed floor on
|
|
349
|
+
// the frame length erases relief as the camera approaches the surface.
|
|
350
|
+
let frameLength2=max(dot(T,T),dot(B,B));
|
|
351
|
+
if (frameLength2 > 1e-28) {
|
|
352
|
+
let orientation=sign(dot(px,cross(py,N)));
|
|
353
|
+
let gradient=(T*mapN.x+B*mapN.y)*(orientation*inverseSqrt(frameLength2));
|
|
354
|
+
N=normalize(N*mapN.z+gradient*mtl.maps.z);
|
|
355
|
+
}
|
|
350
356
|
}
|
|
351
357
|
let ff = select(1.0, 0.5 + 0.85 * fixedFill(N, u.up.xyz), u.up.w > 0.5); // fixed fill (fall back to flat amb if no up)
|
|
352
358
|
let d = clamp(dot(N, -normalize(u.sun.xyz)), 0.0, 1.0);
|
|
@@ -371,6 +377,9 @@ fn linearToSrgb(c: vec3<f32>) -> vec3<f32> {
|
|
|
371
377
|
if (mtl.mat.z >= 0.0) {
|
|
372
378
|
let V = normalize(u.cam.xyz - i.world);
|
|
373
379
|
let L = -normalize(u.sun.xyz);
|
|
380
|
+
// Thin tissue scatters a share of the key light into the opposite
|
|
381
|
+
// hemisphere. Keep the surface opaque to visibility and retain its shadow.
|
|
382
|
+
if (mtl.optics.z > 0.0 && dot(i.n,V) < 0.0) { N = -N; }
|
|
374
383
|
let H = normalize(L + V);
|
|
375
384
|
let nv = max(dot(N, V), 0.001);
|
|
376
385
|
let nl = max(dot(N, L), 0.0);
|
|
@@ -388,7 +397,8 @@ fn linearToSrgb(c: vec3<f32>) -> vec3<f32> {
|
|
|
388
397
|
+ pearlTint * mtl.paint.z * (0.035 + 0.13*pow(1.0-nv,2.0));
|
|
389
398
|
let F = fresnel(f0, vh);
|
|
390
399
|
let kd = (vec3(1.0)-F) * (1.0-metal);
|
|
391
|
-
let
|
|
400
|
+
let diffuseCosine = mix(nl,max(-dot(N,L),0.0),mtl.optics.z);
|
|
401
|
+
let direct = (kd * albedo * diffuseCosine / 3.14159265 + F * ggx(nh,nv,nl,rough) * nl) * u.sunCol.xyz * sh * 2.5;
|
|
392
402
|
let R = reflect(-V,N);
|
|
393
403
|
let env = environment(R,rough) * mtl.coat.y;
|
|
394
404
|
let reflected = env * fresnel(f0,nv) * (1.0-rough*0.6);
|
|
@@ -1231,7 +1241,7 @@ export class GpuPropsRenderer {
|
|
|
1231
1241
|
0,
|
|
1232
1242
|
Math.max(0, Math.min(1, m.transmission ?? 0)),
|
|
1233
1243
|
m.unlit ? 1 : m.glow ? 2 : 0,
|
|
1234
|
-
0,
|
|
1244
|
+
Math.max(0, Math.min(1, m.diffuseTransmission ?? 0)),
|
|
1235
1245
|
0,
|
|
1236
1246
|
]);
|
|
1237
1247
|
dev.queue.writeBuffer(matBuf, 0, materialValues);
|