software-mansion / software-mansion/TypeGPU
feat: Detect change in externals across shader invocations and suggest alternative
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 122
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 34
Description
A first instinct when using TypeGPU functions could be to use variables from the outer scope and expect them to auto-update:
let time = 0;
const getDirection = tgpu.fn([], d.vec2f)(() => {
// Using the `time` variable inside shader code
return d.vec2f(std.cos(time), std.sin(time));
});
// before render
time += deltaTime;
// draw...
However, the shader will compile with the value that the variable had at the moment of compilation, and not change between invocations.
This is a silent error/bug, and could be hard to grasp on first use.
Possible solution
In DEV mode, we can gather the externals that were used by a shader, and check if their values match the ones that were captured during compilation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named. Start by locating the shader compilation path and how external values are captured, then determine how DEV-mode comparisons and an alternative suggestion should be exposed. Done means changed externals are detected across shader invocations without affecting production behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100