---
id: "cga-shape-grammar"
title: "CGA Shape Grammar (Procedural Buildings)"
aliases: [CGA shape, shape grammar for buildings, CityEngine rules]
domain: "procgen"
stage: "procedural"
realtime: "interactive"
platforms: [cpu, houdini, blender]
year_introduced: 2006
inputs: [layout]
outputs: [mesh]
style: "both"
dynamic: "static"
cost: "medium"
authority: "Müller et al., 2006"
url: "https://texelatlas.vercel.app/t/cga-shape-grammar/"
sources_verified_at: "2026-11-29"
---
# CGA Shape Grammar (Procedural Buildings) (Müller et al., 2006)

> A grammar of 3D shapes with scope-aware operations (split, repeat, extrude, component split) that turns a building footprint and a few parameters into a detailed, textured facade and mass model.

## Reach for it when

- generate detailed building facades procedurally
- need to populate a city with many varied buildings
- model architecture from rules instead of by hand
- make variations of a building style from a few parameters

## How it works

A shape is a labelled 3D scope (position, orientation, size) plus geometry. Rules rewrite a shape symbol into others: split divides the scope along an axis into slices with relative or absolute sizes (floors, tiles), repeat tiles an element to fill a range, comp splits a volume into faces, extrude and taper make masses, and insert replaces a scope by an asset. Rules apply in sequence from a lot footprint through mass model, floors, facade tiles and windows, with stochastic selection among alternatives for variety and context queries (occlusion, snapping) to avoid collisions. The grammar's output is a hierarchy of terminal shapes meshed into the final model. It excels at structured, regular architecture and keeps all design logic as editable rules.

## When to use it

