Neon GBA Lighting Engine

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Neon GBA Lighting Engine

Postby YourNerdyJoe on Sun Mar 30, 2014 3:01 pm


As of 3/26 I decided to do the One Game a Month challenge. March's theme is Neon hence the neon-ish colors.

How it works:
This uses 2 of the gba's bg layers. One is used for the lighting effects and the other contains the tiles in the background. The two are then merged with the gba's hardware color blending.

The lights cast rays over the tiles and sets the tile's brightness for that color light depending on how far away the tile is from the light source. So if a tile is close to a green light and far from a pink light, that tile's color brightness (as I'm dubbing it) for green might be 3 (max 4) and its color brightness for pink might be 1.

All of the different possible combinations of colors and brightness for the lights are calculated using a separate program I wrote. It spits out a total of 253 colors into a nice little c array which is compiled with the game. If you notice anything weird with the blending of the white light with the other lights, that is because I ran out colors as I thought I would (since the gba can only hold 256 colors in the bg palette). There was only enough space to mix one shade of white in with all of the other colors so I had to code in a little something extra so wouldn't be that noticeable.

In theory this could have been done with a light on each layer and then using the gba's color blending so I wouldn't use up palette space blending colors. However, in practice, this would severely limit the capabilities of the engine since there are only 4 bg layers. In addition, if only 2 layers are used like they are now, I could use video mode 2 which would allow me to do crazy rotation and shiz on those 2 layers.

Today I should be able to implement light mapping so I'm not casting 64-128 rays each frame for huge lights that aren't moving.

If anything is unclear, confusing, or you just want me to explain more about it please feel free ask

TLDR: THE COOOOLLLORS MAN.
User avatar
YourNerdyJoe
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
 
Posts: 83
Joined: Sun Oct 02, 2011 4:28 pm

Re: Neon GBA Lighting Engine

Postby Falco Girgis on Sun Mar 30, 2014 4:58 pm

That... is fucking awesome, dude. I am impressed, and I love the concept.
"So what happens if the Elysian Shadows Kickstarter fails?"
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
 
Posts: 10690
Joined: Thu May 20, 2004 3:04 pm
Location: Studio Vorbis, AL

Re: Neon GBA Lighting Engine

Postby ph0sph0ruz on Sun Mar 30, 2014 5:22 pm

That is pretty cool. Forgive my ignorance but how are you coding for the GBA? Is there an API or something and an emulator? Thanks!
User avatar
ph0sph0ruz
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 39
Joined: Sat Mar 22, 2014 4:52 am

Re: Neon GBA Lighting Engine

Postby YourNerdyJoe on Sun Mar 30, 2014 7:27 pm

Falco Girgis wrote:That... is fucking awesome, dude. I am impressed, and I love the concept.

Thanks man! Means a lot coming from you

ph0sph0ruz wrote:That is pretty cool. Forgive my ignorance but how are you coding for the GBA? Is there an API or something and an emulator? Thanks!

Didn't mean for this answer to get so long. It's simpler than it looks (I think/hope)
I'm using devkitpro which contains the compiler and libraries for devvin' on the gba. I started with devkitadv which is similar but it doesn't have the libraries and it's pretty outdated now. Since I started without libgba I got used to not using it. So I use a .h file with #defines for each register (REG_DISPCNT,REG_BLDMOD,etc). Anything else I need I normally create my own header file for based on info from tonc or gbatek.
As far as emulators go my personal favorite is VisualBoyAdvance. It includes some useful tools like a memory viewer, tile viewer, etc that come in handy when devin'.
I also have a usb flash cart for the gba but I haven't used it in a while b/c I can't get the software to work with windows 7 and up and I don't feel like busting out the old xp desktop after every build. Hope to build a uart cable before the summer so I can upload games from my pc directly to the gba. :)

The GBA is what got me into C back 3-4 years ago, glad I'm finally getting around to something worth releasing.
User avatar
YourNerdyJoe
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
 
Posts: 83
Joined: Sun Oct 02, 2011 4:28 pm

Re: Neon GBA Lighting Engine

Postby ph0sph0ruz on Sun Mar 30, 2014 7:41 pm

Thanks Dude! I didn't even know all this stuff was out there until recently. I'll have to check some of these kits out.
User avatar
ph0sph0ruz
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 39
Joined: Sat Mar 22, 2014 4:52 am

Re: Neon GBA Lighting Engine

Postby YourNerdyJoe on Sun Mar 30, 2014 7:55 pm

ph0sph0ruz wrote:Thanks Dude! I didn't even know all this stuff was out there until recently. I'll have to check some of these kits out.

No problem man.

Just finished light mapping and static lights earlier today.
The only difference between the 2 is that the light map is an array of pre-computed values and the static lights are computed when the game loads. Both run just as fast.
I probably won't make another video until at least next weekend when I have a few more things to show off.
User avatar
YourNerdyJoe
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
 
Posts: 83
Joined: Sun Oct 02, 2011 4:28 pm

Re: Neon GBA Lighting Engine

Postby dandymcgee on Mon Mar 31, 2014 9:23 am

This is really cool! Neat idea, thanks for the video / explanation.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

Re: Neon GBA Lighting Engine

Postby eatcomics on Mon Apr 14, 2014 3:47 pm

ph0sph0ruz wrote:Thanks Dude! I didn't even know all this stuff was out there until recently. I'll have to check some of these kits out.

It's pretty cool, a year or two ago I bought a flashcart and played around with the API, I got backgrounds loading and some sprites, but after that I got busy. It's a ton of fun and a good way to get a feel for some lower level stuff :)

