...
This commit is contained in:
parent
e926f80e55
commit
819bcfac15
1 changed files with 64 additions and 0 deletions
|
|
@ -0,0 +1,64 @@
|
|||
Godot 4.3 does not include a built-in **automated texture atlas generator** for runtime use, but provides tools and workflows for manual atlas creation and optimization:
|
||||
|
||||
---
|
||||
|
||||
### **Manual Atlas Creation**
|
||||
1. **AtlasTexture Resource**
|
||||
Use the `AtlasTexture` class to define sub-regions of a larger texture manually[1][4]. This involves:
|
||||
- Setting the `atlas` property to the base texture
|
||||
- Defining the `region` (coordinates and size) for each sub-texture
|
||||
- Adjusting `margin` and `filter_clip` to prevent bleeding[4]
|
||||
|
||||
2. **TileSetAtlasSource**
|
||||
For tilemaps, use `TileSetAtlasSource` to define grid-based atlases:
|
||||
- Configure `texture`, `margins`, and `separation` properties[3]
|
||||
- Expose tiles via `create_tile()` with grid coordinates[3]
|
||||
|
||||
---
|
||||
|
||||
### **Runtime Atlas Generation**
|
||||
To dynamically pack textures at runtime:
|
||||
1. Use `Image` class to create a blank texture
|
||||
2. Copy pixels from individual textures using `get_pixel()`/`set_pixel()` with calculated offsets[5]
|
||||
3. Convert the final `Image` to a `Texture2D` for rendering
|
||||
|
||||
```gdscript
|
||||
# Example pseudocode for runtime atlas generation
|
||||
var atlas_image = Image.create(atlas_width, atlas_height, false, Image.FORMAT_RGBA8)
|
||||
for texture in textures:
|
||||
var img = texture.get_image()
|
||||
atlas_image.blit_rect(img, img.get_used_rect(), offset)
|
||||
var atlas_texture = ImageTexture.create_from_image(atlas_image)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### **Editor Workflow**
|
||||
1. **Static Atlas Preparation**
|
||||
Use external tools (TexturePacker, Kenney NL) to create pre-packed atlases, then import them as `Texture2D` resources.
|
||||
|
||||
2. **Texture Atlas Importer**
|
||||
Godot's `ResourceImporterTextureAtlas` can split a single texture into multiple `AtlasTexture` resources during import[6], but requires manually created source images.
|
||||
|
||||
---
|
||||
|
||||
### **Performance Considerations**
|
||||
While texture atlases reduce draw calls, modern hardware often minimizes their impact[2]. Prioritize optimization in areas like:
|
||||
- 2D lighting
|
||||
- Particle systems
|
||||
- Overdraw from transparent textures[2]
|
||||
|
||||
For most use cases, manually prepared atlases combined with `AtlasTexture` or `TileSetAtlasSource` provide sufficient optimization without runtime generation[1][3][6].
|
||||
|
||||
Citations:
|
||||
[1] https://docs.godotengine.org/de/stable/classes/class_atlastexture.html
|
||||
[2] https://www.reddit.com/r/godot/comments/1215i6i/does_godot_automatically_make_texture_atlases/
|
||||
[3] https://docs.godotengine.org/en/4.3/classes/class_tilesetatlassource.html
|
||||
[4] https://docs.godotengine.org/en/4.3/classes/class_atlastexture.html
|
||||
[5] https://forum.godotengine.org/t/how-to-generate-a-texture-atlas-from-multiple-images/64985
|
||||
[6] https://docs.godotengine.org/en/4.3/classes/class_resourceimportertextureatlas.html
|
||||
[7] https://github.com/godotengine/godot/issues/92671
|
||||
[8] https://www.youtube.com/watch?v=oEBUXW674dc
|
||||
|
||||
---
|
||||
Answer from Perplexity: https://www.perplexity.ai/search/godot-4-3-texture-atlas-genera-40o0HDS7TciDehf23JYCew?utm_source=copy_output
|
||||
Loading…
Add table
Add a link
Reference in a new issue