feat: replace mesh queries with typed predicates

Amp-Thread-ID: https://ampcode.com/threads/T-019f9d91-77c1-7206-a60f-ed6554ce92ab

Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
Amp
2026-07-28 20:37:44 +00:00
co-authored by heaust
parent c7ffb0543e
commit f6d6af7a17
36 changed files with 2793 additions and 6973 deletions
+37 -14
View File
@@ -94,7 +94,7 @@ const mapValuePaths = (paths, path, source, value) => {
mapValuePaths(paths, `${path}.${key}`, source, value[key]);
};
function parameterValue(raw, schema, nodeId, key) {
function parameterValue(raw, schema, nodeId, key, semanticType) {
if (!exactKeys(raw, ["kind", "value"]) || raw.kind !== schema.type)
fail("AUTHORING_PARAMETER", { nodeId, parameter: key });
const value = raw.value;
@@ -112,13 +112,33 @@ function parameterValue(raw, schema, nodeId, key) {
? typeof value === "boolean"
: schema.type === "vector" || schema.type === "color"
? Array.isArray(value) &&
value.length === (schema.type === "vector" ? 3 : 4) &&
value.length === (semanticType?.startsWith("vec") ? Number(semanticType.at(-1)) : (schema.type === "vector" ? 3 : 4)) &&
value.every(bounded)
: schema.type === "json" && finiteJson(value);
: schema.type === "json" && finiteJson(value) && validSemanticValue(value, semanticType);
if (!valid) fail("AUTHORING_PARAMETER", { nodeId, parameter: key });
return canonical(structuredClone(raw.value));
}
function validSemanticValue(value, type) {
if (!type) return true;
const finiteVector = (candidate, size) =>
Array.isArray(candidate) && candidate.length === size && candidate.every(Number.isFinite);
const vector = /^vec([24])$/.exec(type);
if (vector) return finiteVector(value, Number(vector[1]));
if (type === "u32x16")
return Array.isArray(value) && value.length === 16 &&
value.every((word) => Number.isInteger(word) && word >= 0 && word <= 0xffffffff);
if (type === "local_aabb")
return exactKeys(value, ["min", "max"]) && finiteVector(value.min, 3) && finiteVector(value.max, 3);
const match = /^mat([234])$/.exec(type);
if (match) {
const size = Number(match[1]);
return Array.isArray(value) && value.length === size &&
value.every((column) => finiteVector(column, size));
}
return false;
}
export function adaptFxNodeSnapshot(raw, revision = 1) {
try {
const rootKeys = [
@@ -300,6 +320,7 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
socketDefinition.value,
n.id,
s.key,
input.accepted.types[0],
);
return false;
} catch {
@@ -327,13 +348,16 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
}
if (new Set(n.sockets.map((s) => s.key)).size !== expected.length)
fail("AUTHORING_SOCKET_SET", { nodeId: n.id });
if (n.typeId === "mesh_query") {
parameters.visibleDefault = sockets.get(
`${n.id}:isVisible`,
).defaultValue.value;
parameters.frustumCulledDefault = sockets.get(
`${n.id}:isFrustumCulled`,
).defaultValue.value;
for (const key of Object.keys(descriptor.inputs)) {
const authoredDefault = sockets.get(`${n.id}:${key}`).defaultValue;
if (authoredDefault)
parameters[`${key}Default`] = parameterValue(
authoredDefault,
definition.sockets[key].value,
n.id,
key,
descriptor.inputs[key].accepted.types[0],
);
}
nodes.set(n.id, {
ordinal,
@@ -507,13 +531,12 @@ export function adaptFxNodeSnapshot(raw, revision = 1) {
mapValuePaths(
paths,
`${base}.parameters.${key}`,
item.value.executor.key === "mesh_query" && key.endsWith("Default")
key.endsWith("Default") && Object.hasOwn(descriptors[item.value.executor.key].inputs, key.slice(0, -7))
? {
kind: "input",
nodeId: item.value.id,
input:
key === "visibleDefault" ? "isVisible" : "isFrustumCulled",
socketId: `${item.value.id}:${key === "visibleDefault" ? "isVisible" : "isFrustumCulled"}`,
input: key.slice(0, -7),
socketId: `${item.value.id}:${key.slice(0, -7)}`,
unconnected: true,
}
: parameterSource(
+2 -1
View File
@@ -2,13 +2,14 @@ import { semanticCatalog } from "./catalog.js";
const GROUPS = Object.freeze([
["source", "Source"],
["expression", "Expression"],
["compute", "Compute"],
["cpu_preparation", "CPU preparation"],
["render", "Render / post"],
["frame", "Frame"],
]);
const title = (typeId) => typeId.replaceAll("_", " ");
const title = (typeId) => typeId.replaceAll("_", " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
/** Application-owned, immutable add-node catalog model. */
export const addNodeItems = Object.freeze(
+89 -74
View File
@@ -1,5 +1,5 @@
export const GRAPH_ID = "authored_gpu_culling";
export const CATALOG_VERSION = 7;
export const CATALOG_VERSION = 8;
const exact = (type) => ({ kind: "exact", types: [type] });
const i = (type, required = true, authoringType) => ({
accepted: typeof type === "string" ? exact(type) : type,
@@ -7,6 +7,45 @@ const i = (type, required = true, authoringType) => ({
...(authoringType ? { authoringType } : {}),
});
const o = (type) => ({ type });
const expression = (inputs, outputs) => ({
version: 1,
execution: "expression",
inputs: Object.fromEntries(Object.entries(inputs).map(([name, type]) => [name, i(type, false)])),
outputs: Object.fromEntries(Object.entries(outputs).map(([name, type]) => [name, o(type)])),
parameters: {},
});
const numbered = (prefix, count, type) =>
Object.fromEntries(Array.from({ length: count }, (_, index) => [`${prefix}${index}`, type]));
const expressionCatalog = {
and: expression({ left: "bool", right: "bool" }, { value: "bool" }),
or: expression({ left: "bool", right: "bool" }, { value: "bool" }),
not: expression({ operand: "bool" }, { value: "bool" }),
xor: expression({ left: "bool", right: "bool" }, { value: "bool" }),
xnor: expression({ left: "bool", right: "bool" }, { value: "bool" }),
greater_than_f32: expression({ left: "f32", right: "f32" }, { value: "bool" }),
less_than_f32: expression({ left: "f32", right: "f32" }, { value: "bool" }),
equals_f32: expression({ left: "f32", right: "f32" }, { value: "bool" }),
greater_than_u32: expression({ left: "u32", right: "u32" }, { value: "bool" }),
less_than_u32: expression({ left: "u32", right: "u32" }, { value: "bool" }),
equals_u32: expression({ left: "u32", right: "u32" }, { value: "bool" }),
separate_vec2: expression({ vector: "vec2" }, { x: "f32", y: "f32" }),
combine_vec2: expression({ x: "f32", y: "f32" }, { vector: "vec2" }),
separate_vec3: expression({ vector: "vec3" }, { x: "f32", y: "f32", z: "f32" }),
combine_vec3: expression({ x: "f32", y: "f32", z: "f32" }, { vector: "vec3" }),
separate_vec4: expression({ vector: "vec4" }, { x: "f32", y: "f32", z: "f32", w: "f32" }),
combine_vec4: expression({ x: "f32", y: "f32", z: "f32", w: "f32" }, { vector: "vec4" }),
separate_mat2: expression({ matrix: "mat2" }, numbered("column", 2, "vec2")),
combine_mat2: expression(numbered("column", 2, "vec2"), { matrix: "mat2" }),
separate_mat3: expression({ matrix: "mat3" }, numbered("column", 3, "vec3")),
combine_mat3: expression(numbered("column", 3, "vec3"), { matrix: "mat3" }),
separate_mat4: expression({ matrix: "mat4" }, numbered("column", 4, "vec4")),
combine_mat4: expression(numbered("column", 4, "vec4"), { matrix: "mat4" }),
separate_u32x16: expression({ value: "u32x16" }, numbered("word", 16, "u32")),
combine_u32x16: expression(numbered("word", 16, "u32"), { value: "u32x16" }),
separate_u32_bits: expression({ value: "u32" }, numbered("bit", 32, "bool")),
combine_u32_bits: expression(numbered("bit", 32, "bool"), { value: "u32" }),
separate_local_aabb: expression({ value: "local_aabb" }, { min: "vec3", max: "vec3" }),
};
const texture = {
residency: "transient",
texture: {
@@ -25,17 +64,13 @@ const texture = {
};
export const semanticCatalog = Object.freeze({
mesh: {
version: 1,
version: 2,
execution: "source",
inputs: {},
outputs: {
mesh: o("mesh_data"),
localAabbs: o("local_aabb_buffer"),
isVisible: {
...o("boolean_flag_buffer"),
authoringType: "visibility_flag_buffer",
},
pipelineIndices: o("pipeline_index_stream"),
type: o("u32x16"),
localAabb: o("local_aabb"),
},
parameters: {},
},
@@ -62,54 +97,28 @@ export const semanticCatalog = Object.freeze({
},
},
frustum_cull: {
version: 1,
execution: "compute",
version: 2,
execution: "expression",
inputs: {
mesh: i("mesh_data"),
localAabbs: i("local_aabb_buffer"),
},
outputs: {
isFrustumCulled: {
...o("boolean_flag_buffer"),
authoringType: "frustum_flag_buffer",
},
localAabb: i("local_aabb"),
},
outputs: { isFrustumCulled: o("bool") },
parameters: { cameraSelection: "active" },
},
mesh_query: {
version: 1,
execution: "compute",
inputs: {
mesh: i("mesh_data"),
isVisible: i("boolean_flag_buffer", false, "visibility_flag_buffer"),
isFrustumCulled: i("boolean_flag_buffer", false, "frustum_flag_buffer"),
},
outputs: { draws: o("draw_stream") },
parameters: {
visiblePredicate: "required_true",
frustumCulledPredicate: "required_false",
},
},
pipeline_registry: {
version: 1,
execution: "cpu_preparation",
inputs: { pipelineIndices: i("pipeline_index_stream") },
outputs: { activation: o("pipeline_activation") },
parameters: {},
},
pipeline: {
version: 1,
version: 2,
execution: "render",
inputs: {
mesh: i("mesh_data"),
draws: i("draw_stream"),
activation: i("pipeline_activation"),
predicate: i("bool", false),
colorTarget: i("texture"),
depthTarget: i("texture"),
},
outputs: { color: o("texture"), depth: o("texture") },
parameters: { pipeline: "gltf_standard", depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor: [0.015, 0.02, 0.03, 1] },
},
...expressionCatalog,
fullscreen_copy: {
version: 1,
execution: "render",
@@ -210,13 +219,8 @@ export const socketTypes = Object.fromEntries(
[
"texture",
"mesh_data",
"local_aabb_buffer",
"boolean_flag_buffer",
"pipeline_index_stream",
"draw_stream",
"pipeline_activation",
"visibility_flag_buffer",
"frustum_flag_buffer",
"bool", "f32", "u32", "vec2", "vec3", "vec4",
"mat2", "mat3", "mat4", "u32x16", "local_aabb",
].map((type, index) => [
type,
{
@@ -226,11 +230,6 @@ export const socketTypes = Object.fromEntries(
},
]),
);
socketTypes.boolean_flag_buffer.acceptsFrom = [
"boolean_flag_buffer",
"visibility_flag_buffer",
"frustum_flag_buffer",
];
export const theme = {
background: "#151820",
grid: "#292e3a",
@@ -266,6 +265,7 @@ export const theme = {
export const styles = {
source: { header: "#3977a8" },
compute: { header: "#725a9b" },
expression: { header: "#725a9b" },
cpu_preparation: { header: "#8a6d3b" },
render: { header: "#426b43" },
frame: { header: "#a75d37" },
@@ -283,8 +283,8 @@ const tagged = (kind, value) => ({ kind, value: structuredClone(value) });
const number = (value, minimum, maximum) => ({
type: "number",
default: tagged("number", value),
minimum,
maximum,
...(minimum !== undefined ? { minimum } : {}),
...(maximum !== undefined ? { maximum } : {}),
});
const enumeration = (value, values) => ({
type: "string",
@@ -302,8 +302,38 @@ const color = (value, minimum = 0, maximum = 1) => ({
minimum,
maximum,
});
const vector = (value, minimum, maximum) => ({ type: "vector", default: tagged("vector", value), minimum, maximum });
const vector = (value, minimum, maximum) => ({
type: "vector", default: tagged("vector", value),
...(minimum !== undefined ? { minimum } : {}),
...(maximum !== undefined ? { maximum } : {}),
});
const json = (value) => ({ type: "json", default: tagged("json", value) });
const socketDefault = (type, value) => {
if (type === "bool") return boolean(value);
if (type === "f32") return number(value);
if (type === "u32") return { ...number(value, 0, 0xffffffff), integer: true };
if (type === "vec3") return vector(value);
return json(value);
};
const zero = (type) => {
if (type === "bool") return false;
if (type === "f32" || type === "u32") return 0;
if (/^vec[234]$/.test(type)) return Array(Number(type.at(-1))).fill(0);
if (type === "u32x16") return Array(16).fill(0);
if (type === "local_aabb") return { min: [0, 0, 0], max: [0, 0, 0] };
const size = Number(type.at(-1));
return Array.from({ length: size }, (_, column) =>
Array.from({ length: size }, (_, row) => Number(column === row)));
};
const defaultForInput = (key, name, type) => {
if (key === "pipeline" && name === "predicate") return true;
if (key === "and") return true;
if (/^combine_mat[234]$/.test(key)) {
const index = Number(name.replace("column", ""));
return zero(type).map((_, row) => Number(index === row));
}
return zero(type);
};
const parameterSchemas = {
texture: {
residency: enumeration("transient", ["transient", "persistent"]),
@@ -343,19 +373,6 @@ const parameterSchemas = {
},
mesh: {},
frustum_cull: { cameraSelection: enumeration("active", ["active"]) },
mesh_query: {
visiblePredicate: enumeration("required_true", [
"any",
"required_true",
"required_false",
]),
frustumCulledPredicate: enumeration("required_false", [
"any",
"required_true",
"required_false",
]),
},
pipeline_registry: {},
pipeline: {
pipeline: string("gltf_standard"),
depthCompare: enumeration("less_equal", [
@@ -399,6 +416,7 @@ const parameterSchemas = {
backgroundColor: color([0, 0, 0, 1]),
},
};
for (const key of Object.keys(expressionCatalog)) parameterSchemas[key] = {};
export const nodeDefinitions = Object.fromEntries(
Object.entries(semanticCatalog).map(([key, c]) => {
const sockets = {
@@ -409,11 +427,7 @@ export const nodeDefinitions = Object.fromEntries(
n,
"input",
v.authoringType ?? v.accepted.types[0],
key === "mesh_query" && n === "isVisible"
? boolean(true)
: key === "mesh_query" && n === "isFrustumCulled"
? boolean(false)
: null,
!v.required ? socketDefault(v.accepted.types[0], defaultForInput(key, n, v.accepted.types[0])) : null,
),
]),
),
@@ -458,6 +472,7 @@ export const nodeDefinitions = Object.fromEntries(
];
}),
);
nodeDefinitions.mesh.sockets.localAabb.title = "Local AABB";
nodeDefinitions.color_balance.ui = [
{ kind: "parameter", parameter: "mode" },
{ kind: "widget", widget: "grading-wheels", bindings: [
+43 -39
View File
@@ -3,19 +3,8 @@ import { CATALOG_VERSION, GRAPH_ID, fxNodeComposition } from "./catalog.js";
import { prepareBrowserHost } from "./browser-host.js";
import { createAddNodeMenu } from "./add-node-menu.js";
import { createNodeIdAllocator, spawnRequestedNode } from "./node-spawn.js";
import { culling } from "./presets.js";
const spec = [
["hdr", "texture", { x: 40, y: 170 }],
["depth", "texture", { x: 40, y: 300 }],
["mesh", "mesh", { x: 40, y: 470 }],
["cull", "frustum_cull", { x: 540, y: 480 }],
["query", "mesh_query", { x: 790, y: 330 }],
["registry", "pipeline_registry", { x: 790, y: 620 }],
["ground", "pipeline", { x: 1040, y: 290 }],
["pbr", "pipeline", { x: 1300, y: 290 }],
["pbr_double", "pipeline", { x: 1560, y: 290 }],
["frame_out", "frame_out", { x: 1820, y: 250 }],
];
async function seed(root) {
await root.setState({
graphId: GRAPH_ID,
@@ -24,28 +13,11 @@ async function seed(root) {
links: [],
metadata: {},
});
for (const [nodeId, nodeType, position] of spec)
await root.dispatch({ type: "node.add", nodeId, nodeType, position });
const links = [
["mesh", "mesh", "cull", "mesh"],
["mesh", "localAabbs", "cull", "localAabbs"],
["mesh", "mesh", "query", "mesh"],
["mesh", "isVisible", "query", "isVisible"],
["cull", "isFrustumCulled", "query", "isFrustumCulled"],
["mesh", "pipelineIndices", "registry", "pipelineIndices"],
...["ground", "pbr", "pbr_double"].flatMap((pipeline) => [
["mesh", "mesh", pipeline, "mesh"],
["query", "draws", pipeline, "draws"],
["registry", "activation", pipeline, "activation"],
]),
["hdr", "texture", "ground", "colorTarget"],
["depth", "texture", "ground", "depthTarget"],
["ground", "color", "pbr", "colorTarget"],
["ground", "depth", "pbr", "depthTarget"],
["pbr", "color", "pbr_double", "colorTarget"],
["pbr", "depth", "pbr_double", "depthTarget"],
["pbr_double", "color", "frame_out", "color"],
];
for (const [index, item] of culling.nodes.entries())
await root.dispatch({ type: "node.add", nodeId: item.id, nodeType: item.executor.key,
position: { x: 40 + (index % 6) * 280, y: 120 + Math.floor(index / 6) * 260 } });
const links = culling.nodes.flatMap((item) => Object.entries(item.inputs).map(([socket, from]) =>
[from.node, from.socket, item.id, socket]));
for (const [a, as, b, bs] of links) {
const id = `${a}_${as}_${b}_${bs}`;
await root.dispatch({
@@ -61,11 +33,43 @@ async function seed(root) {
},
});
}
const authored = await root.getState(),
depth = authored.nodes.find((node) => node.id === "depth");
depth.parameters.format = { kind: "string", value: "depth32_float" };
for (const [id, name] of [["ground", "ground_plane"], ["pbr", "gltf_standard"], ["pbr_double", "gltf_standard_double_sided"]])
authored.nodes.find((node) => node.id === id).parameters.pipeline = { kind: "string", value: name };
const authored = await root.getState();
for (const item of culling.nodes) {
const target = authored.nodes.find((candidate) => candidate.id === item.id);
if (item.executor.key === "texture") {
const texture = item.parameters.texture;
const relative = texture.extent.kind === "surface_relative";
const values = {
residency: item.parameters.residency,
format: texture.format,
dimension: texture.dimension,
extentMode: texture.extent.kind,
absoluteWidth: relative ? 1 : texture.extent.width,
absoluteHeight: relative ? 1 : texture.extent.height,
relativeWidthNumerator: relative ? texture.extent.width.numerator : 1,
relativeWidthDenominator: relative ? texture.extent.width.denominator : 1,
relativeHeightNumerator: relative ? texture.extent.height.numerator : 1,
relativeHeightDenominator: relative ? texture.extent.height.denominator : 1,
depthOrArrayLayers: texture.extent.depthOrArrayLayers,
mipLevelCount: texture.mipLevelCount,
sampleCount: String(texture.sampleCount),
viewFormat: texture.viewFormats[0] ?? "none",
};
for (const [key, value] of Object.entries(values))
target.parameters[key].value = structuredClone(value);
continue;
}
for (const [key, value] of Object.entries(item.parameters)) {
const input = key.endsWith("Default") ? key.slice(0, -7) : null;
if (input) {
const socket = target.sockets.find((candidate) => candidate.key === input);
if (socket?.defaultValue) socket.defaultValue.value = structuredClone(value);
} else {
const authoredKey = item.executor.key === "frustum_cull" && key === "camera" ? "cameraSelection" : key;
if (target.parameters[authoredKey]) target.parameters[authoredKey].value = structuredClone(value);
}
}
}
await root.setState(authored);
}
export async function createRenderGraphEditor(canvas) {
+28 -12
View File
@@ -13,16 +13,37 @@ const texture = (format, scale = 1, heightScale = scale) => ({
residency: "transient",
});
const frameOut = (hdr, options = {}) => ({ surfaceFormat: "preferred", hdrEnabled: hdr, toneMapper: "aces", exposureStops: 0, outputTransfer: "srgb", scaleMode: "stretch", filter: "linear", backgroundColor: [0, 0, 0, 1], ...options });
const scene = (colorTarget, clearColor = [0.015, 0.02, 0.03, 1], heightScale = 1) => [
const predicates = (withCulling = false) => {
const result = [
node("type_words", "separate_u32x16", { valueDefault: Array(16).fill(0) }, { value: input("mesh", "type") }),
node("type_bits", "separate_u32_bits", { valueDefault: 0 }, { value: input("type_words", "word0") }),
node("ground_class", "and", { leftDefault: true, rightDefault: true }, { left: input("type_bits", "bit0"), right: input("type_bits", "bit1") }),
node("visible_pbr", "and", { leftDefault: true, rightDefault: true }, { left: input("type_bits", "bit0"), right: input("type_bits", "bit2") }),
node("not_double", "not", { operandDefault: false }, { operand: input("type_bits", "bit3") }),
node("standard_class", "and", { leftDefault: true, rightDefault: true }, { left: input("visible_pbr", "value"), right: input("not_double", "value") }),
node("double_class", "and", { leftDefault: true, rightDefault: true }, { left: input("type_bits", "bit0"), right: input("type_bits", "bit3") }),
];
if (!withCulling) return { nodes: result, classes: { ground: "ground_class", pbr: "standard_class", pbr_double: "double_class" } };
result.push(
node("cull", "frustum_cull", { camera: "active" }, { mesh: input("mesh", "mesh"), localAabb: input("mesh", "localAabb") }),
node("not_culled", "not", { operandDefault: false }, { operand: input("cull", "isFrustumCulled") }),
...[["ground", "ground_class"], ["pbr", "standard_class"], ["pbr_double", "double_class"]].map(([name, classification]) =>
node(`${name}_final`, "and", { leftDefault: true, rightDefault: true }, { left: input(classification, "value"), right: input("not_culled", "value") })),
);
return { nodes: result, classes: { ground: "ground_final", pbr: "pbr_final", pbr_double: "pbr_double_final" } };
};
const scene = (colorTarget, clearColor = [0.015, 0.02, 0.03, 1], heightScale = 1, withCulling = false) => {
const classification = predicates(withCulling);
return [
node("hdr", "texture", texture("rgba16_float", 1, heightScale)),
node("depth", "texture", texture("depth32_float", 1, heightScale)),
node("mesh", "mesh"),
node("query", "mesh_query", { visiblePredicate: "required_true", visibleDefault: true, frustumCulledPredicate: "any", frustumCulledDefault: false }, { mesh: input("mesh", "mesh"), isVisible: input("mesh", "isVisible") }),
node("registry", "pipeline_registry", {}, { pipelineIndices: input("mesh", "pipelineIndices") }),
node("ground", "pipeline", { pipeline: "ground_plane", depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor }, { mesh: input("mesh", "mesh"), draws: input("query", "draws"), activation: input("registry", "activation"), colorTarget: input(colorTarget, "texture"), depthTarget: input("depth", "texture") }),
node("pbr", "pipeline", { pipeline: "gltf_standard", depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor }, { mesh: input("mesh", "mesh"), draws: input("query", "draws"), activation: input("registry", "activation"), colorTarget: input("ground", "color"), depthTarget: input("ground", "depth") }),
node("pbr_double", "pipeline", { pipeline: "gltf_standard_double_sided", depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor }, { mesh: input("mesh", "mesh"), draws: input("query", "draws"), activation: input("registry", "activation"), colorTarget: input("pbr", "color"), depthTarget: input("pbr", "depth") }),
...classification.nodes,
node("ground", "pipeline", { pipeline: "ground_plane", depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.ground, "value"), colorTarget: input(colorTarget, "texture"), depthTarget: input("depth", "texture") }),
node("pbr", "pipeline", { pipeline: "gltf_standard", depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.pbr, "value"), colorTarget: input("ground", "color"), depthTarget: input("ground", "depth") }),
node("pbr_double", "pipeline", { pipeline: "gltf_standard_double_sided", depthCompare: "less_equal", depthWriteEnabled: true, clearDepth: 1, clearColor, predicateDefault: true }, { mesh: input("mesh", "mesh"), predicate: input(classification.classes.pbr_double, "value"), colorTarget: input("pbr", "color"), depthTarget: input("pbr", "depth") }),
];
};
const graph = (graphId, nodes) => Object.freeze({ schemaVersion: 2, graphId, revision: 1, nodes });
const direct = (graphId, clearColor) => graph(graphId, [
node("ldr", "texture", texture("rgba8_unorm")),
@@ -36,12 +57,7 @@ export const hdr = graph("preset_hdr_fullscreen", [
node("frame_out", "frame_out", frameOut(true), { color: input("pbr_double", "color") }),
]);
export const culling = graph("preset_gpu_culling", (() => {
const nodes = structuredClone(hdr.nodes);
nodes.splice(3, 0, node("cull", "frustum_cull", { camera: "active" }, { mesh: input("mesh", "mesh"), localAabbs: input("mesh", "localAabbs") }));
const query = nodes.find((item) => item.id === "query");
query.parameters.frustumCulledPredicate = "required_false";
query.inputs.isFrustumCulled = input("cull", "isFrustumCulled");
return nodes;
return [...scene("hdr", undefined, 1, true), node("frame_out", "frame_out", frameOut(true), { color: input("pbr_double", "color") })];
})());
const postPreset = (graphId, kind) => {
const nodes = [...scene("hdr")];