On the topic of your demo, that is fucking cool. How hard is it on the poor little machine? Looks pretty involved processing wise.
Image
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
 
Posts: 2664
Joined: Sat Mar 08, 2008 9:52 pm
Location: Illinois

Re: Neon GBA Lighting Engine

Postby YourNerdyJoe on Tue Apr 15, 2014 8:43 pm

eatcomics wrote:How hard is it on the poor little machine? Looks pretty involved processing wise.

After about 4 lights it does begin to lag a little but there is still room for more optimization. The static lights, however, are hella fast since they only need to be computed once.

I should have another video up tomorrow which will show off some new features and something that actually resembles a game.
Don't get too excited because the video will be short for reasons that will be explained after I upload.
It comes down to stupidity
User avatar
YourNerdyJoe
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
 
Posts: 83
Joined: Sun Oct 02, 2011 4:28 pm

Re: Neon GBA Lighting Engine

Postby YourNerdyJoe on Wed Apr 16, 2014 9:55 pm

New video up now!

Added support for lights to fade over time which is used to create samus' beam.
This is done by giving each tile a "fade" brightness value (for lack of a better name) which decreases each frame. It's then added to the initial brightness that is set by the static lights (like the 2 white ones) and light maps.

The reason the video is so short is beacuse I used an entity system I wrote about half a year ago just to see if I could implement it in C. Spent little more than a week end one it and did very little testing. Being the genius that I am I thought "well I wrote this in c so I'll use that old engine I wrote in c that has very poor memory management." The only smart thing I did was keep the code separate.
If enough people want to see the epic fail I'll post the full video. Random memory addresses are being writen to so some freaky TMTRAINER level things start popping up all over.

In the (maybe near) future I plan redoing this with lua wrapper and release it for people to play around with.
The bugging entity system WILL be removed by then. (Just to clarify, I have made a much better entity system than this in c++ and this one was made as a quick challenge to see if I could get it to run in c)
User avatar
YourNerdyJoe
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
 
Posts: 83
Joined: Sun Oct 02, 2011 4:28 pm

Re: Neon GBA Lighting Engine

Postby dandymcgee on Thu Apr 17, 2014 4:00 pm

Holy crap, that is freaking awesome! Really cool effects.

YourNerdyJoe wrote:If enough people want to see the epic fail I'll post the full video.

You know we do.. :twisted:
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

Re: Neon GBA Lighting Engine

Postby YourNerdyJoe on Thu Apr 17, 2014 10:57 pm

dandymcgee wrote:Holy crap, that is freaking awesome! Really cool effects.

YourNerdyJoe wrote:If enough people want to see the epic fail I'll post the full video.

You know we do.. :twisted:

WEEEELLLLLLLLL, it looks you guys are in for a treat :lol:
User avatar
YourNerdyJoe
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
 
Posts: 83
Joined: Sun Oct 02, 2011 4:28 pm

Re: Neon GBA Lighting Engine

Postby YourNerdyJoe on Fri Apr 18, 2014 8:14 pm

Here it is you sadistic bastards!

I understand how the graphical glitches occur but I am very surprised that the friction flag is set in the beam's PhysicsComponent.

I have started working on the lua wrappers for this. Plan on releasing the rom when I'm done (which won't be for a while) so you guys will be able to write your own scripts for it.
User avatar
YourNerdyJoe
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
 
Posts: 83
Joined: Sun Oct 02, 2011 4:28 pm

Re: Neon GBA Lighting Engine

Postby dandymcgee on Fri Apr 18, 2014 11:17 pm

Lol, it's always funny when you mess up something minor and everything goes to hell. I remember blowing on NES carts trying to get the palette to stop looking like the color test channel.

Who remembers this?

Image
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

Re: Neon GBA Lighting Engine

Postby bbguimaraes on Sat Apr 19, 2014 9:36 am

Surely that's not a bug. It's hardcore mode, where monsters have powerful illusions that make them invisible, twist your beams and displace the background. It also happens to be the only mode ;)
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
 
Posts: 324
Joined: Wed Apr 11, 2012 5:34 pm
Location: Brazil

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron