You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Short aliases for matrix uniforms.uniformMat2/3/4 now work alongside uniformMat2x2/3x3/4x4, following the same alias pattern as uniformVector3
and uniformTexture. The existing alias loop also registers varyingMat3 and sharedMat3 from this. (src/strands/strands_api.js)
2. Aliases in the generated TypeScript types.utils/typescript.mjs has its
own copy of the alias logic, so I added the same branch there. Without it, uniformMat3 works at runtime but doesn't show up in editor autocomplete.
3. setUniform accepts a p5.Matrix.p5.Matrix gets an isMatrix flag,
and setUniform unwraps it to its flat column-major array, the same way isVector and isColor are handled. Before this, passing a p5.Matrix
crashed with TypeError: data.slice is not a function from inside setUniform. The unwrap happens before the WebGL/WebGPU split, so it covers
both backends.
4. Docs. Added p5.Matrix to the setUniform@param types, and the same
one-line change to docs/parameterData.json. I edited that file by hand:
running npm run docs regenerated about 1300 unrelated lines, since the
committed copy is behind the JSDoc.
Tests
In a new matrix uniforms (#8992) suite:
WebGL and WebGPU: the short aliases produce the same declarations as the
NxN names (checked in the generated GLSL/WGSL).
WebGL: setUniform('uM', createMatrix([...])) in a plain GLSL filter shader,
checked by pixel colour. It reads an off-diagonal entry, so a transposed
upload would fail too.
Each test was checked by stashing the source change: they fail without it
and pass with it.
Not changed here: storage buffers. _packStructArray calls _packField directly and skips setUniform, so a p5.Matrix inside a createStorage object still isn't unwrapped. Seemed out of scope for this
issue, but I can open a separate issue for it.
Uniform helpers don't have their own reference pages, so the types are
where the short names show up. If you'd like them mentioned in a prose
doc somewhere, let me know where.
Pushed a fix for the failing test TypeScript types check.
The failure was Cannot find name 'Matrix' in the generated p5.d.ts. I had
added p5.Matrix to the setUniform@param types, but p5.Matrix is marked @private, so it isn't in the generated types. I've removed it from the @param line and from docs/parameterData.json.
This also means item 4 in the description ("Docs") no longer applies. The
short names are documented through the TypeScript aliases in item 2.
Nothing else changed. setUniform still accepts a p5.Matrix at runtime,
and the unit tests (which passed in the previous CI run) are the same. npm run test:types now passes locally. The workflows will need approving
again for the new commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #8992
Changes
1. Short aliases for matrix uniforms.
uniformMat2/3/4now work alongsideuniformMat2x2/3x3/4x4, following the same alias pattern asuniformVector3and
uniformTexture. The existing alias loop also registersvaryingMat3andsharedMat3from this. (src/strands/strands_api.js)2. Aliases in the generated TypeScript types.
utils/typescript.mjshas itsown copy of the alias logic, so I added the same branch there. Without it,
uniformMat3works at runtime but doesn't show up in editor autocomplete.3.
setUniformaccepts ap5.Matrix.p5.Matrixgets anisMatrixflag,and
setUniformunwraps it to its flat column-major array, the same wayisVectorandisColorare handled. Before this, passing ap5.Matrixcrashed with
TypeError: data.slice is not a functionfrom insidesetUniform. The unwrap happens before the WebGL/WebGPU split, so it coversboth backends.
4. Docs. Added
p5.Matrixto thesetUniform@paramtypes, and the sameone-line change to
docs/parameterData.json. I edited that file by hand:running
npm run docsregenerated about 1300 unrelated lines, since thecommitted copy is behind the JSDoc.
Tests
In a new
matrix uniforms (#8992)suite:NxN names (checked in the generated GLSL/WGSL).
setUniform('uM', createMatrix([...]))in a plain GLSL filter shader,checked by pixel colour. It reads an off-diagonal entry, so a transposed
upload would fail too.
Each test was checked by stashing the source change: they fail without it
and pass with it.
Notes
p5.Matrix. Reading matrix values back needseither a raw WGSL filter shader or
m * vinside strands, which is part of@perminder-17's work on Support transformation matrices in p5.strands #8953. Happy to add one if you'd like.
_packStructArraycalls_packFielddirectly and skipssetUniform, so ap5.Matrixinside acreateStorageobject still isn't unwrapped. Seemed out of scope for thisissue, but I can open a separate issue for it.
where the short names show up. If you'd like them mentioned in a prose
doc somewhere, let me know where.
PR Checklist
npm run lintpasses