Set a float's value from a texture's color under the player


I’m trying to use an image file that I place in my level. Basically, this image file is to be used as a map to control some data in my game.

I want a float to react to the player’s position on this texture. So if you’re standing on green, it sets the float to 1. If your character is standing on red, it sets the float to 2, etc.

This way, I can easily control my environment by loading an image file that will control some parameters in the world as you move.

Any ideas how I can achieve this?

Note: I eventually want this texture to be invisible, just for controlling environment elements.