Let a shader declare a color the sprite sets (#298)
A shader could only ask its sprites for numbers. A tint, an outline colour or a glow colour had to be built from three Property nodes. - New node Color property next to Property: Name and Default (a colour, white unless picked), output `color`. It becomes a colour row below the Shader dropdown and a vec3 uniform in the program. - Number and colour properties share one set of names. A clash is the existing "Another property is named" problem. - Like Color it cannot feed the Vertex output. - Placed from the palette it is called tint, then tint2. - The preview in the Shader tab shows a colour field for it. Like the sliders it starts at the sprite's value and never writes into the project. - `declaredRows` takes the row builder, so the particle graph keeps its number rows unchanged. Tests: - Gate: 222 files, 3452 tests (3445 + 7) - e2e 28: 89 checks (28l-v: default colour drawn, then the colour the sprite sets) - e2e total 1704, counted (1703 + 1) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f4c149211
commit
bf27e42e8a
13 files changed
+303
-57
No files matched your search
@@ -925,6 +925,29 @@ export async function shader(t) {
|
||||
{ perCorner, perCornerReadout },
|
||||
);
|
||||
|
||||
// 28l-v. A Color property is a colour row on the sprite and a vec3 uniform (#298): unset, the
|
||||
// sprite shows the declared default; set on the sprite, that colour.
|
||||
await graph(
|
||||
[
|
||||
node('tint', 'ShaderColorProperty', { name: 'tint', default: 0x3cc85a }),
|
||||
node('out', 'ShaderOutput', {}, 780, 0),
|
||||
],
|
||||
[edge('tint', 'color', 'out', 'color')],
|
||||
);
|
||||
const tinted = async () => ({ a: await pixel(-0.3, -0.3), b: await pixel(0.3, 0.3) });
|
||||
const unsetTint = await tinted();
|
||||
await assetProps({ tint: 0xe63c3c });
|
||||
const setTint = await tinted();
|
||||
check(
|
||||
'a Color property draws its default, and the colour the sprite sets once it sets one',
|
||||
colourDistance(unsetTint.a, '#3cc85a') < 12 &&
|
||||
colourDistance(unsetTint.b, '#3cc85a') < 12 &&
|
||||
colourDistance(setTint.a, '#e63c3c') < 12 &&
|
||||
colourDistance(setTint.b, '#e63c3c') < 12,
|
||||
{ unsetTint, setTint },
|
||||
);
|
||||
await mutate(`delete __gm.state.project.assets.find((a) => a.id === 'shade-sprite').props.tint`);
|
||||
|
||||
// 28l-ii. The sprite wears a picture and a shader: both open from the object's menu, from the
|
||||
// asset's menu and from the inspector, whose Texture and Shader labels are links (#221).
|
||||
const shadedProps = await json("__gm.state.project.assets.find((a) => a.id === 'shade-sprite').props");
|
||||
|
||||
Reference in new issue
Block a user