ugly-game 0.15.72 → 0.15.73
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 -1
- package/dist/assets/gpuProps.js +22 -2
- package/package.json +1 -1
|
@@ -150,6 +150,8 @@ export interface PropMesh {
|
|
|
150
150
|
diffuseTransmission?: number;
|
|
151
151
|
/** Roughness of the clear lacquer layer; default 0.12. */
|
|
152
152
|
clearcoatRoughness?: number;
|
|
153
|
+
/** Fraction of the clearcoat's directional-light reflection, 0..1 (default 0). */
|
|
154
|
+
directClearcoat?: number;
|
|
153
155
|
/** Stable fine metallic flake strength; zero disables. */
|
|
154
156
|
metalFlakes?: number;
|
|
155
157
|
/** Flake cells per object-space unit (usually meters). Default 320. */
|
|
@@ -397,7 +399,7 @@ export declare class GpuPropsRenderer {
|
|
|
397
399
|
* model moves to the blended pipeline and out of shadowPass from the next frame, exactly as if
|
|
398
400
|
* `setModels` had been given that alpha; back at 1 it is opaque and casts again.
|
|
399
401
|
*/
|
|
400
|
-
setMaterial(model: number, surface: Pick<PropMesh, 'alpha' | 'roughness' | 'metalness' | 'clearcoat' | 'clearcoatRoughness' | 'reflectionStrength' | 'specularIntensity' | 'metalFlakes' | 'flakeScale' | 'pearlStrength'>): void;
|
|
402
|
+
setMaterial(model: number, surface: Pick<PropMesh, 'alpha' | 'roughness' | 'metalness' | 'clearcoat' | 'clearcoatRoughness' | 'directClearcoat' | 'reflectionStrength' | 'specularIntensity' | 'metalFlakes' | 'flakeScale' | 'pearlStrength'>): void;
|
|
401
403
|
setModels(meshes: PropMesh[]): void;
|
|
402
404
|
/**
|
|
403
405
|
* Group instances by model and upload the per-model instance buffers.
|
package/dist/assets/gpuProps.js
CHANGED
|
@@ -329,6 +329,19 @@ fn ggx(nh: f32, nv: f32, nl: f32, rough: f32) -> f32 {
|
|
|
329
329
|
let G = (nv / max(nv * (1.0-k) + k, 0.0001)) * (nl / max(nl * (1.0-k) + k, 0.0001));
|
|
330
330
|
return D * G / max(4.0 * nv * nl, 0.0001);
|
|
331
331
|
}
|
|
332
|
+
// Smith-GGX for the transparent dielectric layer. Widen the microfacet
|
|
333
|
+
// distribution by the normal variance across one pixel to retain unresolved
|
|
334
|
+
// key-light reflections when a curved surface becomes small on screen.
|
|
335
|
+
fn directCoat(n:vec3<f32>, nh:f32, nv:f32, nl:f32, rough:f32) -> f32 {
|
|
336
|
+
let dx = dpdx(n); let dy = dpdy(n);
|
|
337
|
+
let variance = min(0.18, 0.25*(dot(dx,dx)+dot(dy,dy)));
|
|
338
|
+
let a2 = min(1.0, pow(rough,4.0)+variance);
|
|
339
|
+
let denom = (1.0-nh*nh) + nh*nh*a2;
|
|
340
|
+
let D = a2 / max(3.14159265*denom*denom,1e-12);
|
|
341
|
+
let gv = nl*sqrt(a2+(1.0-a2)*nv*nv);
|
|
342
|
+
let gl = nv*sqrt(a2+(1.0-a2)*nl*nl);
|
|
343
|
+
return nl*D*0.5/max(gv+gl,0.0001);
|
|
344
|
+
}
|
|
332
345
|
fn srgbToLinear(c: vec3<f32>) -> vec3<f32> {
|
|
333
346
|
return select(c / 12.92, pow((c + 0.055) / 1.055, vec3(2.4)), c > vec3(0.04045));
|
|
334
347
|
}
|
|
@@ -413,7 +426,13 @@ fn linearToSrgb(c: vec3<f32>) -> vec3<f32> {
|
|
|
413
426
|
let ao=select(1.0,orm.r,mtl.maps.y>0.5);
|
|
414
427
|
let diffuse = albedo * ambient * skyOcclusion * (1.0-metal)*ao;
|
|
415
428
|
let coatF = fresnel(vec3(0.04),nv) * mtl.coat.x;
|
|
416
|
-
|
|
429
|
+
var coating = environment(R,mtl.surface.z) * coatF * mtl.coat.y;
|
|
430
|
+
if (mtl.optics.w > 0.0 && mtl.coat.x > 0.0) {
|
|
431
|
+
// A wet film reflects the directional key as well as the environment.
|
|
432
|
+
// The key follows incident radiance and receiver shadows in world space.
|
|
433
|
+
let amount = mtl.coat.x*mtl.optics.w*directCoat(N,nh,nv,nl,mtl.surface.z);
|
|
434
|
+
coating += fresnel(vec3<f32>(0.04),vh)*amount*u.sunCol.xyz*sh*2.5;
|
|
435
|
+
}
|
|
417
436
|
// A soft fiber lobe distinguishes woven upholstery from a glossy dielectric.
|
|
418
437
|
// Neutral defaults preserve the existing PBR response in other consumers.
|
|
419
438
|
let sheen = albedo * mtl.surface.y * (u.sunCol.xyz * nl * sh * pow(1.0-vh,5.0)
|
|
@@ -1078,6 +1097,7 @@ export class GpuPropsRenderer {
|
|
|
1078
1097
|
reflectionStrength: 5,
|
|
1079
1098
|
specularIntensity: 12,
|
|
1080
1099
|
clearcoatRoughness: 14,
|
|
1100
|
+
directClearcoat: 23,
|
|
1081
1101
|
metalFlakes: 16,
|
|
1082
1102
|
flakeScale: 17,
|
|
1083
1103
|
pearlStrength: 18,
|
|
@@ -1242,7 +1262,7 @@ export class GpuPropsRenderer {
|
|
|
1242
1262
|
Math.max(0, Math.min(1, m.transmission ?? 0)),
|
|
1243
1263
|
m.unlit ? 1 : m.glow ? 2 : 0,
|
|
1244
1264
|
Math.max(0, Math.min(1, m.diffuseTransmission ?? 0)),
|
|
1245
|
-
0,
|
|
1265
|
+
Math.max(0, Math.min(1, m.directClearcoat ?? 0)),
|
|
1246
1266
|
]);
|
|
1247
1267
|
dev.queue.writeBuffer(matBuf, 0, materialValues);
|
|
1248
1268
|
return {
|