Files
Claude-Code-Game-Studios/.claude/rules/shader-code.md
T
DonchitosandClaude Opus 5.5 b21fa0f7f2 Release 1.1.2 — the default path works end to end
Fix release for 1.1.1: the minimal path end to end, engine commands that
run on Godot, Unity and Unreal, hook warnings you can see, and verdicts
that say when they could not check. Details in CHANGELOG.md; upgrade
steps in UPGRADING.md (v1.1.1 → v1.1.2).

Fixes #67
Fixes #131

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WuJn2FdynEybfL5KC697nJ
2026-09-29 21:32:19 +10:00

2.1 KiB

paths
paths
assets/shaders/**
**/*.gdshader
Assets/**/*.{shader,hlsl,cginc,compute,shadergraph}
Shaders/**
**/*.{usf,ush}

Shader Code Standards

All shader files, in every engine, must follow these standards to maintain visual quality, performance, and cross-platform compatibility.

Naming Conventions

  • File naming: [type]_[category]_[name].[ext]
    • spatial_env_water.gdshader (Godot)
    • SG_Env_Water (Unity Shader Graph)
    • M_Env_Water (Unreal Material)
  • Use descriptive names that indicate the material purpose
  • Prefix with the engine's shader type — Godot spatial_, canvas_, particles_, post_; Unity SG_ (Shader Graph); Unreal M_, MI_ (instance), MF_ (function)

Code Quality

  • All uniforms/parameters must have descriptive names and appropriate hints
  • Group related parameters (Godot: group_uniforms, Unity: [Header], Unreal: Category)
  • Comment non-obvious calculations (especially math-heavy sections)
  • No magic numbers — use named constants or documented uniform values
  • Include authorship and purpose comment at the top of each shader file

Performance Requirements

  • Document the target platform and complexity budget for each shader
  • Use appropriate precision: half/mediump on mobile where full precision isn't needed
  • Minimize texture samples in fragment shaders
  • Avoid dynamic branching in fragment shaders — use step(), smoothstep() and mix() (Godot, GLSL) or lerp() (HLSL: Unity, Unreal)
  • No texture reads inside loops
  • Two-pass approach for blur effects (horizontal then vertical)

Cross-Platform

  • Test shaders on minimum spec target hardware
  • Provide fallback/simplified versions for lower quality tiers
  • Document which render pipeline the shader targets (Forward/Deferred, URP/HDRP, Forward+/Mobile/Compatibility)
  • Do not mix shaders from different render pipelines in the same directory

Variant Management

  • Minimize shader variants — each variant is a separate compiled shader
  • Document all keywords/variants and their purpose
  • Use feature stripping where possible to reduce build size
  • Log and monitor total variant count per shader