Jump to content
  • Advertisement
Sign in to follow this  
Nacho

Designing a 3D engine for GBA

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello there! I´ve just finished reading Tricks of the 3D Game Programming Gurus by Lamothe and I´d like to apply the material I´ve learned from it by designing and coding a 3D engine for the Game Boy Advance platform. The problem is that I´m not quite sure about how should I structure it. That is, the author exposes several methods to achieve the same results (eg. tranforming objects individually vs inserting them into a renderlist and then transforming the entire list). Since the GBA has limited capabilities, I think the best approach would be to set the pipeline in a fixed way. For example, perform local to world transformation, backface removal and clipping in the object level, then insert the objects into the renderlist and perform the rest of the pipeline, such as the perspective transformation, at the renderlist level. Is it okay to take that approach or should I code it in more flexible manner (ie. write code to be able to also perform the perspective transformation at the object level)? Thanks in advance for your help! --Ignacio

Share this post


Link to post
Share on other sites
Advertisement
I wouldn't worry too much about proper structure, to get any performance out of the GBA you'll have to cheat and hack on most levels anyway. Most of the CPU time will have to be spent in the polygon fillers. So try to optimize that part, you'll probably be changing the rest around a few times a week anyway.

Try studying some of the methods utilized in the C64 scene for inspiration. You'd be surprised at the amount of cheating you can get away with in a 3d engine..

Share this post


Link to post
Share on other sites
Yeah, on GBA, you have approximately 7.3 CPU cycles to spend on each pixel of the screen if you want to run at full speed (i.e. pretty much impossible), so you're pretty much hacking your way through just to get a playable framerate.

I made a simple 3D engine for GBA a couple years ago, and got it running decently at half resolution. My pipeline was basically like this:


Sort meshes by distance from eye
For each mesh,
Transform all vertices in mesh (including projection)
Cull backfacing
Sort remaining faces by distance from eye
Inverse-transform the light direction vector by the model rotation (didn't work with scale or shear)
For each face, light vertices, and render


The lighting step wasn't necessary for textured models, since I couldn't do both at once.

Clipping was actually done per scanline during the tri drawing. Probably slower than sutherland-hodgeman, but my tri filler was super optimized and I was too lazy to write an N-gon filler just for the clipped tris.

GBA's ARM7 has lots of registers, so there are lots of optimizations to be had, and lots of fun finding them. Memory bandwidth is the real killer, so try to avoid doing multiple passes over all your vertices and such.


EDIT: If you want to see the demo I used this in, grab it at http://deku.gbadev.org/program/eternity.zip, and source at http://deku.gbadev.org/program/eternity-source.zip if you're feeling daring :) Important stuff is in Render.c

Share this post


Link to post
Share on other sites
Thank you all for your input! I´m rating you all up.

@ DekuTree64: Your demo is very impressive! Once I have a simple renderer working I´m going to analyze your source code in detail. Thanks for releasing it.

@ jsgcdude: I´ve skimmed through the document you suggested. Again, once I have a simple renderer working I´m going to analyze it in detail before moving on.

@ doynax: I´ll look into the C64 scene. Thanks for your suggestion!


--Nacho

Share this post


Link to post
Share on other sites
I don´t know if I´m doing the right thing or not by asking this but I´d like to know why did my rating lowered after opening this thread. As you can see from my profile, I haven´t been using the forums for quite some time so I´m still not completely used to the rating system.

Nonetheless, and correct me if I´m wrong, I think I´ve used a friendly tone in my previous posts so please, if I have said something that bothered you, let me know via a PM.

Thanks!
--Ignacio

Share this post


Link to post
Share on other sites
Quote:
Original post by Ignacio Liverotti
I don´t know if I´m doing the right thing or not by asking this but I´d like to know why did my rating lowered after opening this thread. As you can see from my profile, I haven´t been using the forums for quite some time so I´m still not completely used to the rating system.

Nonetheless, and correct me if I´m wrong, I think I´ve used a friendly tone in my previous posts so please, if I have said something that bothered you, let me know via a PM.

Thanks!
--Ignacio


I just wouldn't worry about it. There are alot of poeple that may misread one post and rate down. Also, I have noticed that if you rerate someone (intentianally or on accident) it may actually lower their rating... I have done this a couple times on accident.

Basically, ratings are nice to a degree, but don't keep up with every single rating. Watch the general trend if you even care at all...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!