Skip to content

Add anaglyph 3D post-processing effect support#1

Open
yoavfrancis wants to merge 3 commits intomasterfrom
claude/enable-3d-reading-y0oEd
Open

Add anaglyph 3D post-processing effect support#1
yoavfrancis wants to merge 3 commits intomasterfrom
claude/enable-3d-reading-y0oEd

Conversation

@yoavfrancis
Copy link
Copy Markdown
Owner

Summary

This PR adds anaglyph (red-cyan) 3D post-processing support to the game engine, enabling stereoscopic 3D viewing with compatible glasses.

Key Changes

  • New SurfaceProxy::applyAnaglyph3D() method: Implements red-cyan anaglyph 3D effect by combining two horizontally-shifted versions of the rendered frame into separate color channels

    • Left eye uses the red channel from source shifted right
    • Right eye uses green+blue channels from source shifted left
    • Configurable pixel shift parameter (default: 5 pixels) for stereo separation control
  • Engine rendering pipeline refactored:

    • Added m_renderTarget off-screen surface to Engine for intermediate rendering
    • Game scene now renders to m_renderTarget instead of directly to screen
    • Anaglyph post-processing applied each frame to combine m_renderTarget into m_screen
    • Proper resource cleanup added to Engine destructor

Implementation Details

  • The anaglyph effect works by creating a stereoscopic illusion through color channel separation, allowing users with red-cyan 3D glasses to perceive depth
  • Surfaces are properly locked during pixel manipulation for thread safety
  • Boundary checking prevents out-of-bounds access when applying horizontal shifts
  • The post-processing is applied after scene drawing but before screen flip, maintaining the existing frame timing

https://claude.ai/code/session_01JyqcqkChDKjYQeYzHYZcnH

claude added 3 commits March 5, 2026 14:51
Adds a red-cyan anaglyph post-processing pass so the game can be viewed
with standard 3D glasses. Each frame is first rendered to an off-screen
surface (m_renderTarget), then SurfaceProxy::applyAnaglyph3D combines it
into the visible screen by extracting the red channel from a right-shifted
copy (left eye) and the green+blue channels from a left-shifted copy
(right eye), producing a classic stereoscopic depth effect.

Changes:
- SurfaceProxy: add static applyAnaglyph3D(src, dst, shift=5)
- Engine: add m_renderTarget off-screen surface; scene renders into it;
  anaglyph transform applied to m_screen each frame before SDL_Flip

https://claude.ai/code/session_01JyqcqkChDKjYQeYzHYZcnH
- Fix case-sensitive includes: <Vector> -> <vector> (ResourceManager.h, TileViewDrawer.h)
- Add out-of-class definition for BoardModel::EMPTY_TILE (required pre-C++17)
- Replace Windows backslash resource paths with forward slashes

https://claude.ai/code/session_01JyqcqkChDKjYQeYzHYZcnH
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