Skip to content

t1k:unity:dots-rendering:perspective-framework

FieldValue
Moduledots-rendering
Version2.1.7
Efforthigh
Tools

Keywords: DOTS, framework, perspective, rendering

/t1k:unity:dots-rendering:perspective-framework

Shared foundation patterns used by all 4 perspective skills. Each perspective skill extends this with dimension-specific overrides. Does NOT handle perspective-specific logic — see per-perspective skills below.

PerspectiveSkillKey Overrides
2D top-downdots-perspective-2d-topdownOrtho -Y camera, XZ-plane quads
2D side-viewdots-perspective-2d-sideviewOrtho +Z camera, XY-plane quads
Isometricdots-perspective-isometricIso projection, diamond layout
3Ddots-perspective-3dPerspective camera, world-space meshes
// Vertices (CCW winding, local space, centered at origin)
var verts = new NativeArray<float3>(4, Allocator.Temp)
{
[0] = new float3(-0.5f, 0f, 0.5f), // TL
[1] = new float3( 0.5f, 0f, 0.5f), // TR
[2] = new float3( 0.5f, 0f, -0.5f), // BR
[3] = new float3(-0.5f, 0f, -0.5f), // BL
};
// UVs
var uvs = new NativeArray<float2>(4, Allocator.Temp)
{
[0] = new float2(0,1), [1] = new float2(1,1),
[2] = new float2(1,0), [3] = new float2(0,0),
};
// Normals (all up for floor quad; override per-perspective for billboards)
var normals = new NativeArray<float3>(4, Allocator.Temp);
for (int i = 0; i < 4; i++) normals[i] = math.up();
// Triangles
var tris = new NativeArray<int>(6, Allocator.Temp) { [0]=0,[1]=1,[2]=2,[3]=0,[4]=2,[5]=3 };

Billboard quads: normals face camera — override normals in perspective skill, or use Shader Graph Vertex Normal node.

  1. Shader: Universal Render Pipeline/Unlit or custom Shader Graph
  2. Surface Type: Transparent with Alpha Clipping enabled
  3. Properties: _BaseMap (sprite atlas), _Cutoff (0.5 default)
  4. In Shader Graph: connect Alpha output → Alpha Clip Threshold node

Per-perspective skills specify whether to use Unlit, Lit, or custom shader.

Camera Bridge Pattern (MonoBehaviour → ECS Singleton)

Section titled “Camera Bridge Pattern (MonoBehaviour → ECS Singleton)”
// MonoBehaviour side — runs in managed world
public class CameraBridge : MonoBehaviour
{
void LateUpdate()
{
var world = World.DefaultGameObjectInjectionWorld;
if (world == null) return;
// Write camera data to singleton component
var em = world.EntityManager;
var query = em.CreateEntityQuery(typeof(CameraData));
if (query.TryGetSingleton<CameraData>(out _))
{
query.SetSingleton(new CameraData
{
Position = transform.position,
Forward = transform.forward,
});
}
}
}
// ECS side — IComponentData singleton
public struct CameraData : IComponentData
{
public float3 Position;
public float3 Forward;
}

Each perspective skill defines its own CameraData fields (e.g., orthoSize, isoAngle).

  1. SpriteAnimationAuthoring — exposes frame count, fps, atlas reference in Inspector
  2. Baker bakes to SpriteAnimationData component (frameCount, fps, currentFrame, timer)
  3. SpriteAnimationSystem (Burst) — increments timer, advances currentFrame, updates UV offset on MaterialMeshInfo

Per-perspective skills extend this with direction-based animation (8-dir top-down, 4-dir side-view).

Component: DeathFade : IComponentData { float Timer; float Duration; } System: increment Timer each frame, compute alpha = 1 - Timer/Duration, set material alpha via MaterialMeshInfo or property block, destroy entity when Timer >= Duration (via BeginSim ECB). Dissolve variant: drive _Dissolve shader property instead of alpha.

  • NavMeshSurface component: Agent Type = Humanoid, Collect Objects = Volume
  • Bake bounds: cover entire playable area + 5 unit margin
  • Use Geometry = Physics Colliders (not render mesh) for performance
  • Per-perspective skills specify bake plane (XZ for top-down/3D, XY for side-view).

Perspective affects perceived FOV — scale detection radius:

  • Top-down / Isometric: worldRadius = designRadius (1:1, orthographic)
  • Side-view: worldRadius = designRadius × 0.7 (Z-depth compressed)
  • 3D perspective: worldRadius = designRadius but apply FOV cone check
Cross-ReferenceContent
→ See dots-perspective-2d-topdownTop-down overrides
→ See dots-perspective-2d-sideviewSide-view overrides
→ See dots-perspective-isometricIsometric overrides
→ See dots-perspective-3d3D perspective overrides
→ See dots-graphicsRendering pipeline details
→ See unity-urpURP material/shader config
→ See agents-navigationNavMesh + DOTS agent patterns
  • Singleton CameraData lifecycle bound to active scene — replaying scene without resetting the singleton leaks last-scene’s camera transform into the next.
  • World.DefaultGameObjectInjectionWorld is null in editor before play-mode starts — guard with if (world == null) return in every system that reads it.
  • Multi-camera (split-screen) breaks the singleton model — the framework assumes one CameraData; split-screen requires per-camera entity refactor.
  • LateUpdate ordering across systems is not deterministic — if perspective writes after the renderer reads, frames render with last-frame data.