Manny Naveed and Alan Fraser rented a building on Birkenbush Farm, near Forfar in Angus after spotting an advert for a shed to rent in the Scottish Farmer.
Christopher Paul helped source a generator to power the "industrial and commercial" cultivation. Paul, Fraser and Naveed went there on hundreds of occasions to tend the crops in the 1800 sq ft factory.
The trio were warned they face years in jail after a sheriff decided his maximum five-year sentence wouldn't be enough and sent the case to the High Court.
Dundee Sheriff Court heard that the cultivation could have yielded cannabis worth over £145,000 when it was harvested, which was due to happen within weeks of a police raid in January last year.
The court heard that farmers Derek Greenhill Sr and Derek Greenhill Jr had advertised the shed for rent at their farm in July 2012.
Naveed and Fraser then signed £600 per month lease.
A video was played in court showing the vast scale of the sophisticated cannabis factory they constructed - with a generator powering row upon row of reflective lights, industrial sized extractors, fans, and an irrigation system.
A trial heard that some time around Christmas 2012 Naveed went to Derek Greenhill Jr's office on the farm and accused him of breaking into their shed, which was padlocked shut.
Days later three unknown men turned up and threatened Mr Greenhill Jr.
They told him "better not be going to the police" and said "it will all be gone by mid January".
One of the men then pulled out a sawn-off double barrelled shotgun and pushed it into Mr Greenhill Jr's neck as he issued the threats.
Fiscal depute Nicola Gillespie said the farm operated 24 hours a day and was weeks away from being harvested when police raided on January 19 last year.
She said: "There were 304 plants in the main growing area.
"There were junction boxes on 24 hour timer switches which fed reflective lights.
"The illicit value of the plants is conservatively estimated as between £48,640 and £145,920."
Naveed, 32, Fraser, 42, both of Motherwell, and Paul, 31, of Monikie, Angus, pleaded guilty on indictment to charges of producing cannabis and being concerned in the supply of cannabis between June 1 2012 and January 19 2013.
Sheriff Alistair Brown remanded all three in custody and remitted the case to the High Court for sentence.