Logo Uv And Mesh Attributes

Uv And Mesh Attributes

Cộng đồng
TMHSDigital
uv-and-mesh-attributes

Author per-loop and per-vertex mesh data from Python: UV layers (mesh.uv_layers.new, bmesh loops.layers.uv, the calc_uvs=True silent no-op), a second lightmap UV channel and its active / active_render flags, loop tangents (calc_tangents, bitangent_sign), color attributes and their CORNER vs POINT domain, shape keys (shape_key_add, key_blocks data), and vertex-group weights capped at four influences. Re-fetch layers by name after CustomData-reallocating calls. Use when the user creates or edits UVs in a script, builds a lightmap channel, computes tangents for normal maps, writes vertex colors, authors shape keys or limits skin weights, or gets a mesh that renders one flat color, a wrong UV channel, a crash or silently wrong values from a held layer. Targets 5.2 LTS with 4.5 LTS fallback.

Tổng quan

Nhà phát hànhTMHSDigital
Kho mãBlender-Developer-Tools
Tên kỹ nănguv-and-mesh-attributes
Sao
20
Bản fork
5
Tệp đi kèm
Chỉ có hướng dẫn
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được TMHSDigital công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Uv And Mesh Attributes trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/TMHSDigital/Blender-Developer-Tools/tree/main/skills/uv-and-mesh-attributes
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/TMHSDigital/Blender-Developer-Tools.git /tmp/Blender-Developer-Tools
mkdir -p .claude/skills
cp -r /tmp/Blender-Developer-Tools/skills/uv-and-mesh-attributes .claude/skills/uv-and-mesh-attributes
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Uv And Mesh Attributes trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Uv And Mesh Attributes ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Uv And Mesh Attributes với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

UV Layers and Mesh Attributes

Trigger

Use this skill when the user:

  • Creates or edits UVs from a script (mesh.uv_layers, bm.loops.layers.uv, calc_uvs=True)
  • Builds a second UV channel for baked lighting, or runs uv.lightmap_pack / uv.smart_project on it
  • Computes tangents for a normal-mapped game asset (calc_tangents, bitangent_sign)
  • Writes vertex colors (color_attributes, the deprecated vertex_colors)
  • Authors shape keys or reads a blended shape
  • Caps skin weights at four influences per vertex for a game engine
  • Reports a textured mesh that renders as one flat color, a UV op that wrecked channel 0, a crash or garbage values after calc_tangents, or weights that sum short of one

High-level shape

Every one of these lives in the mesh's CustomData. Three rules cover most bugs: create the layer before anything that fills it, address layers by name, and re-fetch a layer by name after any call that can reallocate CustomData.

python
import bmesh
import bpy

me = bpy.data.meshes.new("Panel")
bm = bmesh.new()
try:
    bm.loops.layers.uv.new("UVMap")  # first: calc_uvs only fills an existing layer
    bmesh.ops.create_grid(bm, x_segments=4, y_segments=4, size=1.0, calc_uvs=True)
    bm.to_mesh(me)
finally:
    bm.free()

me.uv_layers.new(name="UVLight")      # a second channel does NOT become active
assert me.uv_layers.active.name == "UVMap"
assert me.uv_layers["UVMap"].active_render

me.calc_tangents(uvmap="UVMap")       # reallocates loop CustomData
uv = me.uv_layers["UVMap"].data       # so re-fetch by name after it
co = [0.0] * (len(me.loops) * 2)
uv.foreach_get("uv", co)
assert len(me.loops) == 64 and min(co) >= -1e-6 and max(co) <= 1.0 + 1e-6

col = me.color_attributes.new("Tint", 'FLOAT_COLOR', 'CORNER')
assert len(col.data) == len(me.loops)  # CORNER is per loop, not per vertex

UV layers

  • mesh.uv_layers.new(name="UVMap") on a Mesh, bm.loops.layers.uv.new("UVMap") on a BMesh. Look layers up with mesh.uv_layers["UVMap"], never by index or "the first one".
  • calc_uvs=True is a silent no-op without a layer. bmesh.ops.create_grid (and the other primitive ops) only fill a UV layer that already exists on the BMesh. With none, the flag does nothing, to_mesh leaves mesh.uv_layers empty, and an Image Texture samples texel (0, 0) everywhere: the mesh renders one flat color. Create the layer first, or assign UVs yourself.
  • Bulk-read and write UVs with uv_layer.data.foreach_get("uv", flat) / foreach_set, sized len(mesh.loops) * 2. UVs are per loop (face corner), not per vertex.

A second (lightmap) channel

Engines bake lighting into UV1. Two flags decide which channel a tool touches:

FlagMeaning
uv_layer.active (mesh.uv_layers.active)the layer edit-mode UV operators read and write
uv_layer.active_renderthe layer the renderer and exporters treat as the primary UV
  • uv_layers.new() does not move either flag. The first layer keeps both, so an unwrap or pack after adding UVLight runs on channel 0 and destroys it (measured drift 2.068 in lightmap-uv-channel). Set mesh.uv_layers.active = mesh.uv_layers["UVLight"] before the UV op.
  • Edit-mode UV operators clear both flags. Re-assert them afterwards: active on the channel you edit, active_render on UVMap.
  • bpy.ops.uv.lightmap_pack exits OK while packing nothing when its context is wrong; check the result (bounds in [0, 1], non-overlap), not the return value.

Handle lifetime: re-fetch by name

