gputex 0.7.0 → 0.9.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.
- package/README.md +58 -23
- package/dist/index.d.ts +90 -14
- package/dist/index.js +433 -235
- package/dist/testing.js +10 -2
- package/dist/three.d.ts +4 -1
- package/dist/three.js +440 -238
- package/package.json +1 -1
package/dist/testing.js
CHANGED
|
@@ -1610,6 +1610,7 @@ var A3 = MODIFIERS.map((m) => 3 * m[0]);
|
|
|
1610
1610
|
var B3 = MODIFIERS.map((m) => 3 * m[1]);
|
|
1611
1611
|
var THR3 = MODIFIERS.map((m) => 1.5 * (m[0] + m[1]));
|
|
1612
1612
|
var PLANAR_FUDGE = 8;
|
|
1613
|
+
var KAPPA = 0.9;
|
|
1613
1614
|
function fastTableScore(D, t) {
|
|
1614
1615
|
let acc = 0;
|
|
1615
1616
|
for (let i = 0; i < D.length; i++) {
|
|
@@ -1651,6 +1652,8 @@ function encodeFastBlock(px) {
|
|
|
1651
1652
|
];
|
|
1652
1653
|
const qsq = [0, 0, 0, 0];
|
|
1653
1654
|
const qlsq = [0, 0, 0, 0];
|
|
1655
|
+
const sxp = [0, 0, 0];
|
|
1656
|
+
const syp = [0, 0, 0];
|
|
1654
1657
|
for (let k = 0; k < 16; k++) {
|
|
1655
1658
|
const r = px[k * 3];
|
|
1656
1659
|
const g = px[k * 3 + 1];
|
|
@@ -1663,6 +1666,10 @@ function encodeFastBlock(px) {
|
|
|
1663
1666
|
qsum[q][2] += b;
|
|
1664
1667
|
qsq[q] += r * r + g * g + b * b;
|
|
1665
1668
|
qlsq[q] += l * l;
|
|
1669
|
+
for (let c = 0; c < 3; c++) {
|
|
1670
|
+
sxp[c] += (k & 3) * px[k * 3 + c];
|
|
1671
|
+
syp[c] += (k >> 2) * px[k * 3 + c];
|
|
1672
|
+
}
|
|
1666
1673
|
}
|
|
1667
1674
|
const pair = (a, b) => ({
|
|
1668
1675
|
sum: [qsum[a][0] + qsum[b][0], qsum[a][1] + qsum[b][1], qsum[a][2] + qsum[b][2]],
|
|
@@ -1699,13 +1706,14 @@ function encodeFastBlock(px) {
|
|
|
1699
1706
|
const residual = (s) => {
|
|
1700
1707
|
const dotSum = s.sum[0] * s.sum[0] + s.sum[1] * s.sum[1] + s.sum[2] * s.sum[2];
|
|
1701
1708
|
const lsum = s.sum[0] + s.sum[1] + s.sum[2];
|
|
1702
|
-
return s.sq - dotSum / 8 - (s.lsq - lsum * lsum / 8) / 3;
|
|
1709
|
+
return s.sq - dotSum / 8 - KAPPA * (s.lsq - lsum * lsum / 8) / 3;
|
|
1703
1710
|
};
|
|
1704
1711
|
const resA = residual(pair(0, 2)) + residual(pair(1, 3));
|
|
1705
1712
|
const resB = residual(pair(0, 1)) + residual(pair(2, 3));
|
|
1713
|
+
const gray = qsum.every((q) => q[0] === q[1] && q[1] === q[2]) && sxp[0] === sxp[1] && sxp[1] === sxp[2] && syp[0] === syp[1] && syp[1] === syp[2];
|
|
1706
1714
|
let flip;
|
|
1707
1715
|
let cur;
|
|
1708
|
-
if (
|
|
1716
|
+
if (gray) {
|
|
1709
1717
|
const fa = evalFlip(0, pair(0, 2), pair(1, 3));
|
|
1710
1718
|
const fb = evalFlip(1, pair(0, 1), pair(2, 3));
|
|
1711
1719
|
flip = fb.est < fa.est ? 1 : 0;
|
package/dist/three.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompressResult as CompressResult$1, CompressTextureSource, CompressOptions, TextureHint, PreferredFormat, FormatQuality, SvgRasterSize, TextureFormat, Encoder, EncoderImageSource } from './index.js';
|
|
2
|
-
export { ASTC4x4Encoder, ASTC4x4WebGLEncoder, BC1Encoder, BC1WebGLEncoder, BC5Encoder, BC5WebGLEncoder, BC7Encoder, BC7EncoderOptions, BC7WebGLEncoder, Capabilities, ETC2Encoder, EncodeBytesResult, EncodeCallOptions, EncodeMipChainResult, EncodedLevelBytes, EncoderConstructor, EncoderOptions, ExtensionProvider, FeatureProvider, FormatSelection, FormatVariant, MipLevel, RasterizeSvgOptions, RawPixelSource, SelectFormatOptions, WebGLBlockEncoder, WebGLCapabilities, WebGLEncodeBytesResult, WebGLEncoderConstructor, WebGLEncoderImageSource, WebGLEncoderOptions, WebGLFormatSelection, WebGPUFeature, clearTranscodeCache, compressTextureToBytes, createWebGLContext, detectCapabilities, detectWebGLCapabilities, generateGpuMipChain, generateMipChain, getSharedWebGLContext, gpuMipLevelCount, isWebGLAvailable, padToBlockMultiple, rasterizeSvg, releaseSharedGpuResources, selectFormat, selectWebGLFormat, setTranscodeCacheLimit } from './index.js';
|
|
2
|
+
export { ASTC4x4Encoder, ASTC4x4WebGLEncoder, BC1Encoder, BC1WebGLEncoder, BC5Encoder, BC5WebGLEncoder, BC7Encoder, BC7EncoderOptions, BC7WebGLEncoder, Capabilities, ETC2Encoder, ETC2WebGLEncoder, EncodeBytesResult, EncodeCallOptions, EncodeMipChainResult, EncodedLevelBytes, EncoderConstructor, EncoderOptions, ExtensionProvider, FeatureProvider, FormatSelection, FormatVariant, MipLevel, PrewarmResult, PrewarmTarget, RasterizeSvgOptions, RawPixelSource, SelectFormatOptions, WebGLBlockEncoder, WebGLCapabilities, WebGLEncodeBytesResult, WebGLEncoderConstructor, WebGLEncoderImageSource, WebGLEncoderOptions, WebGLFormatSelection, WebGPUFeature, clearTranscodeCache, compressTextureToBytes, createWebGLContext, detectCapabilities, detectWebGLCapabilities, generateGpuMipChain, generateMipChain, getSharedWebGLContext, gpuMipLevelCount, isWebGLAvailable, padToBlockMultiple, prewarmCompressTexture, rasterizeSvg, releaseSharedGpuResources, selectFormat, selectWebGLFormat, setTranscodeCacheLimit } from './index.js';
|
|
3
3
|
import { Texture, CompressedTexture, Loader, CompressedPixelFormat } from 'three';
|
|
4
4
|
|
|
5
5
|
/** A `compressTexture()` result: a ready-to-use texture plus the same encode
|
|
@@ -50,6 +50,9 @@ declare class GputexLoader extends Loader<Texture> {
|
|
|
50
50
|
*/
|
|
51
51
|
device?: GPUDevice;
|
|
52
52
|
adapter?: GPUAdapter;
|
|
53
|
+
/** Encode on the WebGL2 fallback even when WebGPU is available (testing).
|
|
54
|
+
* See `CompressOptions.forceWebGL`. Default false. */
|
|
55
|
+
forceWebGL: boolean;
|
|
53
56
|
/**
|
|
54
57
|
* Most recent full encode result. Useful when the caller wants format
|
|
55
58
|
* / mipLevels / astcNormalRemap metadata without threading a separate
|