Shader graph: Number node, a typed constant like Color (#72)
game-maker / suite (push) Canceled after 6m55s
game-maker / suite (push) Canceled after 6m55s
No input, one Value param (step 0.05, drawn on the node), output `value` as a float literal via floatLiteral (2 -> 2.0, NaN -> 0.0). No uniform, no sprite row - that is the difference to Property. The e2e negative check for "no behavior node in the palette" now uses Boolean as its marker, and step 28 types the palette search first because the palette scrolls from twelve entries on. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d9c4982eb
commit
ccc6dc5b6e
5 files changed
+89
-4
No files matched your search
+44
-3
@@ -86,10 +86,14 @@ export async function shader(t) {
|
||||
const offered = await json('__gm.overlayTexts()');
|
||||
check(
|
||||
'right-click offers shader nodes and no behavior node',
|
||||
['Texture color', 'Output', 'Property', 'Mix', 'Luminance'].every((text) => offered.includes(text)) &&
|
||||
!offered.some((text) => /On start|Number|Branch|Set state/.test(text)),
|
||||
['Texture color', 'Output', 'Property', 'Number', 'Mix', 'Luminance'].every((text) =>
|
||||
offered.includes(text),
|
||||
) && !offered.some((text) => /On start|Boolean|Branch|Set state/.test(text)),
|
||||
JSON.stringify(offered),
|
||||
);
|
||||
// A dozen entries scroll; searched, the row is the only one and in view.
|
||||
await typeText('Texture color');
|
||||
await sleep(150);
|
||||
await clickLast('Texture color');
|
||||
await sleep(300);
|
||||
await click(canvas.x + 420, canvas.y + 60, 'right');
|
||||
@@ -323,7 +327,44 @@ export async function shader(t) {
|
||||
await sleep(300);
|
||||
check('opacity back at 1 draws the pixel from before, byte for byte', (await centre()) === red);
|
||||
|
||||
// 28i. Back to None: no filter at all, the plain colour returns bit for bit.
|
||||
// 28i. A Number node is a constant in the fragment: red times 0.5 is half red; typed back to 1,
|
||||
// the pixel is the red from before. Its value is a setting row on the node.
|
||||
await mutate(`
|
||||
const a = __gm.state.project.assets.find((x) => x.id === ${JSON.stringify(made.id)});
|
||||
const out = a.graph.nodes.find((n) => n.type === 'ShaderOutput');
|
||||
a.graph.nodes.push(
|
||||
{ id: 'sh-half', type: 'ShaderNumber', x: 200, y: 200, params: { value: 0.5 } },
|
||||
{ id: 'sh-dim', type: 'ShaderMultiply', x: 400, y: 200, params: {} });
|
||||
a.graph.edges = a.graph.edges.filter((e) => e.id !== 'sh-red-edge');
|
||||
a.graph.edges.push(
|
||||
{ id: 'sh-dim-a', from: { node: 'sh-red', port: 'color' }, to: { node: 'sh-dim', port: 'a' } },
|
||||
{ id: 'sh-dim-b', from: { node: 'sh-half', port: 'value' }, to: { node: 'sh-dim', port: 'b' } },
|
||||
{ id: 'sh-dim-out', from: { node: 'sh-dim', port: 'result' }, to: { node: out.id, port: 'color' } });`);
|
||||
await sleep(400);
|
||||
const dimmed = await centre();
|
||||
check('a Number of 0.5 into a Multiply halves the red', colourDistance(dimmed, '#800000') < 6, {
|
||||
red,
|
||||
dimmed,
|
||||
});
|
||||
await evaluate("__gm.showTab('shader')");
|
||||
await sleep(300);
|
||||
check(
|
||||
'the Number node draws its value as a setting row',
|
||||
(await json("__gm.shader.nodeSettings('sh-half')"))?.join() === 'Value: 0.500',
|
||||
JSON.stringify(await json("__gm.shader.nodeSettings('sh-half')")),
|
||||
);
|
||||
await shot('28-number-node');
|
||||
await evaluate("__gm.showTab('scene')");
|
||||
await mutate(`
|
||||
const a = __gm.state.project.assets.find((x) => x.id === ${JSON.stringify(made.id)});
|
||||
a.graph.nodes.find((n) => n.id === 'sh-half').params.value = 1`);
|
||||
await sleep(400);
|
||||
check('the Number typed to 1 gives the red from before, byte for byte', (await centre()) === red, {
|
||||
red,
|
||||
now: await centre(),
|
||||
});
|
||||
|
||||
// 28j. Back to None: no filter at all, the plain colour returns bit for bit.
|
||||
await assetProps({ shader: '' });
|
||||
await sleep(300);
|
||||
const back = await centre();
|
||||
|
||||
Reference in new issue
Block a user