Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-materials-effects

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Configure materials, effects, uniforms, defines and GLSL. Diagnose black/invisible effects, missing textures, setProperty, AIR_E_MATERIAL_NOT_READY or AIR_E_MATERIAL_TYPE.

  • 12 files
  • 116 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-materials-effects

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescontext.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Working context

Use package imports and shipped docs for an application; use source paths and repository commands only in a confirmed AIR checkout. A copied host skill is not a runtime installation.

Read the shared environment rules when locating these roots. If sibling resources are unavailable, use the installed canonical chapter and disclose the limitation. Tool declarations identify workflow capabilities; they do not authorize installation, writes, publication or any action outside the user and host scope.

Related skills

  • cocosair - routing and shared Code First constraints; reuse it if already loaded.
  • cocosair-project-setup - which entry exposes Material and EffectAsset.
  • cocosair-application - the device-initialization ordering that Material.initialize depends on.
  • cocosair-scene-graph - MeshRenderer attachment, node.layer bits a material's draws are culled against.
  • cocosair-camera - camera.visibility and clear flags decide whether a correct material is visible at all.
  • cocosair-math - Color, Vec3, Vec4, Mat3, Mat4, Quat values a setProperty call must carry.
  • cocosair-graphics-and-dom - the ui-graphics-material / builtin-graphics path and canvas-backed textures.
  • cocosair-verification - pixel readback recipes that prove a material actually rendered.

Lighting, shadows and the post-process pipeline belong to the cocosair-rendering skill; mesh primitives and multi-material sub-models to cocosair-primitives-mesh; SkinnedMeshRenderer macro handling to cocosair-skinning-morph; UI 2D materials to cocosair-ui-2d; glTF material import to cocosair-gltf. Use the matching existing skill as a direct dependency; keep material authoring here.

Original entry guidance

The original entry wording below is an on-demand archive, not a second routing source.

Use the environment rules to locate the checkout or installed package; sibling skills are optional direct dependencies, not a recursive load list.

A material in AIR is one effect recipe plus a bag of uniform values: new Material(), initialize({ effectName }) picks the recipe, setProperty(name, value) fills it. There is no material inheritance tree, no ShaderMaterial, and no Editor asset pipeline - recipe names are strings and custom shaders are hand-written compiled effect JSON.

Read references/quick-start.md when constructing the minimal example. It preserves the complete setup and teardown sequence; select the source-checkout or npm-consumer environment first.

Read references/context.md to select the owner of this step and only its directly needed dependencies. Reuse already loaded skills; this is not a recursive load list.

Original mistake navigation

Before implementing the relevant path, read its wrong/right examples in references/common-mistakes.md:

  • [HIGH] Setting the texture without its map macro
  • [HIGH] Writing a shared material after the renderer instantiated it
  • [HIGH] Calling the runtime recompile and state-override API on a plain Material
  • [MEDIUM] Hand-writing a glsl3 variant that keeps Vulkan-only members

Original metadata

Description and description_en

The two original fields contained exactly the same value, retained once here.

Author and drive Cocos AIR materials in a Code First scene - new Material() plus initialize({effectName, defines, technique, states}), the 21 registered AIR effect entries and 17 builtin materials, setProperty value types for float, Vec3, Vec4, Color, Texture2D and arrays, the USE_TEXTURE versus USE_ALBEDO_MAP define gates, handleInfo property aliases, MaterialInstance versus shared materials, the Pass warn stubs for recompileShaders and overridePipelineStates, the glsl4 to glsl3 source transform, the set and binding layout assignEffectBindings enforces including CCSkinning at binding 3, createAirUnlitFogEffect, attachAirSpriteMask and inspectAirMaterial. Use when creating or configuring a Material or EffectAsset, picking builtin-standard or builtin-unlit, setting a color, texture or uniform array, overriding blend or depth state, writing custom GLSL, or debugging AIR_E_MATERIAL_NOT_READY, AIR_E_MATERIAL_TYPE, uniform buffer too small, a flat untextured surface or a setProperty call that does nothing.

Keywords

Cocos AIR, cocosair.js, materials, effects

References

  • builtin-effects.md - the 21 registered effect entries with definition lines, the 17 builtin material uuids with their effectName and defines, the registration and tryCompile timing, and which names are absent from the bundle export list.
  • property-types.md - gfx.Type ordinals, the accepted-JS-value matrix per declared type with its error codes, Color byte-versus-fraction conversion, linear: true handling, the setProperty step order, handleInfo alias tables, and the full settable property lists of builtin-standard and builtin-unlit.
  • custom-glsl.md - effect JSON field contract, variant selection, the four glsl4 -> glsl3 rules, the assignEffectBindings set/binding matrices including CCSkinning -> 3 and why, registration timing, the effect-json.mjs generator and effect-layout.ts pre-check, black-screen triage order.
  • defines.md - where a macro must appear to have any effect, USE_TEXTURE versus USE_ALBEDO_MAP, the inert USE_COLOR define, the complete declared define lists of unlit, sprite and standard, runtime macro changes, fog defines and createAirUnlitFogEffect, define read-back and diagnostics.

Canonical docs

docs/manual/materials.md, docs/manual/custom-shaders.md, docs/manual/uniform-types.md. Runnable references: examples/shader-custom-gradient, examples/shader-dissolve, examples/material-basic, examples/material-color, examples/material-unlit, examples/material-ops, examples/material-lifecycle.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Edit Write Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "setProperty changes nothing",
  "texture missing after setProperty",
  "different colors for each renderer",
  "change blend or depth state",
  "custom GLSL shader fails"
]
owns
[
  "material",
  "effect",
  "uniform-types",
  "shader-defines",
  "custom-glsl",
  "material-instance"
]
not_for
[
  "lighting, shadows or post-process -> cocosair-rendering",
  "glTF material import -> cocosair-gltf",
  "mesh geometry and sub-models -> cocosair-primitives-mesh"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "配置材质、效果、属性类型、宏和自定义 GLSL。用于 USE_TEXTURE、uniform 类型、效果初始化或材质诊断问题。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-materials-effects