I've recently discovered the PocketFrog and PocketHal libraries for developing games and graphics on mobile devices. One thing that caught my eye was the ability to create per pixel shaders using C style structs. So I wrote an example application demonstrating a per pixel light shader with PocketFrog.
The shader uses a list of omni light structures to hold the light's properties: power (range), falloff, position, and RGB color. These structs can be accessed by the user. For every pixel the fragment program calculates the influence each light has on that pixel (0-1) according to the light's range, falloff, and position relative to the pixel's screen position. The influence value is used to calculate a color. The total color values for each light are then summed to get the final color of the pixel before it is returned and drawn by the rasterizer.
One problem with my implementation is that it will only work on rectangular sprites that have no masks. This is because PocketFrog does not send the 2D location of the pixel to the shader. I had to hack in a pixel cursor. This hack fails when masks are used, however, because not every pixel is sent to the shader. I just started using this library yesterday and will take a closer look at it to see if there is a way to have the rasterizer send the pixel location to the shader. It may take a rebuild of PocketFrog. [cool]
It's kind of fun programming my iPaq again. [smile]
You can find the PC binaries and VC6 source here.