Pixel Shader (Three.js)
A spinning crystal sphere rendered through Three.js’s EffectComposer with the RenderPixelatedPass addon — chunky retro pixels with antialiased edges. Ported from refs/three/examples/webgl_postprocessing_pixel.html.
Live demo
Section titled “Live demo”What it exercises
Section titled “What it exercises”| Pillar | What it needs |
|---|---|
@gjsify/webgl | Multiple framebuffers (WebGLRenderTarget), custom shaders compiled at runtime, OrbitControls |
@gjsify/dom-elements | The standard canvas/RAF/Resize trio |
@gjsify/adwaita-web | Browser embed’s resolution-tier controls |
| Adwaita widgets (GJS) | Adw.PreferencesGroup + Adw.SpinRow for pixel-size + render-resolution controls |
Run it on GJS
Section titled “Run it on GJS”gjsify showcase three-postprocessing-pixelOpens a GTK4 window with an Adw.ToolbarView. Adjust pixel-size to crush the resolution into chunky cells; the RenderPixelatedPass writes into a low-res framebuffer then upscales with nearest-neighbor sampling for the retro look.
Run it in the browser
Section titled “Run it in the browser”import { mount } from '@gjsify/example-dom-three-postprocessing-pixel/browser';mount(document.getElementById('app')!);Same scene logic. Browser-side resolution controls live in @gjsify/adwaita-web web components for visual parity with the GJS shell.
Source
Section titled “Source”showcases/dom/three-postprocessing-pixel/
The shared three-demo.ts drives the scene + post-processing pipeline. Both targets re-use it; the only target-specific code is the host shell.
Why this is the harder Three.js showcase
Section titled “Why this is the harder Three.js showcase”The plain three-geometry-teapot exercises a single forward render pass. This one threads the render through:
- Custom-resolution
WebGLRenderTarget— the pixelated buffer RenderPass→RenderPixelatedPass— multi-stage compositionOutputPass— final blit to the screen framebuffer- Custom GLSL shaders for the pixel-art edge detection
Each step has its own buffer / texture state. If @gjsify/webgl mishandles ANY framebuffer attachment or read-back, the pipeline produces a black canvas. Smoke-testing this showcase verifies the bridge’s framebuffer / texture state-tracking is intact across the full WebGL2 surface.
Related
Section titled “Related”three-geometry-teapot— simpler companion (single render pass)refs/three/— Three.js source, used as the gap-analysis reference- Bridge widgets pattern —
WebGLBridgelifecycle