A MeshUVLoopLayer, attribute or color-attribute object is a view into CustomData. Calls that reallocate CustomData leave held views dangling:

  • mesh.calc_tangents(), VertexGroup.add(), adding or removing modifiers or layers, edit-mode UV operators
  • On 4.5 LTS a held UV handle read after calc_tangents returns tangent floats instead of UVs: exit 0, silently wrong (measured in triangulate-tangents). Iterating a held uv_layer.data after edit-mode UV ops segfaulted 4.5.11 headless (5 of 5 runs). On 5.1 and 5.2 the same stale read survives by memory-layout luck, which hides the bug.

Fetch the layer by name again after each such call, as the block above does.

Tangents

  • mesh.calc_tangents(uvmap="UVMap") fills loop.tangent and loop.bitangent_sign; the bitangent is bitangent_sign * normal.cross(tangent).
  • It needs triangles and quads. One n-gon anywhere aborts the whole call: triangulate first, or build caps as triangle fans.
  • Tangents follow the UVs, so planar UVs on a curved wall collapse the tangent onto the normal. Unwrap the wall instead.
  • mikktspace output is identical on 4.5.11, 5.1.2 and 5.2.1; a difference between versions points at a stale handle, not the math.

Color attributes

  • Use mesh.color_attributes.new(name, type, domain). mesh.vertex_colors is the deprecated alias.
  • The domain sets the length: 'CORNER' is per loop (len(mesh.loops)), 'POINT' is per vertex. Per-vertex data written to a CORNER attribute must be expanded across each vertex's corners.
  • A material only shows it through a Shader Attribute node (attribute_type='GEOMETRY', attribute_name set) wired into Base Color. Without that node the mesh stays gray even when the data is right.

Shape keys

  • obj.shape_key_add(name="Basis", from_mix=False) first, then the target key. Write the target with key_blocks["Tall"].data.foreach_set("co", flat).
  • A shape key does not rewrite mesh.vertices: those stay at Basis. Read the blended shape from the evaluated mesh (obj.evaluated_get(depsgraph).to_mesh(), then to_mesh_clear()), where each vertex is basis + value * (key - basis).

Skin weights: four influences

  • Engines cap skinning at four bone influences per vertex. Enforce it on the data API rather than bpy.ops.object.vertex_group_limit_total: read v.groups, keep the four heaviest, VertexGroup.remove([v.index]) the rest, then renormalize the survivors to sum to one. Dropping without renormalizing shrinks the mesh toward the origin under load.
  • The weights on the mesh (v.groups) are the contract, not the weights you meant to write: read them back to check.
  • The vertex-group API is the same on 4.5 LTS and 5.2.

Common AI mistakes

  • Trusting calc_uvs=True on a BMesh with no UV layer.
  • Adding UVLight and unwrapping without moving active, or forgetting that edit-mode UV ops cleared active_render.
  • Holding uv = mesh.uv_layers.active.data across calc_tangents() or other reallocating calls.
  • Calling calc_tangents on a mesh with an n-gon.
  • Sizing CORNER color data by vertex count, or never adding the Attribute node.
  • Reading shape-key results from mesh.vertices.
  • Removing extra skin influences without renormalizing.

See also

  • mesh-editing-and-bmesh: bmesh ownership, foreach_get / foreach_set, evaluated meshes
  • depsgraph-and-evaluated-data: the to_mesh / to_mesh_clear lifetime
  • engine-export-presets: exporting UV1, tangents and weights to Unity, Godot and Unreal

Runnable examples

Each example runs headless, asserts the contract, and exits non-zero when it breaks. Run one with blender --background --python <script> --; pass a falsifier flag to watch the check fail.

  • color-attribute-wheel: The modern color-attributes API — mesh.color_attributes.new() on the CORNER domain. Falsify: --point-domain (exit 6).
  • lightmap-uv-channel: A market cart carrying the two-channel UV contract for baked lighting: UV0 untouched, UVLight packed with no overlaps and a respected margin. Falsify: --overlap-islands (exit 7).
  • shape-key-blend: A relative Tall shape key that turns a squat ceramic jar into a trumpet vase. Falsify: --zero-blend (exit 5).
  • triangulate-tangents: A machined buckler verifying the tangent-space contract a game engine's normal mapping depends on. Falsify: --zero-uv (exit 4).
  • uv-layer-grid: The UV-layer authoring hazard — bmesh.ops.create_grid(..., calc_uvs=True) is a silent no-op unless a UV layer already exists; without one an Image Texture samples texel (0,0) everywhere. Falsify: --precreate-on-hazard (exit 3).
  • vertex-weight-limit: A rigged industrial robot arm pruned to the game-engine cap of four bone influences per vertex, through the data API. Falsify: --skip-limit (exit 4).

References

Câu hỏi thường gặp

Kỹ năng AI Uv And Mesh Attributes làm được gì?

Author per-loop and per-vertex mesh data from Python: UV layers (mesh.uv_layers.new, bmesh loops.layers.uv, the calc_uvs=True silent no-op), a second lightmap UV channel and its active / active_render flags, loop tangents (calc_tangents, bitangent_sign), color attributes and their CORNER vs POINT domain, shape keys (shape_key_add, key_blocks data), and vertex-group weights capped at four influences. Re-fetch layers by name after CustomData-reallocating calls. Use when the user creates or edits UVs in a script, builds a lightmap channel, computes tangents for normal maps, writes vertex color...

Vì sao nên dùng Uv And Mesh Attributes trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Uv And Mesh Attributes là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Uv And Mesh Attributes trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/TMHSDigital/Blender-Developer-Tools/tree/main/skills/uv-and-mesh-attributes. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Uv And Mesh Attributes?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Uv And Mesh Attributes với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Uv And Mesh Attributes với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Uv And Mesh Attributes có miễn phí không?

Kỹ năng này được TMHSDigital phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