• Advertisement
Sign in to follow this  
  • entries
    149
  • comments
    510
  • views
    94824

There's a pocket in my frog

Sign in to follow this  

261 views

2D light shader...

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.

Hmmm...

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.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement