We show that a large class of maximally degenerating families of
n
n
-dimensional polarized varieties comes with a canonical basis of sections of powers of the ample line bundle. The families considered are obtained by smoothing a reducible union of toric varieties governed by a wall structure on a real
n
n
-(pseudo-)manifold. Wall structures have previously been constructed inductively for cases with locally rigid singularities [Gross and Siebert, From real affine geometry to complex geometry (2011)] and by Gromov-Witten theory for mirrors of log Calabi-Yau surfaces and
K
3
K3
surfaces [Gross, Pandharipande and Siebert, The tropical vertex; Gross, Hacking and Keel, Mirror symmetry for log Calabi-Yau surfaces (2015); Gross, Hacking, Keel, and Siebert, Theta functions and
K
3
K3
surfaces (In preparation)]. For trivial wall structures on the
n
n
-torus we retrieve the classical theta functions.
We anticipate that wall structures can be constructed quite generally from maximal degenerations. The construction given here then provides the homogeneous coordinate ring of the mirror degeneration along with a canonical basis. The appearance of a canonical basis of sections for certain degenerations points towards a good compactification of moduli of certain polarized varieties via stable pairs, generalizing the picture for K3 surfaces [Gross, Hacking, Keel, and Siebert, Theta functions and
K
3
K3
surfaces (In preparation)]. Another possible application apart from mirror symmetry may be to geometric quantization of varieties with effective anti-canonical class.