We consider a family of d × d matrices W e indexed by e ∈ E where (E, μ) is a probability space and some natural conditions for the family (W e ) e ∈ E are satisfied. The aim of this paper is to develop a theory of continuous, compactly supported functions φ:Rd→C which satisfy a refinement equation of the form φ(x)=∫Eα∈Zd∑ae(α)φ(Wex−α)dμ(e) for a family of filters ae:Zd→C also indexed by e ∈ E. One of the main results is an explicit construction of such functions for any reasonable family (W e ) e ∈ E . We apply these facts to construct scaling functions for a number of affine systems with composite dilation, most notably for shearlet system