Cocos AIR materials and effects
Stop once you can answer the task. Do not read another same-topic reference for the same question.
Scope: Material recipes, property types, texture defines, instances and custom GLSL.
Environment: use package imports in apps; source paths require an AIR checkout. See context.
Quick Start
For complete setup and teardown, read Quick Start.
Siblings: direct dependencies; reuse loaded skills.
Triggers
- Create unlit or physically shaded materials
- Texture stays flat or setProperty does nothing
- Give objects independent colors or material instances
- Change macros, blend state or depth state
- Write custom GLSL or debug uniform layouts
- Update uniforms per frame
- Add unlit fog or a Sprite mask
- Inspect material and mesh compatibility
Exact API and symptom mappings: triggers.
Contracts
Create materials after app/device initialization. Property names and value types must match the effect; USE_TEXTURE must match the sampling path. Custom GLSL needs declared layouts and built-in bindings.
Read references/contracts.md only when the task needs exact option rules, limits, error behavior or source annotations. Prefer the topic references below for a narrower question.
Common Mistakes
- [HIGH] Enable the correct map macro before setting textures.
- [HIGH] Shared materials and renderer instances have distinct ownership.
- [HIGH] Plain Material runtime recompile/state overrides only warn.
- [MEDIUM] Remove Vulkan-only members from glsl3 variants.
Read relevant wrong/right examples before implementation.
Reference map
AirMorphField polish controls? - Field-owned surface
Which material recipe? - Registration and instances
Property rejected? - Types, aliases and color
Write custom GLSL? - Variants and binding layouts
Texture or macro inert? - Map gates and diagnostics
Black additive effect or empty UBO? - Numeric states and block omission
Copy a complete effect? - JSON, registration and version traps