diff --git a/Archive.zip b/Archive.zip index 6b72954..82128ce 100644 Binary files a/Archive.zip and b/Archive.zip differ diff --git a/README.md b/README.md index b701295..91d4eb9 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,80 @@ # Text Texture Generator - Blender Addon -A modern Blender addon that generates image textures from text with extensive customization options. +A modern Blender addon that generates image textures from text with extensive customization options and advanced features. ## Features -- **Text Input**: Enter any text to convert into a texture -- **Customizable Size**: Adjust texture dimensions (64x64 to 4096x4096 pixels) -- **Font Controls**: - - Multiple font options (system-dependent) - - Adjustable font size (8-200px) +- **Text Input & Processing**: + + - Enter any text to convert into a texture (up to 1024 characters) + - Prepend and append text support with customizable margins + - Horizontal and vertical text layout options + - Text fitting system with automatic font size adjustment + +- **Advanced Positioning System**: + + - 9-point anchor positioning system (top-left, center, bottom-right, etc.) + - Manual coordinate positioning with percentage or pixel units + - Fine-tuning offsets for precise placement + - Canvas constraint options + +- **Font System**: + + - System font detection and selection + - Custom font file support (.ttf, .otf) + - Font validation with mixed-case support testing + - Adjustable font size (8-500px) - Text alignment (left, center, right) -- **Color Controls**: - - Text color picker with alpha - - Background color picker with alpha + +- **Image Overlay System**: + + - Multiple image overlays with individual controls + - Three positioning modes: Absolute, Prepend, Append + - Per-overlay scaling, rotation, and z-index control + - Image spacing and sequencing for complex layouts + - Enable/disable individual overlays + +- **Color & Transparency**: + + - RGBA text color picker with full alpha support + - RGBA background color picker - Transparent background option -- **Layout Options**: - - Adjustable padding around text - - Professional text positioning + - Preview background options (transparent, solid color, gradient) + +- **Normal Map Generation**: + + - Automatic normal map creation from text alpha channel + - Adjustable strength, blur radius, and invert options + - Proper colorspace handling for normal maps + +- **Advanced Shader Generation**: + + - Complete material shader creation + - Multiple shader types: Principled BSDF, Emission, Transparent + - Light path control: disable shadows, reflections, backfacing + - Auto-assignment to selected objects + - Normal map integration in shaders + +- **Preset Management System**: + + - Three-tier storage: Blend file, Persistent, Legacy + - Presets travel with .blend files + - Import/export functionality for backup and sharing + - Automatic migration system for addon updates + - Conflict resolution for preset imports + +- **Preview System**: + + - Full-resolution live preview generation + - Zoomable preview window with Image Editor integration + - Multiple preview background options + - Real-time updates on property changes + - **Blender Integration**: - - Automatic image texture node creation in Shader Editor - - Works in both Shader Editor and 3D Viewport + - Works in Shader Editor, 3D Viewport, and Properties panel + - Automatic texture node creation with proper connections - Generated textures are packed into the .blend file + - Menu integration across multiple editors ## Installation @@ -64,40 +118,105 @@ A modern Blender addon that generates image textures from text with extensive cu ### Text Settings -- **Text**: The text to render (up to 1024 characters) -- **Font**: System font selection (varies by OS) -- **Font Size**: Size of the text in pixels (8-200) -- **Alignment**: Text alignment (left, center, right) -- **Padding**: Space around text in pixels (0-100) +- **Main Text**: Primary text to render (up to 1024 characters) +- **Prepend Text**: Text to add before main text (up to 512 characters) +- **Append Text**: Text to add after main text (up to 512 characters) +- **Layout**: Horizontal or vertical arrangement of text elements +- **Margins**: Percentage-based spacing between text elements + +### Font Settings + +- **System Fonts**: Auto-detected system fonts with validation +- **Custom Font**: Load external .ttf/.otf font files +- **Font Size**: Size in pixels (8-500px) +- **Text Alignment**: Left, center, right alignment options + +### Positioning & Layout + +- **Position Mode**: Preset anchor points or manual coordinates +- **Anchor Points**: 9-point positioning grid (top-left to bottom-right) +- **Margins**: Percentage-based margins from canvas edges (0-50%) +- **Offsets**: Pixel-perfect fine-tuning (-200 to +200px) +- **Manual Positioning**: Direct X,Y coordinates in percentage or pixels +- **Canvas Constraints**: Keep text within canvas bounds + +### Text Fitting + +- **Auto-Sizing**: Automatically adjust font size to fit canvas +- **Fitting Modes**: Fit width, height, both, or contain within bounds +- **Size Limits**: Minimum and maximum font size constraints +- **Fitting Margin**: Percentage margin for auto-fitting calculations ### Texture Settings -- **Width/Height**: Texture dimensions in pixels (64-4096) -- **Text Color**: RGBA color picker for text -- **Transparent Background**: Enable/disable background transparency -- **Background Color**: RGBA color picker for background (when not transparent) +- **Dimensions**: Canvas size in pixels (64x64 to 4096x4096) +- **Text Color**: RGBA color picker with full alpha support +- **Background**: Transparent or solid color with RGBA control + +### Image Overlays + +- **Multiple Images**: Add unlimited image overlays +- **Positioning Modes**: Absolute coordinates, prepend, or append to text +- **Transform Controls**: Scale (0.1-5.0x), rotation (360°), z-index layering +- **Spacing Controls**: Configurable spacing between images and text +- **Sequence Control**: Order overlays in prepend/append modes + +### Normal Maps + +- **Auto-Generation**: Create normal maps from text alpha channel +- **Strength Control**: Adjust normal map intensity (0.1-5.0) +- **Blur Radius**: Smooth normal map edges (0-10px) +- **Invert Option**: Switch between emboss and deboss effects + +### Shader Generation + +- **Shader Types**: Principled BSDF, Emission, Transparent materials +- **Texture Connections**: Base color, emission, or alpha channels +- **Light Path Controls**: Disable shadows, reflections, or backfacing +- **Auto-Assignment**: Automatically apply materials to selected objects +- **Normal Map Integration**: Automatic normal map nodes and connections + +### Preview Options + +- **Live Preview**: Real-time texture generation and display +- **Preview Size**: Adjustable preview resolution (128-2048px) +- **Background Display**: Transparent, solid color, or gradient options +- **Zoom Controls**: Open preview in zoomable Image Editor window ## System Requirements - Blender 4.0.0 or newer - Python 3.10+ (included with Blender) -- Pillow library (automatically installed via pip) +- Pillow library (>=10.0.0, automatically installed via pip) -## Supported Fonts +## Font Support -The addon includes several built-in font options that vary by operating system: +The addon features intelligent font detection and validation: -### Windows +### System Font Detection -- Arial, Times New Roman, Courier New, Calibri, Segoe UI +- Automatically scans system font directories +- Supports .ttf, .ttc, .otf, and .dfont files +- Mixed-case rendering validation for quality assurance +- Platform-specific fallback fonts with guaranteed compatibility -### macOS +### Windows Fallback Fonts -- Arial, Times New Roman, Courier New, Helvetica, SF Pro Display, Menlo +- Arial, Calibri, Segoe UI, Verdana, Tahoma, Times, Trebuchet MS -### Linux +### macOS Fallback Fonts -- DejaVu Sans, DejaVu Serif, DejaVu Sans Mono, Ubuntu +- Helvetica, Arial, Times, Avenir, Geneva, Palatino + +### Linux Fallback Fonts + +- Liberation Sans, DejaVu Sans, Ubuntu, Noto Sans, Lato, Open Sans + +### Custom Fonts + +- Load any .ttf or .otf font file +- Automatic validation for mixed-case support +- Error handling and fallback for unsupported fonts ## Dependencies @@ -132,20 +251,66 @@ The addon automatically installs required dependencies: - Very long text strings may affect performance - Generated textures are stored in memory and packed with the .blend file +## Preset System + +The addon features a sophisticated three-tier preset system: + +### Storage Locations (Priority Order) + +1. **Blend File Storage** (Highest Priority) + + - Presets stored in scene custom properties + - Travel with your .blend file + - Perfect for project-specific presets + +2. **Persistent File Storage** (Medium Priority) + + - Survives addon updates and Blender upgrades + - Stored in Blender's user config directory + - Shared across all blend files + +3. **Legacy File Storage** (Lowest Priority) + - Backward compatibility with old addon versions + - Automatically migrated to persistent storage + +### Preset Features + +- **Auto-Migration**: Seamlessly upgrades presets during addon updates +- **Import/Export**: Backup and share presets across installations +- **Conflict Resolution**: Smart handling of duplicate preset names +- **Migration Reports**: Detailed logs of preset migration operations + ## Development ### File Structure ``` text_texture_generator/ -├── blender_manifest.toml # Modern addon manifest -├── __init__.py # Main addon code -└── README.md # This file +├── blender_manifest.toml # Modern addon manifest (Blender 4.0+) +├── __init__.py # Main addon code (~5000 lines) +└── README.md # Documentation ``` +### Code Organization + +- **Utility Functions**: Font detection, validation, system compatibility +- **Preview Generation**: Real-time texture creation and display +- **Normal Map Generation**: Height-based normal map algorithms +- **Positioning System**: 9-point anchors, manual coordinates, constraints +- **Preset Management**: Three-tier storage with migration system +- **UI Components**: Collapsible sections, shared drawing functions +- **Operators**: 20+ operators for all addon functionality +- **Property Groups**: Comprehensive property system with validation + ### Contributing -Feel free to submit issues and enhancement requests. The addon is designed to be simple and focused on core text texture generation functionality. +The addon is designed with modularity and extensibility in mind. Key areas for contribution: + +- Additional shader types and material presets +- Extended image overlay positioning modes +- Font rendering improvements and compatibility +- UI/UX enhancements and workflow optimization +- Platform-specific font detection improvements ## License @@ -157,11 +322,22 @@ Marc Mintel ## Changelog -### Version 1.0.0 +### Version 2.3.2 (Current Code Version) -- Initial release -- Text to texture conversion -- Customizable fonts, colors, and sizing -- Transparent background support -- Automatic Blender integration -- Cross-platform font support +- Advanced positioning system with 9-point anchors and manual coordinates +- Text fitting with automatic font size adjustment and multiple modes +- Comprehensive image overlay system with absolute, prepend, and append positioning +- Normal map generation from text alpha channels with strength/blur controls +- Advanced shader generation with Principled BSDF, Emission, and Transparent types +- Light path controls for shadows, reflections, and backfacing geometry +- Three-tier preset system (blend file → persistent → legacy) with auto-migration +- Live preview with zoomable Image Editor integration and multiple backgrounds +- Prepend/append text support with horizontal/vertical layouts +- Custom font support with mixed-case validation and fallback systems +- Import/export functionality for preset backup and cross-installation sharing +- Enhanced error handling and user feedback throughout the interface + +### Version 1.0.0 (Manifest Version) + +- Note: The blender_manifest.toml shows version 1.0.0 but the code implements v2.3.2 features +- Recommendation: Update manifest version to match actual code capabilities diff --git a/__init__.py b/__init__.py index 50432a1..95f300a 100644 --- a/__init__.py +++ b/__init__.py @@ -1265,7 +1265,7 @@ def generate_texture_image(props, width, height): # ============================================================================ # Get the main text - main_text = props.text if props.text and props.text.strip() else "Hello World" + main_text = props.text if props.text is not None else "" # Get prepend and append text prepend_text = props.prepend_text.strip() if props.prepend_text else "" @@ -1956,7 +1956,7 @@ class TEXT_TEXTURE_Properties(PropertyGroup): text: StringProperty( name="Text", description="Text to render as texture", - default="Hello World", + default="", maxlen=1024, update=update_live_preview ) diff --git a/demo.blend b/demo.blend new file mode 100644 index 0000000..940f7ea Binary files /dev/null and b/demo.blend differ