Overview
The Binary serializer encodes each DMX channel value as 8 separate binary bits, allowing for extremely high channel density. Each bit is represented as a 4×4 pixel block, making this one of the most space-efficient serialization methods.Class: Binary
Namespace: GlobalImplements:
IDMXSerializer
Configuration Constants
Size in pixels of each bit block (4×4 pixels)
Number of bit blocks per column. Since each channel uses 8 blocks, this allows for approximately 6.5 channels per column.
How It Works
Bit Encoding
Each DMX channel value (0-255) is split into 8 individual bits:- 0 → RGB(0, 0, 0) - Black
- 1 → RGB(255, 255, 255) - White
Spatial Layout
Bits are arranged vertically in columns:Methods
SerializeChannel
Encodes a DMX channel value as 8 binary bit blocks.The pixel array to write the encoded bits to
The DMX channel value (0-255) to encode
The DMX channel number
Width of the output texture
Height of the output texture
- Converts the channel value to a BitArray
- For each of the 8 bits:
- Calculates the position based on
(channel * 8) + bitIndex - Creates a 4×4 color block (white for 1, black for 0)
- Writes the block to the pixel array
- Calculates the position based on
- Skips any blocks that would exceed texture bounds
DeserializeChannel
Decodes a DMX channel value from 8 binary bit blocks.The input texture to read from
Output parameter that receives the decoded value
The DMX channel number to decode
Width of the input texture
Height of the input texture
- Creates an 8-bit BitArray
- For each bit position:
- Calculates the block position
- Reads the center pixel of the block (offset +1, +1)
- Determines bit value based on red channel threshold (> 0.5 = 1)
- Converts the BitArray back to a byte value
Usage Example
Channel Capacity
For a given texture size, the Binary serializer can encode:Capacity by Resolution
| Resolution | Channels |
|---|---|
| 128×128 | 104 |
| 256×256 | 416 |
| 512×512 | 1,664 |
| 1024×1024 | 6,656 |
| 1920×1080 | 3,120 |
Advantages
High Density
8× more efficient than block-based encoding methods
Simple Decoding
Easy threshold-based bit detection
Small Blocks
4×4 pixel blocks minimize texture usage
Clear Visual
Binary pattern is easily recognizable
Limitations
- Compression Artifacts: Video compression may corrupt individual bits
- Noise Sensitivity: Single-pixel errors can cause incorrect values
- No Redundancy: Each bit is represented only once
Best Practices
1. Video Quality
Use high bitrate, lossless or near-lossless compression:2. Threshold Testing
The default threshold is 0.5, but you may need to adjust based on your video pipeline:3. Bounds Checking
Always verify that your channel count fits within the texture:Comparison with Other Serializers
| Feature | Binary | VRSL | Binary Stage Flight |
|---|---|---|---|
| Block Size | 4×4 | 16×16 | 4×4 |
| Error Detection | None | None | CRC-4 |
| Channels (256×256) | 416 | 169 | ~195 |
| Compression Tolerance | Low | High | Medium |
| Decoding Complexity | Simple | Simple | Medium |
Performance
- Encoding: ~0.02ms per channel (tested on Unity 2019.4)
- Decoding: ~0.03ms per channel
- Memory: Minimal overhead, uses BitArray
Troubleshooting
Decoded values are incorrect
Decoded values are incorrect
- Check video compression settings - use minimal compression
- Verify color space is RGB, not YUV
- Ensure no chroma subsampling (use 4:4:4)
- Test with threshold adjustment
Blocks appear outside texture bounds
Blocks appear outside texture bounds
- Verify channel count doesn’t exceed capacity
- Check texture dimensions are correct
- Ensure textureWidth/textureHeight match actual texture
Intermittent decoding errors
Intermittent decoding errors
- Binary format is sensitive to single-bit errors
- Consider using Binary Stage Flight for CRC error detection
- Increase video bitrate
- Use error-tolerant video transport