# Texture Synthesizer

## Overview

The Texture Synthesizer is a procedural texture generation tool that creates seamless, tileable textures for backgrounds, game assets, and artistic effects. It includes 12 different texture types ranging from architectural materials to natural patterns, all generated algorithmically for infinite variation.

## Access

**Menu**: Tools → Tool Scripts → "Texture Synthesizer"
**Keyboard**: Ctrl+Shift+T, then select "Texture Synthesizer"

## What is Procedural Texture Generation?

Procedural textures are generated mathematically rather than drawn by hand. This provides:
- **Infinite variation**: Change seed for new patterns
- **Seamless tiling**: Perfect for backgrounds and game levels
- **Resolution independence**: Generate at any size
- **Parametric control**: Adjust scale and variation
- **Memory efficient**: No need to store image files

## Texture Types

### 1. **Brick Wall**
Classic brick wall pattern with mortar joints.

**Parameters:**
- **Scale**: Controls brick size
- **Variation**: Brick color variation

**Best For:**
- Building exteriors
- Dungeon walls
- Platformer backgrounds
- Architectural scenes

**Characteristics:**
- Running bond pattern (offset rows)
- Consistent mortar thickness
- Per-brick color variation

### 2. **Wood Grain**
Natural wood grain with flowing lines.

**Parameters:**
- **Scale**: Controls grain spacing
- **Variation**: Grain irregularity

**Best For:**
- Wooden planks
- Barrels and crates
- Furniture
- Medieval interiors

**Characteristics:**
- Organic flowing lines
- Natural-looking variation
- Works great with brown color ranges

### 3. **Brushed Metal**
Metallic surface with vertical brush strokes.

**Parameters:**
- **Scale**: Brush stroke fineness
- **Variation**: Surface irregularity

**Best For:**
- Sci-fi panels
- Industrial surfaces
- Robot textures
- Modern architecture

**Characteristics:**
- Vertical streak pattern
- Subtle variation
- Best with gray/metallic colors

### 4. **Scratched Metal**
Metal surface with random scratches and wear.

**Parameters:**
- **Scale**: Base texture detail
- **Variation**: Scratch frequency

**Best For:**
- Worn machinery
- Battle damage
- Aged surfaces
- Industrial decay

**Characteristics:**
- Random scratch patterns
- Weathered appearance
- Combines well with rust

### 5. **Fabric Weave**
Textile weave pattern like canvas or burlap.

**Parameters:**
- **Scale**: Thread thickness
- **Variation**: Weave irregularity

**Best For:**
- Cloth surfaces
- Sacks and bags
- Tapestries
- Medieval textures

**Characteristics:**
- Over-under weave pattern
- Checkerboard base
- Natural textile feel

### 6. **Dragon Scales**
Overlapping scale pattern like reptile skin.

**Parameters:**
- **Scale**: Scale size
- **Variation**: Scale color variation

**Best For:**
- Fantasy creatures
- Armor patterns
- Alien skin
- Decorative patterns

**Characteristics:**
- Overlapping rows
- Offset pattern
- Organic appearance

### 7. **Hexagon Tiles**
Honeycomb hexagonal tile pattern.

**Parameters:**
- **Scale**: Tile size
- **Variation**: Tile color variation

**Best For:**
- Bathroom tiles
- Sci-fi floors
- Beehive patterns
- Geometric backgrounds

**Characteristics:**
- Perfect hexagons
- Consistent grout
- Clean geometric look

### 8. **Cobblestone**
Irregular stone pavement pattern.

**Parameters:**
- **Scale**: Stone size
- **Variation**: Stone arrangement randomness

**Best For:**
- Medieval streets
- Castle courtyards
- Pathways
- Dungeon floors

**Characteristics:**
- Irregular stone shapes
- Random offsets
- Natural variation
- Dark grout lines

### 9. **Circuit Board**
Electronic circuit board with traces and components.

**Parameters:**
- **Scale**: Circuit density
- **Variation**: Component placement randomness

**Best For:**
- Sci-fi technology
- Computer interfaces
- Cyberpunk aesthetics
- Electronic devices

**Characteristics:**
- Grid-based traces
- Random component placement
- High-tech appearance

### 10. **Clouds**
Soft, fluffy cloud patterns using Perlin noise.

**Parameters:**
- **Scale**: Cloud size
- **Variation**: Cloud density

**Best For:**
- Sky backgrounds
- Smoke effects
- Atmospheric effects
- Soft textures

**Characteristics:**
- Multiple noise octaves
- Soft, organic shapes
- Natural cloud appearance
- Great for parallax backgrounds

### 11. **Marble**
Veined marble stone texture.

**Parameters:**
- **Scale**: Vein spacing
- **Variation**: Vein irregularity

**Best For:**
- Luxury surfaces
- Statues
- Palace floors
- Decorative elements

**Characteristics:**
- Turbulent veins
- Sine wave base
- Elegant appearance
- Classic stone look

### 12. **Rust/Corrosion**
Rusty, corroded metal surface.

**Parameters:**
- **Scale**: Corrosion patch size
- **Variation**: Rust coverage

**Best For:**
- Aged metal
- Post-apocalyptic scenes
- Weathered vehicles
- Industrial decay

**Characteristics:**
- Irregular rust spots
- Multi-scale noise
- Organic corrosion patterns
- Combines well with metal textures

## Parameters

### Texture Type
Select from 12 different procedural textures (see above).

### Texture Scale (4-64)
Controls the size of texture features.
- **Small (4-8)**: Fine, detailed patterns
- **Medium (12-24)**: Standard size (default: 16)
- **Large (32-64)**: Bold, chunky patterns

**Scale affects:**
- Brick size
- Wood grain spacing
- Metal brush stroke width
- Tile dimensions
- Stone size
- Component spacing

### Variation/Noise (0-100%)
Controls randomness and organic irregularity.
- **0%**: Uniform, repetitive pattern
- **50% (default)**: Balanced natural variation
- **100%**: Maximum randomness

**Variation affects:**
- Brick color differences
- Wood grain irregularity
- Metal surface noise
- Tile color variation
- Stone placement randomness
- Rust coverage

### Make Seamless (Tileable)
Ensures texture edges match perfectly for tiling.
- **Enabled (default)**: Edges blend seamlessly
- **Disabled**: Unique non-tiling texture

**When to disable:**
- Single-use backgrounds
- Full-screen images
- When edge artifacts are acceptable

### Color Range (0-31)
Select which color range to use for the texture.

**Tips:**
- **Brick**: Browns and reds
- **Wood**: Browns and tans
- **Metal**: Grays and blues
- **Fabric**: Natural earth tones
- **Clouds**: Whites and light blues
- **Rust**: Oranges and browns

### Random Seed (0-9999)
Determines the random variation pattern.
- **0 (default)**: Random seed each time
- **1-9999**: Specific seed for reproducible results

**Use cases:**
- Set to 0 for different result each time
- Set to specific number to recreate exact pattern
- Share seeds to reproduce textures

### Clear Canvas First
Start with blank canvas before generating.
- **Enabled (default)**: Fresh texture
- **Disabled**: Layer over existing content

## Usage Examples

### Example 1: Brick Wall Background
1. Setup a color range with brick colors (browns, reds)
2. Open Texture Synthesizer
3. Texture Type: Brick Wall
4. Scale: 16
5. Variation: 50%
6. Select your brick color range
7. Click Run
8. **Result**: Perfect tileable brick wall

### Example 2: Wood Planks
1. Setup color range with wood tones (browns, tans)
2. Texture Type: Wood Grain
3. Scale: 20
4. Variation: 60%
5. Click Run
6. **Result**: Natural wood plank texture

### Example 3: Sci-Fi Floor
1. Setup color range with grays and blues
2. Texture Type: Hexagon Tiles
3. Scale: 12
4. Variation: 30%
5. Click Run
6. **Result**: Clean futuristic floor

### Example 4: Fantasy Dragon Scales
1. Setup color range with greens or blues
2. Texture Type: Dragon Scales
3. Scale: 16
4. Variation: 40%
5. Click Run
6. **Result**: Reptilian scale pattern

### Example 5: Cloud Background
1. Setup color range with white, light blue
2. Texture Type: Clouds
3. Scale: 32
4. Variation: 70%
5. Click Run
6. **Result**: Soft cloudy sky

