Skip to content

Optimize WebGL frame transforms - #17

Merged
aomona merged 1 commit into
feature/webgl-v2from
optimize/webgl-frame-uniforms
Jul 8, 2026
Merged

Optimize WebGL frame transforms#17
aomona merged 1 commit into
feature/webgl-v2from
optimize/webgl-frame-uniforms

Conversation

@aomona

@aomona aomona commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Move per-frame motion trig and transform values from fragment shader work into JS-computed uniforms
  • Keep the public API and visual behavior unchanged while reducing per-pixel shader work
  • Add shader source assertions covering the uniform-based transform path

Test Plan

  • npm run typecheck
  • npm run build
  • npm test
  • npm run build:playground
  • npm run lint
  • npm run format:check

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the WebGL fragment shader by moving per-frame trigonometry and transform math (rotation/zoom/travel) out of per-pixel shader execution and into CPU-computed uniforms, aiming to reduce fragment shader work without changing the public API or visual output.

Changes:

  • Replace time/swirl/zoom/rotate/travel-driven per-pixel trig in the fragment shader with precomputed per-frame uniforms (u_frameRotationSin, u_frameRotationCos, u_frameScale, u_frameTravel).
  • Update the WebGL renderer to compute and upload the new per-frame uniforms each render.
  • Add regression assertions in tests to ensure the uniform-based transform path exists and per-pixel trig patterns are absent from the built shader source.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/library.test.mjs Adds build-output assertions to validate the uniform-based transform path and avoid per-pixel motion trig in the fragment shader.
src/webgl.ts Moves per-frame trig/transform computation into JS and updates the fragment shader + uniform plumbing accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aomona
aomona merged commit dc945d4 into feature/webgl-v2 Jul 8, 2026
2 checks passed
@aomona
aomona deleted the optimize/webgl-frame-uniforms branch July 8, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants