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
@@ -25,6 +25,7 @@ import { inlineInputs } from '../../src/core/graph/NodeRegistry';
|
||||
import { compileShader } from '../../src/core/shader/compile';
|
||||
import {
|
||||
SHADER_NODES,
|
||||
SHADER_NUMBER,
|
||||
SHADER_OUTPUT,
|
||||
SHADER_TEXTURE_ALPHA,
|
||||
SHADER_TEXTURE_COLOR,
|
||||
@@ -227,6 +228,35 @@ describe('compileShader', () => {
|
||||
expect(tinted).toMatch(/vec3 n1_result = \(vec3\(1\.0\) \* n0_color\);/);
|
||||
});
|
||||
|
||||
it('turns a Number node into one float literal: decimal point kept, sign kept, NaN made 0', () => {
|
||||
const f = makeProject();
|
||||
const s = shaderEditor(f);
|
||||
const half = s.add(SHADER_NUMBER, { value: 0.5 });
|
||||
const two = s.add(SHADER_NUMBER, { value: 2 });
|
||||
const minus = s.add(SHADER_NUMBER, { value: -0.25 });
|
||||
const broken = s.add(SHADER_NUMBER, { value: Number.NaN });
|
||||
const sum = s.add('ShaderAdd');
|
||||
const times = s.add('ShaderMultiply');
|
||||
const diff = s.add('ShaderSubtract');
|
||||
const output = s.add(SHADER_OUTPUT);
|
||||
s.link(half, 'value', sum, 'a');
|
||||
s.link(two, 'value', sum, 'b');
|
||||
s.link(sum, 'result', times, 'a');
|
||||
s.link(minus, 'value', times, 'b');
|
||||
s.link(times, 'result', diff, 'a');
|
||||
s.link(broken, 'value', diff, 'b');
|
||||
s.link(diff, 'result', output, 'color');
|
||||
const { fragment } = compileShader(s.asset().graph).compiled!;
|
||||
// Locals are numbered in visiting order; the literal's form is what matters here.
|
||||
expect(fragment).toMatch(/float n\d+_value = 0\.5;/);
|
||||
expect(fragment).toMatch(/float n\d+_value = 2\.0;/);
|
||||
expect(fragment).toMatch(/float n\d+_value = -0\.25;/);
|
||||
expect(fragment).toMatch(/float n\d+_value = 0\.0;/);
|
||||
expect(fragment).toMatch(/float n\d+_result = \(n\d+_value \+ n\d+_value\);/);
|
||||
expect(fragment).toMatch(/clamp\(vec3\(n\d+_result\), 0\.0, 1\.0\)/);
|
||||
expect(fragment).not.toContain('uniform float u_');
|
||||
});
|
||||
|
||||
it('keeps the texture’s alpha until the Output’s alpha is fed, then clamps what feeds it', () => {
|
||||
const f = makeProject();
|
||||
const s = shaderEditor(f);
|
||||
|
||||
Reference in new issue
Block a user