For anyone unfamiliar with the concept, here's a little background info:
So basically, you have an object the same size as your frame (I really ought to add scrolling support, so it only needs to be the size of the window), with two textures:
* a map image representing your game level, with 1 pixel per tile.
* a tileset image with the individual tiles, in a 16x16 tile grid.
The color of each pixel in the map image determines which tile from the tileset to draw at that position.
Anyway, here's my version: http://sdrv.ms/13aDqGN
The tileset image must be 16x16 tiles in size. Tiles are indexed from 0-255 (ordered left-to-right and top-to-bottom), using the red component from the map image only (unlike the example above which uses red and green).
btw: I realize there are many other ways to do the same thing, besides a pixel shader, but it just seemed like an interesting experiment.
EDIT: Ooops - it's still broken (thought I'd fixed it). If anyone can figure out how to fix it, it would be much appreciated...