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:[gemwin]
|
[create( <- Create window
[destroy( <- Destroy window
[1( <- Start rendering (1 = on)
[0( <- Stop rendering (0 = off)
[gemhead 50] <- Priority 50 (lower = earlier)
|
[rotateXYZ 1 1 0] <- Rotate object
|
[cube] <- Draw cube
Window Configuration
The[gemwin] object accepts many configuration messages:
Gem Objects Reference
3D Primitives
Basic geometric objects:| Object | Description |
|---|---|
[cube] | 3D cube |
[sphere] | Sphere (latitude/longitude) |
[cylinder] | Cylinder |
[cone] | Cone |
[torus] | Torus (donut shape) |
[teapot] | Utah teapot |
[square] | 2D square |
[circle] | 2D circle |
[triangle] | 3D triangle |
[rectangle] | 2D rectangle |
Transformations
Modify object position, rotation, and scale:| Object | Description |
|---|---|
[translate X Y Z] | Move object |
[rotate angle X Y Z] | Rotate around axis |
[scale X Y Z] | Scale object |
[rotateXYZ Xangle Yangle Zangle] | Rotate on all axes |
[translateXYZ X Y Z] | Alias for translate |
[scaleXYZ X Y Z] | Alias for scale |
Materials and Lighting
| Object | Description |
|---|---|
[color R G B] | Set object color (0-1) |
[colorRGB R G B] | Alias for color |
[alpha A] | Set transparency (0-1) |
[ambient R G B] | Ambient light color |
[diffuse R G B] | Diffuse reflection |
[specular R G B] | Specular highlights |
[shininess S] | Shininess amount |
[light] | Create light source |
[world_light] | World-space light |
Camera Control
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:[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).- MP4 (.mp4)
- AVI (.avi)
- MOV (.mov)
- MKV (.mkv)
GLSL Shaders
Gem supports custom GLSL shaders:Vertex Shader
Fragment Shader
Complete Shader Example
ripple.frag):
3D Model Loading
Load external 3D models:- 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
-
Use appropriate frame rates: Higher FPS = more CPU usage
-
Limit particle counts: Start with low numbers and increase as needed
- Optimize image sizes: Use power-of-2 textures (256, 512, 1024, 2048)
-
Use
[separator]wisely: Only when you need isolated transformations -
Disable unused features:
Common Issues
Window Won’t Create
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
