AtlasDefinition
A class in Root.Township, Alta.Utilities.Atlas.
Asset describing a texture atlas: which materials it combines into one baked material, and where each sits in the atlas. ApplyTo swaps renderers over to the baked material and rewrites their mesh UVs. Mostly a build and editor tool.
- Listed in Utilities and other Alta namespaces
- Inherits or implements
ScriptableObject - Nested types
AtlasedMaterial,MaterialReferences
Constructors
| Member | What it is |
|---|---|
AtlasDefinition() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
| Member | What it is |
|---|---|
string atlasedMaterialName | Base name for the atlas's files. |
int atlasSize | Atlas texture size in pixels (a power of two). |
Material bakedMaterial | The combined material renderers are switched to. |
string freeDetails | Text describing how full the atlas is. |
int generalPaddingValue | Default padding between atlas entries. |
bool isDisablingAlphaOnDifuse | Turns off alpha in the diffuse atlas. Forced on for metal atlases. |
bool isForcingNoEmission | Leaves emission out of the atlas. |
List<AtlasDefinition.AtlasedMaterial> materials | The materials in the atlas, each with its rectangle, scale and padding. |
bool needsToBake | Set when the atlas needs to be baked again. |
uint priority | Order among atlases. |
int smallestTextureHeight | Height of the smallest texture in the atlas. |
int smallestTextureWidth | Width of the smallest texture in the atlas. |
AtlasTarget target | Flags for which builds or uses this atlas targets. |
AtlasType type | Kind of atlas, which picks the atlased shader (common, foliage, metal). |
UVFixType uvFixType | How UVs are remapped: through an extra UV channel (Texcoord) or by rewriting UV 0 (None). |
5 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<int, Mesh> bakedMeshes | Cache of atlased meshes keyed by a mesh and material hash, so each pair is only rebuilt once. Cleared by ClearBakedMeshes. |
private static List<Color> colors | Shared scratch list of colours. |
private static Logger logger | NLog logger for this class. |
private Dictionary<Material, AtlasDefinition.AtlasedMaterial> materialReferences | Lookup from source material to its AtlasedMaterial entry, built by PrepareReferences. |
private static List<Vector4> offsetScaleUVs | Shared scratch list of UVs reused by FixMeshUVs. |
Properties
| Member | What it is |
|---|---|
static string BasePath { get; } | Resource folder for atlases: Atlases/Standalone/ or Atlases/Android/. |
static string DefinitionsPath { get; } | Folder for atlas definitions under BasePath. |
6 private and internal properties
Methods
| Member | What it is |
|---|---|
bool ApplyTo(IEnumerable<Renderer> renderers, bool isSavingMeshAsAsset = false, bool isSavingToTemporaryFolder = false) | Points matching renderers (or one mesh) at the baked material, using UV-fixed mesh copies that are cached. True if anything changed. |
bool ApplyTo(Mesh originalMesh, Material baseMaterial, out Mesh resultMesh, bool isSavingToTemporaryFolder = false) | Points matching renderers (or one mesh) at the baked material, using UV-fixed mesh copies that are cached. True if anything changed. |
void AutoEstimateSize(bool forceRebake = true) | Works out the atlas size from the materials' texture sizes and fills in freeDetails. Marks it for rebake by default. |
void Bake() | Runs AutoEstimateSize if the atlas has a name and materials. It does not draw the atlas itself. |
void ClearBakedMeshes() | Forgets the cached UV-fixed meshes. |
IEnumerable<Renderer> FilterRenderers(IEnumerable<Renderer> renderers) (iterator) | Yields the renderers that use any of the atlas's materials (once per matching material). |
bool GetMaterialRect(Material material, out AtlasDefinition.AtlasedMaterial reference) | Finds the atlas entry for a material. |
bool IsTargeting(AtlasTarget target) | True if the atlas is for the given target. |
void PrepareReferences() | Rebuilds the material lookup and clears the mesh cache. |
void PrepareReferencesIfNeeded() | Builds the material lookup if it is empty. |
void UpdateShader() | Sets the baked material's shader from the atlas type. |
8 private and internal methods
Used in
Members of other types that take, return or hold a AtlasDefinition:
MeshPlacementData.BakeAtlas, MeshPlacementData.forcedAtlasDefinition, TreeAttachment.GenerateRenderers, TreeSpecies.FixMaterials, WoodcutTreeBaker.attachmentDefinitions, WoodcutTreeBaker.trunkDefinitions, ForcedAtlasDefinition.androidDefinition, ForcedAtlasDefinition.standaloneDefinition, PhysicalMaterial.Setup, PhysicalMaterial.MaterialChannel.SetupOffsetScale, PooledMeshReplaceObjectDefinition.Bake.