• entries
298
1135
• views
231309

# Let there be light!

165 views

The Weekend

I spent this weekend at home with the family for my birthday, so I didn't really get any work done. Feeling guilty about this, I sat down for 2 hours and wrote two little fun lighting-related 2D demos. Amusing!

My first demo was to write a program that let the user move the mouse around as a light source around a bitmap-based scene. The goal was to have the scene project 2D shadows wherever a line-of-sight check failed. It mostly works, is very fast, and only occassionally misses a spot. Change the BMP scene around to see what does and doesn't work. ;)

Bump-Fun

Bump mapping (of the 3D variety) is always something that has looked VERY cool, but I still haven't gone over the math of how it's done. So in an attempt to satiate that curiousity I wrote a go at 2D bump mapping. It doesn't look as nice as I would have preferred, but it's still neat to look at. Took a while to get the equation for the shadows nice and smooth.

(The prebuilt 'bump map' is of repeating capped-cones)

Hopefully I didn't forget any DLLs! ;)

EDIT: Ah, and I did. Reuploaded. :P

I had an error requiring msvcr71.dll and msvcp71d.dll but fortunatly I had them in my Blocky Man folder. The bumpmapping one ran horrably slow and didnt do anything but follow the mouse. The shadow one followed my mouse and performed SMOOTHLY. It was really neat, good job!

##### Link to comment
Shadow Fun is pretty clever. Colour me impressed. Are you doing the math for that manually?

Just wondering why the close button was disabled? I had to Ctrl-Alt-Delete to get rid of it.

##### Link to comment
Quote:
 Original post by ShoeStringGames I had an error requiring msvcr71.dll and msvcp71d.dll but fortunatly I had them in my Blocky Man folder.

Fixed; thanks.

Quote:
 The bumpmapping one ran horrably slow and didnt do anything but follow the mouse.

It's supposed to cast small shadows on the bumps as you move your mouse. You likely won't notice the effect if you move your mouse really fast. (Or if it's just really choppy)

Quote:
 The shadow one followed my mouse and performed SMOOTHLY. It was really neat, good job!

Thanks!

Quote:
 Original post by EasilyConfused Shadow Fun is pretty clever. Colour me impressed. Are you doing the math for that manually?

Thanks, and yes.

Quote:
 Just wondering why the close button was disabled? I had to Ctrl-Alt-Delete to get rid of it.

Allegro disables it. But hitting Escape also works. ;)

##### Link to comment
by default allegro apps do this. you can enable the close button with a special function and a tiny bit of effort, but if you just wanna throw together a quickie demo you don't generally care about stuff like this.

hopedagger, pander to the masses dammit!

bool closeButtonPressed = false;
void CloseButtonHandler ()
{
closeButtonPressed = true;
}

// in your main(), before main loop
set_close_button_callback (CloseButtonHandler);

// main loop!
while (!key[KEY_ESC] && !closeButtonPressed)
{
// ... stuff...
}



copy/paste, beeyatch! [rolleyes]

## 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