Don’t want to rain on your parade, but the cost isn’t in the amount of materials, but in the intricacy of the machining.
First, you would have to make a mold out of a material with a sufficiently high melting point. Then, you’d have to have some way of heating up the metal to that level.
Too much material poured would = waste,
filling a mold that is long and thin would be difficult.
There’s a reason nobody casts their own track. It’s expensive and difficult.
Fred is correct, they take solid metal wire rolls feed it thru the die machine where the dies, big wheels with half the rail profile cut into the face, press against the rod as its rolled thru, forming the classitc t -profile, then its sent on to where ever its going next, sometimes cut down, some times not.
I have delivered “Billets” or solid tubes of aluminum or steel. By flat bed truck. These customers will literally ram a tube into one end of a very hot machine (708 Degrees for Aluminum) and maybe use Nitrogen in a very cold form to prevent the set temperature of 708 degrees within 1 degree by computer every 3 seconds. The tube goes in one end with Fire and thru the middle coated in ice (-250 degrees) and then forced out a die into forms.
A form may be a step. Take a look at any Tractor trailer and look at the steps on the fuel tank. Those are one peice extrusions stamped out while it is hot like a wife cookie cutting dough before baking.
I hope this assist you in understanding. I just bought 4 3’ flex track code 83 today and it ran me about 1.10 a foot. Cork and ballast will be a little bit more. That is a very small price to pay to have trains running. If there was no track I will need to file the flanges off and tie a string to each end to push pull the trains.