Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Tobias Johansson, posted on September 04, 2001

Image Description, by Tobias Johansson

Inspired by Jaap's GBA screenshots from his 3d engine, I thought I'd try some raytracing on the GBA. For anyone that grew up with dos mode13 graphics programming, programming the GBA is like taking a walk in the park, really nice.

I use the 15bit Mode3, rendering times are 2-3 mins for a simple picture, and 5 times slower with supersampling on.

  • Plane and Sphere primitives
  • Phong shading
  • Shadows
  • Reflections
  • Supersampling
  • As you can see I use iGBA for emulation and I use ARM Software Development Toolkit v2.50 for compilation. The source code the be found at my homepage I have no idea if it works on the actual hardware, but if someone tries please tell me what happened.

    /Tobias Johansson

    Image of the Day Gallery


    Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
    Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
    Jaap Suter

    September 04, 2001, 02:17 PM

    Dang, did you read my mind or something? I was thinking about raytracing on GBA just 5 minutes ago...

    Anyway, very very sweet IOTD! Compliments.

    About the 2-3 minutes for a picture. That doesn't really mean anything since you're running on an emulator. If you want accurate timing there is only one option; the real thing!

    I'm sure somebody is going to popup here and test it on the real thing for ya. Otherwise go ask in #GBADev on an Efnet server.

    This really looks sweet. However, one minor point...

    let's get back to 2D people :). Let's use the metal what it's made for. Besides that, compliments for making a raytracer!!!!!




    September 04, 2001, 02:22 PM

    very very cool - I was inspired to work on a GBA project too. Mine just consists of some sprites right now, looks nothing like this ;)


    September 04, 2001, 02:42 PM

    In fact, nothing serious happened, except "short sponsors message"


    September 04, 2001, 03:31 PM

    The idea behind this is perverse to say the least. Nevertheless, the results are awesome.


    September 04, 2001, 03:55 PM

    Those screenshots look really nice, but why is supersampling taking five times longer? I mean, when you sample at the corners of the pixels, you are only doing one extra row and one extra column. Blending the four values can't take that long on the GBA ... or can it? I don't know if memory constraints cause you to rerender samples. Hope this is not too stupid :)

    - Marco


    September 04, 2001, 04:06 PM

    95 fps!?!?!? Woah!

    Tobias Johansson

    September 04, 2001, 04:18 PM

    Thanks for the nice comments...and I totally agree that the idea is perverse. But it's a pretty good platform to make a simple raytracer, the code to set up graphics mode and plot some 15bit pixels isn't more than a few lines.

    And about the supersampling, I shoot one ray through the center of the pixel and four through the corners and each pixel, which means the exactly same ray is traced four times, pretty stupid but I'm much to lazy to do something about it.



    September 04, 2001, 04:23 PM

    It doesn't work on the real hardware unfortunately. More specifically, it doesn't get past the Nintendo boot sequence. The "Nintendo" word-logo is absent, pointing towards a size/checksum problem most likely?

    David Olsson

    September 04, 2001, 06:04 PM

    Super sampling means that you trace more rays than one for each pixel, not just blending adjacent pixels.


    September 04, 2001, 06:10 PM

    The 'supersampling' you described is just bilinear filtering...


    September 04, 2001, 07:27 PM

    Perverse... Does that mean you stared at it for a really long time, then got soapy with it with Mr. Rogers? :)

    Tis a pretty nice pic though for a gba, I must admit.


    September 04, 2001, 09:14 PM

    I really think that this is insultant. My poor on-working 486 is annoyed by knowing that an stupid hand entertainment system can do such as things even faster than him. I think he's getting old :)

    Really cool. GBA development will bring us too much surprises (good ones hope).



    September 04, 2001, 09:37 PM

    Gosh, it sure is dark....

    Just kidding, looks cool man. Always cool to see something new.

    -=[ Megahertz ]=-

    Matt D

    September 04, 2001, 10:00 PM

    dumb question time..

    what do you need to run your own code on the gba?

    a flash writer?
    a gbadev machine?
    some form of external link?

    just wondering.....



    September 04, 2001, 11:00 PM

    Mmmmmmmmm, I can't get enough of 3d on handhelds, its just to cooool!

    This got me thinking, would it be possible to do similar things with a sega gamegear. I guess it would be really sloooooooooow though.


    September 05, 2001, 03:05 AM

    No, it is not ... at least I don't think it is ... the supersampling pattern I described does four samples per pixel (There are many supersampling patterns out there, I assumed this one was used, because it is quite fast). You shoot rays through the four corners of each individual pixel. So, for the first pixel you shoot four rays. Now, when you move to the next pixel, you can reuse two rays from the previous pixel. The savings get even better in the next row.

    I mean, what is supersampling? Supersampling is doing more than one sample per pixel ... in this scheme you are doing four samples per pixel, but you can reuse (in most cases) three previously calculated values (I see that this part could reduce this to just plain bilinear filtering).

    Is this bilinear filtering? Maybe ... my CG instructor told us it was one way of doing supersampling ... oh well, wouldn't be the first time he was wrong. Still, this sampling technique (whatever you want to call it) does provide a cheap way of doing simple antialiasing ... might just be the right algorithm for the GBA, considering the speed of the machine.

    - Marco


    September 05, 2001, 03:21 AM

    Now that was hypocrite Jaap. :)


    September 05, 2001, 03:25 AM


    There are flash rom cartridges available, one is called Flash Advance, if I'm correct. You can simply download a ROM image to it, stick the thing in your GBA, and test it. It's not an official Nintendo pherephial (boy, that word gotta contain lots of typos), but who cares. :)
    O yeah, that flash thing also happens to run pirated games.

    - Phantom


    September 05, 2001, 04:04 AM

    Yay I have implemented all of those features myself allready for a change.
    Looks fairly good, but I suggest you use mip-mapping or such because the checkerboard looks awful in the distance.
    Well done!


    September 05, 2001, 04:31 AM

    Tobias, I got it to work on hardware.. I don't know what frankstank did but I'm getting a nice red ball on my GBA as we speak :) I'm too lazy to wait for it to finish, but it works.


    September 05, 2001, 04:33 AM

    Why it didn't work for franstank might be because your ROM don't have a correct header or file size, but my flash softawre fixes that before upload to the flash card..


    September 05, 2001, 04:37 AM

    oooooooooooooooooooooooh. nice

    Tobias Johansson

    September 05, 2001, 07:03 AM

    Cool, that's great. It tries to do bumpmapping, that's slows it down quite a bit. Try removing lines 517-523 and it should be somewhat faster.



    September 05, 2001, 09:21 AM

    Yeah. I want to know where that really high fps is coming from. Surely, that is good even for a modern computer.


    September 05, 2001, 10:14 AM

    I'm assuming that 95 fps is how fast it's displaying the FINAL IMAGE a second ;). Not how fast it's rendering the images.



    September 05, 2001, 10:42 AM

    yup, it would be pretty hard to get 85Fps when the tracing of the image takes 2-3 mins.


    September 05, 2001, 10:54 AM

    Ok people, lets go back to the kindergarden common sense class. If something takes 3 minutes to render, how many times can it render in one second? 90? Hm....NO! :)

    Zach Wendt

    September 05, 2001, 11:09 AM

    I think it's 2-3 min on gba, and 90fps on a pc like the picture of the emulator shows.


    September 05, 2001, 11:32 AM

    I think it's 2-3 min on gba, and 90fps on a pc like the picture of the emulator shows.

    When Tobias wrote the IOTD description he didn't even know whether or not the ray tracer would run on a real GBA. Hence your argument is flawed =)

    Alexander Blach

    September 05, 2001, 02:10 PM

    What about that idea:

    iGBA is an emulator. In the window caption it shows how often the screen is updated (~90 times a second). It has nothing to do with Tobias' code.

    That's my impression...

    Nice job btw!

    This thread contains 32 messages.
    First Previous ( To view more messages, select a page: 0 1 ... out of 1) Next Last
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.