### Example 6: Weathered Metal
1. Setup color range with grays
2. Generate Brushed Metal (Scale: 8, Variation: 30%)
3. Disable "Clear Canvas First"
4. Switch to Rust texture
5. Variation: 80%
6. Click Run
7. **Result**: Metal with rust patches

## Tips & Best Practices

### Scale Guidelines
- **Pixel art (low-res)**: Use smaller scales (4-12)
- **Standard resolution**: Medium scales (12-24)
- **Large canvas**: Larger scales (24-48)
- **Rule of thumb**: Scale should be ~1/20th of canvas width

### Color Range Setup
1. Create color range with appropriate colors for texture
2. Order colors from dark to light for best results
3. Use 4-8 colors for most textures
4. More colors = smoother gradients

### Seamless Tiling
- Always enable for backgrounds that will tile
- Test tiling by placing texture side-by-side
- Blend edges are subtle but prevent visible seams

### Seed Management
- Use seed 0 for exploration and variation
- Note interesting seed numbers
- Share seeds with team for consistent assets
- Increment seed by 1 for slight variations

### Layering Textures
1. Generate base texture (e.g., metal)
2. Disable "Clear Canvas First"
3. Generate overlay texture (e.g., rust) with high variation
4. Experiment with different combinations

### Performance
- Large scales generate faster (fewer calculations)
- Cloud and Marble are slower (multiple noise layers)
- Brick and Circuit Board are fastest (simple math)

## Advanced Techniques

### Creating Aged Surfaces
1. Generate clean texture (brick, metal, wood)
2. Layer rust/corrosion over it (disable clear canvas)
3. Result: Weathered, realistic surface

### Parallax Backgrounds
1. Generate clouds at scale 48 (background layer)
2. Generate clouds at scale 24 (midground layer)
3. Generate clouds at scale 12 (foreground layer)
4. Use different seeds for each
5. Result: Multi-layer depth

### Custom Patterns
1. Start with geometric texture (hexagons, circuit board)
2. Layer organic texture (clouds, rust) at low variation
3. Result: Unique hybrid pattern

### Texture Variations
1. Generate texture with seed 100
2. Generate again with seed 101, 102, 103...
3. Result: Subtle variations of same pattern
4. Use for varied but consistent level tiles

## Technical Details

### Noise Functions
The tool uses several noise algorithms:
- **Perlin Noise**: Smooth, natural-looking randomness
- **Turbulence**: Multi-octave noise for complex patterns
- **Seeded Random**: Reproducible pseudo-random values

### Seamless Algorithm
Blends edges by:
1. Creating blend zones at borders (1/8 of dimension)
2. Smoothly transitioning edge pixels
3. Ensuring opposite edges match perfectly
4. Maintains pattern continuity

### Color Mapping
- Textures generate luminance values (0.0 to 1.0)
- Values map to color range by index
- Smoother color ranges = smoother textures
- High-contrast ranges = bold, graphic look

## Troubleshooting

### Problem: Pattern too small/large
- **Solution**: Adjust Scale parameter

### Problem: Too repetitive/boring
- **Solution**: Increase Variation percentage

### Problem: Visible seams when tiling
- **Solution**: Ensure "Make Seamless" is enabled

### Problem: Wrong colors
- **Solution**: Check selected Color Range, ensure it has appropriate colors

### Problem: Pattern identical each time
- **Solution**: Set Seed to 0 for random generation

### Problem: Can't recreate cool pattern
- **Solution**: Note the seed number, use same seed to recreate

## Inspiration & Use Cases

### Game Development
- Level backgrounds (brick, cobblestone)
- Environmental details (wood, metal)
- Sky layers (clouds)
- UI textures (fabric, metal)

### Pixel Art
- Tileable game assets
- Repeating patterns
- Background textures
- Surface materials

### Digital Art
- Textured backgrounds
- Surface effects
- Layer foundations
- Abstract patterns

### Prototyping
- Quick placeholder textures
- Rapid iteration
- Consistent visual style
- Procedural asset pipeline

## Performance Notes

**Generation times (320×200 canvas):**
- Simple textures (brick, fabric): 0.5-1 second
- Medium complexity (wood, scales): 1-2 seconds
- Complex textures (clouds, marble): 2-4 seconds

Larger canvases scale linearly with pixel count.

Happy texture creating! 🎨
