Complete first pass CTM funcion, including cache for texture mappings