Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Merge main (#1054)

Nguyen Xuan An2107c3624b35
diff --cc packages/render-native/job-input.mjs
index 231143e6,282a4568..34030a4c
--- a/packages/render-native/job-input.mjs
+++ b/packages/render-native/job-input.mjs
@@@ -2,8 -2,9 +2,9 @@@
// FORMAT-v2 material record holds, so the job takes what the tables carry from the tables (a scene that uses nothing else packs
// to the bytes it always did) and lays the rest of the material over it: blend opacity, sheen, specular, anisotropy,
// iridescence, attenuation and the layer textures. A flattened scene and an instanced one go through the same records, so a
- // part looks the same whether or not other geometry in the scene is shared.
- import { buildNativeV1Tables, packNativeMaterialTables } from './pack-input.mjs';
+ // part looks the same whether or not other geometry in the scene is shared. The maps go from the materials into the FORMAT-v2
+ // texture pool without the v1 atlas, so the pool (1 GiB) is the limit on them, not the atlas (4096 x 16384 texels).
-import { buildNativeInput, packNativeMaterialTables, withVirtualAtlas } from './pack-input.mjs';
++import { buildNativeV1Tables, packNativeMaterialTables, withVirtualAtlas } from './pack-input.mjs';
import { buildNativeInputV2, reduceV1MaterialTable, upgradeNativeInputV1ToV2 } from './pack-input-v2.mjs';
const ALL_LIGHT_GROUPS = 0xffffffff;
@@@ -185,6 -188,7 +188,7 @@@ export function buildFlattenedJobNative
const upgradeOptions = {
...(options.samples === undefined ? {} : { samples: options.samples }),
...(options.textureMips === undefined ? {} : { textureMips: options.textureMips }),
+ ...(options.texturePoolMaxBytes === undefined ? {} : { texturePoolMaxBytes: options.texturePoolMaxBytes }),
};
- return upgradeNativeInputV1ToV2(buildNativeV1Tables(scene, camera, options, pack), upgradeOptions, carriedFields, scene.partRayVisibility ?? null);
- return upgradeNativeInputV1ToV2(buildNativeInput(scene, camera, options, withVirtualAtlas(pack)), upgradeOptions, carriedFields);
++ return upgradeNativeInputV1ToV2(buildNativeV1Tables(scene, camera, options, withVirtualAtlas(pack)), upgradeOptions, carriedFields, scene.partRayVisibility ?? null);
}
diff --cc scripts/native-bake-page.js
index 1cd8c26e,4ecb1785..d4b54f82
--- a/scripts/native-bake-page.js
+++ b/scripts/native-bake-page.js
@@@ -84,16 -86,21 +86,26 @@@ export function exportNativeSceneTables
materialsReason = error.message;
}
}
- const input = buildNativeInputOrExplain(buildNativeInput, traceScene, camera, options, pack, materialsReason);
+ if (traceScene.partRayVisibility && !wholeMaterials) {
+ throw new TypeError('A part sets rayVisibility to hide from a ray kind, which only the "cycles" kernel can carry. Use kernel "cycles", or drop the rayVisibility of the part.');
+ }
+ // The v1 tables of the "cycles" job fallback cannot carry visibility: the scene is drawn without it, and the report says so.
+ const visibilityNote = traceScene.partRayVisibility ? { rayVisibility: 'ignored', rayVisibilityReason: materialsReason } : {};
- const input = buildNativeInput({ ...traceScene, partRayVisibility: null }, camera, options, pack);
++ const input = buildNativeInputOrExplain(buildNativeInput, { ...traceScene, partRayVisibility: null }, camera, options, pack, materialsReason);
return { tables: encodeNativeTables(input), triangleCount: input.triangleCount, triangles: traceScene.indices.length / 3, wholeMaterials: false,
- ...(materialsReason === undefined ? {} : { materialsReason }), ...instancingNote };
+ ...(materialsReason === undefined ? {} : { materialsReason }), ...visibilityNote, ...instancingNote };
}
+ // The v1 tables are the fallback for a scene whose FORMAT-v2 materials failed; when they fail too, the error keeps the first reason.
+ function buildNativeInputOrExplain(buildNativeInput, traceScene, camera, options, pack, materialsReason) {
+ try {
+ return buildNativeInput(traceScene, camera, options, pack);
+ } catch (error) {
+ if (materialsReason === undefined || !(error instanceof RangeError)) throw error;
+ throw new RangeError(`${error.message} The FORMAT-v2 export had already failed: ${materialsReason}`);
+ }
+ }
+
// The flattened scene of parts the packer refused as instances. Every copy counts against the bound once flattened, so a scene
// that fitted as instances can be over it; the error then names the packer's refusal, since the geometry was already shared.
function flattenRefusedScene(buildTraceScene, parts, environment, triangleLimit, refusal) {