A name that a sprite already owns cannot name a property, and a division by zero cannot answer (#63, #64)
game-maker / suite (push) Failing after 11m29s
game-maker / suite (push) Failing after 11m29s
#63: a shader Property node named "width" quietly took over the sprite row of the same name. isSpriteProp lives in PropertySchema now and is derived from FULL_SCHEMAS.sprite instead of being a second list that drifts. isValidPropertyName rejects those ten names, and the compiler reports it at the node as its own problem: "width" is a sprite property, told apart from "not a word" and from a duplicate. #64: Divide emitted (a / b) and handed NaN to the driver. It emits divide(a, b) now, with the guard in the prologue next to straight(), scalar and per channel: zero divided by zero is zero. That was already the house rule in the behavior and particle graphs - only the shader had never been told. Clamp comes along as a shader node for the same reason: the behavior catalog has had it all along.
This commit is contained in:
1 parent
150f2e0906
commit
c990dbcb26
6 files changed
+203
-6
No files matched your search
@@ -287,7 +287,43 @@ export const ShaderMultiply = arithmetic(
|
||||
'a × b, per channel for colours.',
|
||||
1,
|
||||
);
|
||||
export const ShaderDivide = arithmetic('ShaderDivide', 'Divide', '/', 'a / b, per channel for colours.', 1);
|
||||
/**
|
||||
* Division with an answer at zero. `a / 0.0` is NaN, and the epilog's `clamp(NaN, 0.0, 1.0)` is
|
||||
* undefined in GLSL – the driver decides the pixel, so the same graph looks different on Intel,
|
||||
* Nvidia and a phone (#64). Zero is the answer, the same one the `Divide` of a behavior graph and
|
||||
* of a particle graph give.
|
||||
*/
|
||||
export const DIVIDE_FN = [
|
||||
'float divide(float a, float b) { return b == 0.0 ? 0.0 : a / b; }',
|
||||
'vec3 divide(vec3 a, vec3 b) { return vec3(divide(a.x, b.x), divide(a.y, b.y), divide(a.z, b.z)); }',
|
||||
].join('\n');
|
||||
|
||||
export const ShaderDivide: ShaderNodeDef = {
|
||||
type: 'ShaderDivide',
|
||||
label: 'Divide',
|
||||
category: 'shader',
|
||||
description: 'a / b, per channel for colours. Dividing by 0 is 0, not a pixel the driver picks.',
|
||||
inputs: [anyIn('a', 1), anyIn('b', 1)],
|
||||
outputs: [anyOut('result')],
|
||||
params: [],
|
||||
emit: ({ a, b }) => {
|
||||
const l = lifted(a!, b!);
|
||||
return { result: { code: `divide(${l.a}, ${l.b})`, type: l.type } };
|
||||
},
|
||||
};
|
||||
|
||||
export const ShaderClamp: ShaderNodeDef = {
|
||||
type: 'ShaderClamp',
|
||||
label: 'Clamp',
|
||||
category: 'shader',
|
||||
description: 'Holds the value inside min..max, per channel for colours.',
|
||||
inputs: [anyIn('value', 0), floatIn('min', 0), floatIn('max', 1)],
|
||||
outputs: [anyOut('result')],
|
||||
params: [],
|
||||
emit: ({ value, min, max }) => ({
|
||||
result: { code: `clamp(${value!.code}, ${min!.code}, ${max!.code})`, type: value!.type },
|
||||
}),
|
||||
};
|
||||
|
||||
export const ShaderMix: ShaderNodeDef = {
|
||||
type: 'ShaderMix',
|
||||
@@ -423,6 +459,7 @@ export const SHADER_NODES: readonly ShaderNodeDef[] = [
|
||||
ShaderStep,
|
||||
ShaderPow,
|
||||
ShaderSqrt,
|
||||
ShaderClamp,
|
||||
];
|
||||
|
||||
/** A GLSL float literal: always with a decimal point, so `1` does not become an int. */
|
||||
|
||||
Reference in new issue
Block a user