feat: synthesize default graph attachments
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:
@@ -1,10 +1,11 @@
|
||||
export const GRAPH_ID = "authored_gpu_culling";
|
||||
export const CATALOG_VERSION = 8;
|
||||
export const CATALOG_VERSION = 9;
|
||||
const exact = (type) => ({ kind: "exact", types: [type] });
|
||||
const i = (type, required = true, authoringType) => ({
|
||||
const i = (type, required = true, authoringType, defaultPolicy = required ? "none" : "parameter_literal") => ({
|
||||
accepted: typeof type === "string" ? exact(type) : type,
|
||||
required,
|
||||
...(authoringType ? { authoringType } : {}),
|
||||
defaultPolicy,
|
||||
});
|
||||
const o = (type) => ({ type });
|
||||
const expression = (inputs, outputs) => ({
|
||||
@@ -107,13 +108,13 @@ export const semanticCatalog = Object.freeze({
|
||||
parameters: { cameraSelection: "active" },
|
||||
},
|
||||
pipeline: {
|
||||
version: 2,
|
||||
version: 3,
|
||||
execution: "render",
|
||||
inputs: {
|
||||
mesh: i("mesh_data"),
|
||||
predicate: i("bool", false),
|
||||
colorTarget: i("texture"),
|
||||
depthTarget: i("texture"),
|
||||
colorTarget: i("texture", false, undefined, "compiler_texture"),
|
||||
depthTarget: i("texture", false, undefined, "compiler_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] },
|
||||
@@ -427,7 +428,7 @@ export const nodeDefinitions = Object.fromEntries(
|
||||
n,
|
||||
"input",
|
||||
v.authoringType ?? v.accepted.types[0],
|
||||
!v.required ? socketDefault(v.accepted.types[0], defaultForInput(key, n, v.accepted.types[0])) : null,
|
||||
v.defaultPolicy === "parameter_literal" ? socketDefault(v.accepted.types[0], defaultForInput(key, n, v.accepted.types[0])) : null,
|
||||
),
|
||||
]),
|
||||
),
|
||||
|
||||
@@ -34,12 +34,13 @@ const predicates = (withCulling = false) => {
|
||||
};
|
||||
const scene = (colorTarget, clearColor = [0.015, 0.02, 0.03, 1], heightScale = 1, withCulling = false) => {
|
||||
const classification = predicates(withCulling);
|
||||
const explicit = colorTarget || heightScale !== 1;
|
||||
const target = colorTarget || "hdr";
|
||||
return [
|
||||
node("hdr", "texture", texture("rgba16_float", 1, heightScale)),
|
||||
node("depth", "texture", texture("depth32_float", 1, heightScale)),
|
||||
...(explicit && !colorTarget ? [node("hdr", "texture", texture("rgba16_float", 1, heightScale))] : []),
|
||||
node("mesh", "mesh"),
|
||||
...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("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"), ...(explicit ? { colorTarget: input(target, "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") }),
|
||||
];
|
||||
@@ -47,20 +48,20 @@ const scene = (colorTarget, clearColor = [0.015, 0.02, 0.03, 1], heightScale = 1
|
||||
const graph = (graphId, nodes) => Object.freeze({ schemaVersion: 2, graphId, revision: 1, nodes });
|
||||
const direct = (graphId, clearColor) => graph(graphId, [
|
||||
node("ldr", "texture", texture("rgba8_unorm")),
|
||||
...scene("ldr", clearColor).filter((item) => item.id !== "hdr"),
|
||||
...scene("ldr", clearColor),
|
||||
node("frame_out", "frame_out", frameOut(false), { color: input("pbr_double", "color") }),
|
||||
]);
|
||||
export const midnight = direct("preset_midnight", [0.015, 0.06, 0.18, 1]);
|
||||
export const ember = direct("preset_ember", [0.18, 0.035, 0.012, 1]);
|
||||
export const hdr = graph("preset_hdr_fullscreen", [
|
||||
...scene("hdr"),
|
||||
...scene(),
|
||||
node("frame_out", "frame_out", frameOut(true), { color: input("pbr_double", "color") }),
|
||||
]);
|
||||
export const culling = graph("preset_gpu_culling", (() => {
|
||||
return [...scene("hdr", undefined, 1, true), node("frame_out", "frame_out", frameOut(true), { color: input("pbr_double", "color") })];
|
||||
return [...scene(undefined, undefined, 1, true), node("frame_out", "frame_out", frameOut(true), { color: input("pbr_double", "color") })];
|
||||
})());
|
||||
const postPreset = (graphId, kind) => {
|
||||
const nodes = [...scene("hdr")];
|
||||
const nodes = [...scene()];
|
||||
let source = "pbr_double";
|
||||
if (kind === "edges") {
|
||||
nodes.splice(0, 0, node("edge_hdr", "texture", texture("rgba16_float")));
|
||||
@@ -89,7 +90,7 @@ const postPreset = (graphId, kind) => {
|
||||
};
|
||||
export const tone = postPreset("preset_tone", "tone");
|
||||
const displayPreset = (id, parameters, heightScale = 1) => graph(id, [
|
||||
...scene("hdr", undefined, heightScale),
|
||||
...scene(undefined, undefined, heightScale),
|
||||
node("frame_out", "frame_out", parameters, { color: input("pbr_double", "color") }),
|
||||
]);
|
||||
export const contain = displayPreset("preset_contain", frameOut(false, { scaleMode: "contain", filter: "nearest", backgroundColor: [0.18, 0.18, 0.18, 0.25] }), 2);
|
||||
@@ -100,7 +101,7 @@ export const bloom = postPreset("preset_bloom", "bloom");
|
||||
export const combined = postPreset("preset_combined", "combined");
|
||||
export const grading = graph("preset_grading", [
|
||||
node("balance_hdr", "texture", texture("rgba16_float")), node("exposure_hdr", "texture", texture("rgba16_float")), node("saturation_hdr", "texture", texture("rgba16_float")), node("mixer_hdr", "texture", texture("rgba16_float")),
|
||||
...scene("hdr"),
|
||||
...scene(),
|
||||
node("balance", "color_balance", { mode: "lift_gamma_gain", factor: 1, lift: 0, liftColor: [1,1,1,1], gamma: 1, gammaColor: [1,1,1,1], gain: 1, gainColor: [1,1,1,1], offset: 0, offsetColor: [1,1,1,1], power: 1, powerColor: [1,1,1,1], slope: 1, slopeColor: [1,1,1,1] }, { source: input("pbr_double", "color"), colorTarget: input("balance_hdr", "texture") }),
|
||||
node("exposure", "exposure_contrast", { exposureStops: 0, contrast: 1, pivot: 0.18, factor: 1 }, { source: input("balance", "color"), colorTarget: input("exposure_hdr", "texture") }),
|
||||
node("saturation", "saturation", { saturation: 1, factor: 1 }, { source: input("exposure", "color"), colorTarget: input("saturation_hdr", "texture") }),
|
||||
|
||||
Reference in New Issue
Block a user