Choose it for city blocks and facades where rules (floors, bays, windows) express the style, and for large crowds of varied buildings from a handful of rules. Prefer [Model Synthesis](https://texelatlas.vercel.app/t/model-synthesis.md) or [Wave Function Collapse](https://texelatlas.vercel.app/t/wave-function-collapse.md) when you want to imitate an example rather than author rules, [L-Systems](https://texelatlas.vercel.app/t/l-systems.md) for organic growth, and [Procedural Kit Modeling with Verification (procgen-kit)](https://texelatlas.vercel.app/t/procedural-kit-modeling.md) when modules must be parametric, closed and collision-verified.

## Cost

medium — Rule derivation is fast per building (milliseconds to seconds) but generating a whole city is a batch job; resulting meshes need LOD.
Measured GPU Weight: 1.55× baseline (feather) — 0.0511 ms median / 0.053 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 1.33× baseline (feather) — 0.0212 ms median (2.41× faster on L4).
Ampere A100 scaling: 1.11× baseline (feather) — 0.0321 ms median (1.59× faster on A100).

## Failure modes

- Rules are brittle with irregular footprints: splits on odd lot shapes give slivers or overlapping scopes
- Grammar authoring is an expertise barrier; subtle rule errors yield mismatched facades
- Repeated rules make uniform, clone-like facades unless stochastic variation is added
- Output mesh topology is not guaranteed manifold or watertight
- Complex designs (organic, historical) are hard to express and require many custom operations

## Engine support

- unreal: official — `Enable the PCG plugin; PCG graph shape grammar nodes` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/using-shape-grammar-with-pcg-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: layout
- Outputs: mesh
- Platforms: cpu, houdini, blender

## Presets

### Facade produced by a CGA-style split/repeat rule chain (glsl-fragment; rendered 2026-11-29)

```json
{
  "FLOORS": 5,
  "TILE_W": 0.11,
  "GROUND_H": 0.17,
  "ROOF_H": 0.06
}
```

```glsl
// Facade from a CGA-style rule chain: split(y){ground | floor~ | roof}, repeat(x){wall | window | wall}, with a door on the ground floor.
const int FLOORS = 5;
const float TILE_W = 0.11;
const float GROUND_H = 0.17;
const float ROOF_H = 0.06;
float h(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float box(vec2 p, vec2 b) { vec2 q = abs(p) - b; return max(q.x, q.y); }
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = fragCoord / iResolution.xy;
    vec3 sky = mix(vec3(0.85, 0.65, 0.5), vec3(0.2, 0.3, 0.55), uv.y);
    vec3 col = sky;
    vec2 lo = vec2(0.12, 0.06), hi = vec2(0.88, 0.94);
    if (uv.x > lo.x && uv.x < hi.x && uv.y > lo.y && uv.y < hi.y) {
        float H = hi.y - lo.y, y = (uv.y - lo.y) / H * (1.0 - 0.0);
        float gh = GROUND_H, rh = ROOF_H, fh = (1.0 - gh / 1.0 * 0.0);
        float yy = uv.y - lo.y;
        float totalH = H, floorsH = totalH - GROUND_H - ROOF_H;
        float fl = floorsH / float(FLOORS);
        vec3 wall = vec3(0.72, 0.62, 0.52);
        float tx = (uv.x - lo.x) / TILE_W;
        float nTiles = floor((hi.x - lo.x) / TILE_W);
        float ti = floor(tx);
        vec2 tl = vec2(fract(tx) - 0.5, 0.0);
        col = wall * (0.9 + 0.1 * h(floor(uv * 90.0)));
        if (yy < GROUND_H) {
            // ground: shopfront band with a door in the middle tile
            col = wall * 0.75;
            vec2 q = vec2(fract(tx) - 0.5, yy / GROUND_H - 0.5);
            bool mid = abs(ti - floor(nTiles * 0.5)) < 0.5;
            float d = box(q, mid ? vec2(0.3, 0.42) : vec2(0.36, 0.28));
            vec3 gl = mid ? vec3(0.25, 0.15, 0.1) : vec3(0.3, 0.45, 0.55);
            col = mix(col, gl, smoothstep(0.03, -0.01, d));
        } else if (yy > totalH - ROOF_H) {
            col = vec3(0.35, 0.18, 0.15) * (0.8 + 0.2 * sin(uv.x * 220.0));
            col = mix(col, wall * 0.5, step(totalH - ROOF_H * 0.22, yy));
        } else {
            float fy = (yy - GROUND_H) / fl;
            float fi = floor(fy);
            vec2 q = vec2(fract(tx) - 0.5, fract(fy) - 0.5);
            float d = box(q, vec2(0.2, 0.28));
            float lit = step(0.5, h(vec2(ti, fi)));
            vec3 gl = mix(vec3(0.22, 0.32, 0.45), vec3(1.0, 0.8, 0.45), lit) * (0.7 + 0.5 * (0.5 - q.y));
            col = mix(col, gl, smoothstep(0.02, -0.01, d));
            col = mix(col, wall * 0.45, smoothstep(0.02, 0.0, abs(d - 0.04)) * step(0.0, d) * 0.5);
            col *= 1.0 - 0.25 * smoothstep(0.03, 0.0, abs(fract(fy) - 0.0));
        }
        col = mix(col, vec3(0.08), smoothstep(0.004, 0.0, min(uv.x - lo.x, hi.x - uv.x)) * 0.5);
    } else if (uv.y < lo.y) col = vec3(0.15, 0.15, 0.17);
    fragColor = vec4(pow(col, vec3(0.8)), 1.0);
}

```

Attribution: written for this index

## Lineage

- extends [L-Systems](https://texelatlas.vercel.app/t/l-systems.md)

## Combines with

- [Procedural City Generation (L-system Road Networks)](https://texelatlas.vercel.app/t/procedural-city-roads.md): Road networks produce the lots and footprints that the shape grammar extrudes into buildings.

## Combination ideas

- [Overgrown grammar cities](https://texelatlas.vercel.app/ideas/ivy-on-grammar-architecture/)
- [Cities wired by slime mould](https://texelatlas.vercel.app/ideas/slime-mould-road-networks/)

## Sources

1. [primary] Pascal Müller, Peter Wonka, Simon Haegler, Andreas Ulmer, Luc Van Gool (2006) Procedural modeling of buildings. ACM Transactions on Graphics. https://doi.org/10.1145/1141911.1141931 (verified via crossref on 2026-11-29)

## Cite this entry

Texel. "CGA Shape Grammar (Procedural Buildings)." https://texelatlas.vercel.app/t/cga-shape-grammar/ (accessed 2026-12-01).
