Skip to content
Skills Library
Programming · Building & coding

depth-sorting-occlusion

/depth-sorting-occlusion

Use when sprites draw in the wrong order so characters appear in front of objects they should be behind in an isometric scene.

Licence
MIT
Last repository change
12.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 12.08.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when sprites draw in the wrong order so characters appear in front of objects they should be behind in an isometric scene.

Original author description

Use when sprites draw in the wrong order so characters appear in front of objects they should be behind in an isometric scene.

How it works

  1. Overview
  2. When to Use
  3. Process
  4. Rationalizations (Stop Lying to Yourself)
  5. Red Flags - STOP if you catch yourself:
  6. Verification
Original SKILL.md headings · 48 lines, 294 words
SKILL.md preview
---
name: depth-sorting-occlusion
description: Use when sprites draw in the wrong order so characters appear in front of objects they should be behind in an isometric scene.
license: MIT
---

# Depth Sorting & Occlusion

## Overview

In isometric, draw order IS depth. A character is behind a tree if its anchor tile sorts earlier. This skill gives the correct sort key and handles tall/multi-tile objects that break naive sorting.

## When to Use

- Characters render in front of trees/walls they should be behind.
- Tall or multi-tile objects sort incorrectly.
- You added objects and the layering looks wrong.

## Process

1. Give every drawable a depth key based on its anchor tile: depth = row + col.
2. Sort all objects by depth ascending before drawing.
3. For ties, break by a secondary key (e.g. y, then creation order).
4. For multi-tile objects, sort by the FRONT-most occupied tile.
5. For very tall objects, consider splitting into stackable slices.
6. Re-sort only when objects move, not every frame if static.
7. Test the classic case: walk a character around all four sides of a tree.

```js
objects.sort((a, b) => (a.row + a.col) - (b.row + b.col));
```

## Rationalizations (Stop Lying to Yourself)

| Excuse | Reality |
|---|---|
| "Painter order by y is good enough" | Pure y fails for multi-tile and tall sprites. Use anchor row+col. |
| "I will sort once at load" | Moving objects must re-sort. Sort on movement. |

## Red Flags - STOP if you catch yourself:

- Sorting by raw y instead of anchor tile.
- Multi-tile objects using their center instead of front tile.
- Characters clipping through tall buildings.

## Verification

You are NOT done until every box is checked:

- [ ] Walking around all sides of an object always sorts correctly.
- [ ] Multi-tile and tall objects occlude properly.
- [ ] Sorting updates when objects move.
Files in this package (2)
  • SKILL.md 2 KB
  • assets/depth-sorting.svg 3 KB

Versions

The database has no other skills named depth-sorting-occlusion.

Database snapshot: 13.11.2026 · package version 6ca253ec3c10 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100iwsdk-depth-occlusion
    Add or repair IWSDK WebXR depth sensing and real-world occlusion in AR. Use for DepthSensingSystem, DepthOccludable, occlusion modes, or passthrough depth troubleshooting.
  • 90isometric-character-sprites
    Use when generating isometric characters in consistent 8 directions with a fixed feet-anchor for movement and depth sorting.
  • 100unity-2d
    Unity 6 2D game development guide. Use when building 2D games, working with sprites, sprite atlas, SpriteRenderer, tilemaps, 2D physics (Rigidbody2D, Collider2D), 2D lighting, sorting layers, or sorting groups. Based on Unity 6.3 LTS documentation.
  • 100unity-2d-core
    Unity 2D fundamentals — Sprite Renderer, Sprite Atlas v2 (master/variants), 9-slice rendering, Sorting Layers vs Order in Layer vs Sorting Group, sprite import settings, Pixels Per Unit (PPU), Pixel Perfect Camera, point filtering. USE WHEN: importing sprites, packing atlases,…
  • 100canvas-performance-optimization
    Use when an isometric Canvas game drops frames, to cut draw calls and allocations and hold a steady 60fps.
  • 90add-sprite-assembly-into-threejs-engine
    Create or fix a Three.js billboard mode from verified sprite data. Use when adding a character group, wiring a mode into the demo cards, or debugging a layer, pattern, draw order, mirrored direction or hand-held prop in Three.js.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.