Changing landscape material in realtime

Hey,

How can I change my landscape material function in realtime? I want players to be able to alter the landscape material; how can I access this by code? I guess I would trace to the ground and then detect what material is currently in place, and then replace that with another material in a 1x1 grid (preferably blend with the materials surrounding the grid).

Is this possible, if so how?