Skip to main content
Plugdata includes Gem (Graphics Environment for Multimedia), a powerful library for creating real-time 3D graphics, video processing, and visual effects in Pure Data patches.

Overview

Gem provides:
  • ✅ Real-time 3D graphics rendering
  • ✅ Video playback and capture
  • ✅ Image processing and effects
  • ✅ OpenGL integration
  • ✅ Shader support (GLSL)
  • ✅ Particle systems
  • ✅ 3D model loading
Gem is enabled by default. To disable during compilation, use -DENABLE_GEM=0.

Quick Start

Basic Rendering Chain

Every Gem patch follows this structure:

Window Configuration

The [gemwin] object accepts many configuration messages:

Gem Objects Reference

3D Primitives

Basic geometric objects: Example:

Transformations

Modify object position, rotation, and scale: Example:

Materials and Lighting

Example:

Camera Control

Or use perspective:

Textures and Images

Load and Display Image

Supported Image Formats

  • JPEG (.jpg, .jpeg)
  • PNG (.png)
  • BMP (.bmp)
  • WebP (.webp)
  • TGA (.tga)

Image Processing

Gem includes many image processing objects:
Common pix_ objects:
  • [pix_blur] - Gaussian blur
  • [pix_contrast] - Adjust contrast
  • [pix_invert] - Invert colors
  • [pix_gray] - Convert to grayscale
  • [pix_chroma_key] - Chroma key (green screen)
  • [pix_kaleidoscope] - Kaleidoscope effect
  • [pix_normalize] - Normalize brightness

Video Playback

Video playback requires FFmpeg support. Enable with -DENABLE_FFMPEG=1 (default).
Supported video formats (with FFmpeg):
  • MP4 (.mp4)
  • AVI (.avi)
  • MOV (.mov)
  • MKV (.mkv)

GLSL Shaders

Gem supports custom GLSL shaders:

Vertex Shader

Fragment Shader

Complete Shader Example

Example fragment shader (ripple.frag):

3D Model Loading

Load external 3D models:
Supported formats:
  • Wavefront OBJ (.obj)
  • Various formats via ASSIMP library

Particle Systems

Create particle effects:

Multiple Render Chains

Use [separator] to create independent chains:

Animation Techniques

Using [gemhead] Bang

External Control

Practical Examples

Rotating Textured Cube

Multi-Object Scene

Performance Tips

  1. Use appropriate frame rates: Higher FPS = more CPU usage
  2. Limit particle counts: Start with low numbers and increase as needed
  3. Optimize image sizes: Use power-of-2 textures (256, 512, 1024, 2048)
  4. Use [separator] wisely: Only when you need isolated transformations
  5. Disable unused features:

Common Issues

Window Won’t Create

Solution: Check graphics drivers and OpenGL support.

Black Screen

Solution: Verify:
  • [gemhead] is receiving bangs (connect to [print])
  • Objects are visible (not behind camera)
  • Lighting is appropriate

Poor Performance

Solution:
  • Lower frame rate: [frame 30(
  • Reduce particle counts
  • Optimize image/video resolution
  • Check CPU/GPU usage

Code References

  • Gem setup: Source/Pd/Setup.cpp:163-702, 1831-2068
  • Gem initialization: Source/Pd/Setup.cpp:1831
  • CMake Gem option: CMakeLists.txt:35, 340-343
  • Gem documentation: Resources/Documentation/Gem/

Learning Resources

  • Gem documentation files: Resources/Documentation/Gem/
  • [gemhead] reference: Resources/Documentation/Gem/gemhead.md
  • [gemwin] reference: Resources/Documentation/Gem/gemwin.md
  • Over 400 Gem objects documented in Resources/Documentation/Gem/

Next Steps

Performance Optimization

Optimize Gem rendering performance

Lua Scripting

Control Gem with Lua scripts