@hypersoniclabs/helix-cli 0.1.27-helix3.604 → 0.1.27-helix3.605
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.
|
@@ -17,5 +17,14 @@ export interface NormalRegion {
|
|
|
17
17
|
* gentle slope into a handful of directions; these come from the float field, so the shader reads a smooth one.
|
|
18
18
|
*/
|
|
19
19
|
export declare function encodeNormalPixels(field: SampleField, region: NormalRegion): Uint8Array;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* One tile's or the coarse layer's normal map as the PNG the source folder and the scene resource both ship.
|
|
22
|
+
*
|
|
23
|
+
* PNG ROW FILTERS ON. A normal map is a smooth gradient, which is exactly what PNG's predictive filters (Sub, Up, Paeth)
|
|
24
|
+
* turn into near-zero residuals; with filtering off, deflate sees the raw bytes and does far worse. On mountainous
|
|
25
|
+
* terrain the difference is large: Pacifica's 2048^2 coarse map is 5.21 MB unfiltered and 3.82 MB filtered (-27%), a
|
|
26
|
+
* 512^2 tile 397 KB -> 234 KB (-41%), ~63 MB of tile normals across the map. Still lossless and deterministic, so the
|
|
27
|
+
* decoded pixels and the runtime are unchanged. The splat maps keep filtering off: they are mostly flat runs, where it
|
|
28
|
+
* measured 4-10% LARGER.
|
|
29
|
+
*/
|
|
21
30
|
export declare function bakeNormalMap(field: SampleField, region: NormalRegion): Promise<TerrainNormalMap>;
|
package/dist/terrain/normals.js
CHANGED
|
@@ -38,13 +38,22 @@ function encodeNormalPixels(field, region) {
|
|
|
38
38
|
}
|
|
39
39
|
return out;
|
|
40
40
|
}
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* One tile's or the coarse layer's normal map as the PNG the source folder and the scene resource both ship.
|
|
43
|
+
*
|
|
44
|
+
* PNG ROW FILTERS ON. A normal map is a smooth gradient, which is exactly what PNG's predictive filters (Sub, Up, Paeth)
|
|
45
|
+
* turn into near-zero residuals; with filtering off, deflate sees the raw bytes and does far worse. On mountainous
|
|
46
|
+
* terrain the difference is large: Pacifica's 2048^2 coarse map is 5.21 MB unfiltered and 3.82 MB filtered (-27%), a
|
|
47
|
+
* 512^2 tile 397 KB -> 234 KB (-41%), ~63 MB of tile normals across the map. Still lossless and deterministic, so the
|
|
48
|
+
* decoded pixels and the runtime are unchanged. The splat maps keep filtering off: they are mostly flat runs, where it
|
|
49
|
+
* measured 4-10% LARGER.
|
|
50
|
+
*/
|
|
42
51
|
async function bakeNormalMap(field, region) {
|
|
43
52
|
const rgb = encodeNormalPixels(field, region);
|
|
44
53
|
const png = await (0, sharp_1.default)(Buffer.from(rgb.buffer, rgb.byteOffset, rgb.byteLength), {
|
|
45
54
|
raw: { width: region.pixels, height: region.pixels, channels: exports.NORMAL_CHANNELS },
|
|
46
55
|
})
|
|
47
|
-
.png({ compressionLevel: 9, adaptiveFiltering:
|
|
56
|
+
.png({ compressionLevel: 9, adaptiveFiltering: true, palette: false })
|
|
48
57
|
.toBuffer();
|
|
49
58
|
return { width: region.pixels, height: region.pixels, png: new Uint8Array(png) };
|
|
50
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normals.js","sourceRoot":"","sources":["../../src/terrain/normals.ts"],"names":[],"mappings":";;;;;;AAuBA,gDAuBC;
|
|
1
|
+
{"version":3,"file":"normals.js","sourceRoot":"","sources":["../../src/terrain/normals.ts"],"names":[],"mappings":";;;;;;AAuBA,gDAuBC;AAYD,sCAQC;AAlED,kDAA0B;AAC1B,iCAAoD;AAEpD,yHAAyH;AAC5G,QAAA,eAAe,GAAG,CAAC,CAAC;AAejC;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,KAAkB,EAAE,MAAoB;IACzE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC5C,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,eAAe,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,MAA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