Repository navigation
webgl_postprocessing_pixel: Snap Objects to Pixel Grid - #33908
Conversation
…ation demo Adds a pixelAlignedObjects checkbox to webgl_postprocessing_pixel that snaps moving objects to the screen-space pixel grid, complementing the existing pixel-aligned camera panning. The crystal's true (unsnapped) position is restored after rendering so its bulk motion is unaffected. Defaults the demo to pixelSize 4 with both alignment options enabled. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
webgl_postprocessing_pixel.jpg.zip Can you please replace the E2E screenshot with this version? It should solve the CI issues. |
Adds a rotationSnap slider (degrees, 0 = off) that snaps moving objects' rotations to the nearest camera-relative euler increment for a stepped, retro look. Like the position snapping, the object's true rotation is restored after rendering so its bulk motion is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The sphere transformation looks somewhat broken when Bildschirmaufnahme.2026-06-29.um.19.47.44.mov |
Restoring the unsnapped rotation via the quaternion let three.js re-derive a gimbal-equivalent euler (e.g. a 180-deg Y rotation became x=PI, z=PI), which the next frame's rotation.y assignment left baked in, permanently corrupting the spin. Snapshot and restore the euler rotation directly instead, since that is what drives the motion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Regenerated to reflect the new default pixelSize, object pixel snapping and camera-relative rotation snapping. Verified with `npm run test-e2e` (0.0% diff). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Apologies! The rotation snapping was a last minute bit of inspiration before I took a nap; it’s all fixed now 😄 I think with these two new elements, the whole effect is much more convincing, and should stay perfectly convincing so long as the camera is not rotating… I could also snap the camera rotation and scale too, I suppose… that would make the effect much more solid on mobile too (where the two fingered touch is used…) |
Adds cameraRotationSnap (deg) and cameraZoomSnap sliders that snap the camera's orientation and zoom to fixed increments, keeping the pixelated effect solid while orbiting or pinch-zooming. The camera snap runs before the frustum (translation) snap so the latter derives its pixel grid and screen-space basis from the already-snapped orientation and zoom. The camera's true transform is restored after rendering so OrbitControls interaction is unaffected. Both sliders default to 0 (off). Regenerated the e2e screenshot (0.0% diff). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When snapping the camera's orientation while orbiting, re-place the camera along the snapped view axis at the same distance from the orbit target, so the orbit translation snaps together with the rotation and the target stays centered instead of sliding smoothly off-screen. The camera position is snapshotted and restored after rendering alongside its rotation and zoom so OrbitControls interaction is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Snapping the camera's euler angles independently could combine into a rolled orientation. Snap the orbit's azimuth/polar angle around the target in spherical coordinates instead, then re-aim with lookAt and world up, which is roll-free by construction (and keeps the target centered). Default cameraRotationSnap to 10 deg and cameraZoomSnap to 0.1; the default view sits on these grids so the screenshot is unchanged (verified e2e, 0.0% diff). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Regenerated the e2e screenshot for the slightly steeper default framing (the 60-degree polar angle snaps to 63). Verified e2e (0.0% diff). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Snapping the camera rotation and scale got rid of the last “immersion breaker” (even on mobile). Now it’s “authentic” by default 😄 |
Move the five snapping controls into a 'Snapping' folder and add a top-level 'snapping (all)' checkbox that enables/disables every snapping effect at once (and greys out the folder when off). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Snap the pulsing emissiveIntensity to 32 discrete levels to match the pixelated, retro aesthetic. Regenerated the e2e screenshot (0.0% diff). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Coarser stepping reads better with the pixelated look than 32 levels. Regenerated the e2e screenshot (0.0% diff). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Also make the comment value-agnostic so it stays accurate. Regenerated the e2e screenshot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Have you encountered this issue when panning? Screen.Recording.2026-06-30.at.23.51.55.mov |
|
Strange, that did appear on my setup (Chrome + macMini and 5K screen). |
|
It’s probably one of those things that only started showing up when snapping all the camera parameters and scale to be perfectly axis aligned… |
Description
The pixelated rendering demo already snaps the camera frustum translation to the pixel grid to achieve pixel stability under camera panning.
This PR adds a checkbox to snap scene object translations and rotations to the pixel grid so they maintain pixel stability under translation (and look more like sprites). Also adds snapping to the camera rotation and scale as well.
Example: https://rawcdn.githack.com/zalo/three.js/90e77c4be36f33fa35de39923736a2b89b34b5fe/examples/webgl_postprocessing_pixel.html