I was taking a look at my tile engine today and playing Super Mario Kart (SNES) so I got to thinking the maps in there are just tile maps that are rotated to look 3D and then have billboarded sprites. I think the Mode 7 effect is pretty cool.
Anyway, I did a floormapping function for my raycaster that casts rays against the floor's map array and then draws the floor from the center of the screen down. I imagine that's similar to how Ken's Lab renders them. Though I could be wrong.
Anyway, for a simple Mode 7 style game this seems like a bit much. Is there a more simple efficient way of rendering my tile maps in a rotated sense? I can't think of anything.
Thanks a ton guys,
Jinroh.
Awesoken at
I imagine that's similar to how Ken's Lab renders them. Though I could be wrong.
Have you looked at Ken's Labyrinth recently? The ceilings and floors are solid filled, which is obviously much simpler than your algorithm. Ken's Labyrinth fills using good old "rep stosw" in conjuction with a standard mode X trick for filling the 4 planes simultaneously. For an extra boost, I fill only to the top and bottom of the shortest wall raycasted in the scene.
I am not familiar with this "Mode 7". I'll assume it's some handheld console mode. No matter what hardware you use, it is almost certainly faster to render ceilings and floors in the horizontal direction. To do this, you will have to convert your list of vertical spans to a list of horizontal spans. This can be accomplished using a few 'while' loops as you go from left to right.
For tiling, you may want to use an algorithm similar to 2Draw. 2Draw draws the entire horizontal line in the same inner loop. It updates the base texture pointer only when necessary - when the U or V coordinates go out of bounds. Lines near the horizon will have nasty aliasing effects (and render slower). I would suggest implementing fog or something to hide this.
0xC0DE at
First of all (for Ken and other people who aren
Jinroh at
I see, I see.
Have you looked at Ken's Labyrinth recently?
Wow, sorry Ken. I forgot that Ken is a Wolf3D Clone. :oops: There must be something wrong with my brain lately. Between this and passing 12 values into my Vertex Structure instead of 11. *shakes head* I blame school.
No matter what hardware you use, it is almost certainly faster to render ceilings and floors in the horizontal direction. To do this, you will have to convert your list of vertical spans to a list of horizontal spans.
Hmm...all right. This sounds kind of like how you fill a poly by drawing horizontal lines. I think it's along the same idea anyway.
0xC0DE's Post
All right, so it's similar to a 3D World just with more restrictions. So I could use a 3D camera and render each tile as a separate texture mapped poly?
If I'm wrong let me know, but I think I'm forming an idea of how to attempt this.
Thanks a lot guys, you are the best.
Jinroh.
0xC0DE at
Re: I see, I see.
Jinroh said
Have you looked at Ken's Labyrinth recently?
Wow, sorry Ken. I forgot that Ken is a Wolf3D Clone. :oops: There must be something wrong with my brain lately. Between this and passing 12 values into my Vertex Structure instead of 11. *shakes head* I blame school.
No matter what hardware you use, it is almost certainly faster to render ceilings and floors in the horizontal direction. To do this, you will have to convert your list of vertical spans to a list of horizontal spans.
Hmm...all right. This sounds kind of like how you fill a poly by drawing horizontal lines. I think it's along the same idea anyway.
0xC0DE's Post
All right, so it's similar to a 3D World just with more restrictions. So I could use a 3D camera and render each tile as a separate texture mapped poly?
If I'm wrong let me know, but I think I'm forming an idea of how to attempt this.
Thanks a lot guys, you are the best.
Jinroh.
no. There are no polies involved at all. It isn't a 3D world either. :)
This is what I said :
you then scale
the map on every vblank and hblank to get a 3D perspective
That means it looks like 3D, but it really isn't. The tilemap, gameplay,etc
would be handled as normal for a 2D game. It only apprears 3D thanks
to the mode 7 effect.
As you can see, it's just a normal tilemap. But it doesn't appear that way because of the scaling and rotation. And that's the whole trick, making it
appear to be 3D when it's just a normal 2D game.
Jinroh at
Floormapping?
Not to sound rude or ungrateful or anything, but...
I was taking a look at my tile engine today and playing Super Mario Kart (SNES) so I got to thinking the maps in there are just tile maps that are rotated to look 3D and then have billboarded sprites. I think the Mode 7 effect is pretty cool.
I had a suspicion that it was a tilemap. :D
I just thought of an idea this evening on how I can make a Mode 7 style floor with my tile map. So I'll try it tomorrow and post if I had any luck or not.
Thanks again for the quick reply.
0xC0DE at
Jinroh said
Not to sound rude or ungrateful or anything, but...
I was taking a look at my tile engine today and playing Super Mario Kart (SNES) so I got to thinking the maps in there are just tile maps that are rotated to look 3D and then have billboarded sprites. I think the Mode 7 effect is pretty cool.
I had a suspicion that it was a tilemap. :D
I just thought of an idea this evening on how I can make a Mode 7 style floor with my tile map. So I'll try it tomorrow and post if I had any luck or not.
Thanks again for the quick reply.
I understand, but you scared me with the '3d camera' and 'polygon' thing.
because that's not the way it works at all :P
Jinroh at
Idea Maybe?
Yeah, sorry for the non-explanation in yesterdays less than tactful post. I had like 5 seconds to make the post. Sorry about that.
When I mentioned 3D Camera and texturemapping I was trying to think about it in terms I'm fairly familiar with. But all the Trig that's been running through my head from my below idea is really starting to give me a headache. lol.
I was thinking about it yesterday and today, but haven't gotten a chance to try this so I'll see what you, Ken and anyone else think about this possible solution. Though you probably know the correct way.
Anyway I was thinking. What if I cast a rays in say a 90 degree Field of View. Then had the ray hit every block to the edge of the map or up to a certain distance away from the camera, whatever.
Then once the ray was in the tile it would draw the tile in vertical strips from whatever the scaled top position on the screen of the tile was down to the scaled bottom position. And from the scaled right to the scaled left. Then it would pick up where it left off and keep going.
It's kind of a simplified version of my raycaster one. But it still seems more complex than it should be, making it seem inefficient. Now that I think about it, it seems like it was a good attempt but not a very good idea.
EDIT: LATER THAT SAME EVENING!
Okay, garbage the last idea. I got a new one that sounds better. I was thinking as I was just lazing around, I must be overthinking this. (as usual)
Ok so now what I thought of:
You have a camera, which is just how much of the map you can see at a time like in a plain old scrolling tilemap engine.
Okay, that's your camera. You mentioned earlier that there is no height values which I got but didn't really think about. So our Y = 0; and then Z is our Y Dimension on the Map Array and X is the X Dimension.
So, then we render our map staring from CamX to CamX + CamWidth and CamY to CamY + CamHeight so we draw all the tiles. BUT! We can for each pixel get their position in the world which would be something like (The Width of the Camera View * TileSize) * (The Height of the Camera View * TileSize) I think that's right.
Then we can draw each tile pixel by pixel and rotate the pixels using the X Axis Rotation Equation with Y = 0 and Z = Y Tile On the Map; Then we draw them.
Does that make sense? The details are sketchy as my brain is tired of thinking in terms of Trig all day trying to figure out a simpler raycaster method. But the "More Friendly To Me" 3D Style Math way certainly rubs me the right way. Though my details are a little sketchy as I was just jotting the idea down as I cooked it up in my brain. I'll have to sketch it out on a piece of paper. But if I can figure out Mode 7 style on my PC it'll be worth it :D
Thanks again for the quick reply 0xC0DE,
Jinroh.
0xC0DE at
Re: Idea Maybe?
Jinroh said
Yeah, sorry for the non-explanation in yesterdays less than tactful post. I had like 5 seconds to make the post. Sorry about that.
When I mentioned 3D Camera and texturemapping I was trying to think about it in terms I'm fairly familiar with. But all the Trig that's been running through my head from my below idea is really starting to give me a headache. lol.
I was thinking about it yesterday and today, but haven't gotten a chance to try this so I'll see what you, Ken and anyone else think about this possible solution. Though you probably know the correct way.
Anyway I was thinking. What if I cast a rays in say a 90 degree Field of View. Then had the ray hit every block to the edge of the map or up to a certain distance away from the camera, whatever.
Then once the ray was in the tile it would draw the tile in vertical strips from whatever the scaled top position on the screen of the tile was down to the scaled bottom position. And from the scaled right to the scaled left. Then it would pick up where it left off and keep going.
It's kind of a simplified version of my raycaster one. But it still seems more complex than it should be, making it seem inefficient. Now that I think about it, it seems like it was a good attempt but not a very good idea.
EDIT: LATER THAT SAME EVENING!
Okay, garbage the last idea. I got a new one that sounds better. I was thinking as I was just lazing around, I must be overthinking this. (as usual)
Ok so now what I thought of:
You have a camera, which is just how much of the map you can see at a time like in a plain old scrolling tilemap engine.
Okay, that's your camera. You mentioned earlier that there is no height values which I got but didn't really think about. So our Y = 0; and then Z is our Y Dimension on the Map Array and X is the X Dimension.
So, then we render our map staring from CamX to CamX + CamWidth and CamY to CamY + CamHeight so we draw all the tiles. BUT! We can for each pixel get their position in the world which would be something like (The Width of the Camera View * TileSize) * (The Height of the Camera View * TileSize) I think that's right.
Then we can draw each tile pixel by pixel and rotate the pixels using the X Axis Rotation Equation with Y = 0 and Z = Y Tile On the Map; Then we draw them.
Does that make sense? The details are sketchy as my brain is tired of thinking in terms of Trig all day trying to figure out a simpler raycaster method. But the "More Friendly To Me" 3D Style Math way certainly rubs me the right way. Though my details are a little sketchy as I was just jotting the idea down as I cooked it up in my brain. I'll have to sketch it out on a piece of paper. But if I can figure out Mode 7 style on my PC it'll be worth it :D
Thanks again for the quick reply 0xC0DE,
Jinroh.
first of all; don't worry so much. I really don't get offended by any of your posts :P
second :
well, all you have to do is figure out what line of the map belongs to a scanline. that's really all. So in fact were looking at a raytracer (a simple one though).
NOTE: this was NOT tested, I just wrote it down from the top of my head.
Can't remember were I learned it this way.. some tutorial I guess.
Jinroh at
Floormapping?
Hey, thanks for the clarification 0XC0DE I appreciate the psuedo code, I'll try and play around with the general idea.
BTW: What all consoles have you worked with out of curiosity? Either professionially or just in your free time?
0xC0DE at
GB - hobby
GBC - hobby
GBA - prof
NDS - prof
PSP - prof
NGAGE - prof
XBOX - prof
XBOX360 - prof
mobilephones - prof
I like the GBA the most. I still write/test new alogrithms first on the GBA.
Jinroh at
Whoa!
Wow, that's a pretty sweet record of consoles.
I still have a ways to go until I'm even passable at coding for the GBA. I can integrate with hardware and do stuff with registers on the PC with DOS and stuff, but the GBA overwhelms me if I do too much.
Oh well, I'll get it eventually. I just don't code enough for the GBA is what the problem probably is. :P
0xC0DE at
Re: Whoa!
Jinroh said
Wow, that's a pretty sweet record of consoles.
I still have a ways to go until I'm even passable at coding for the GBA. I can integrate with hardware and do stuff with registers on the PC with DOS and stuff, but the GBA overwhelms me if I do too much.
Oh well, I'll get it eventually. I just don't code enough for the GBA is what the problem probably is. :P
heh, I find it the otherway around. I like the GBA because it's a small clean machine. While with PC coding (or mobile, even worse) I need to focus on so many problems that may, or may not occure on a differtent pc/mobile.
But yeah, at first glance, the GBA might overwhelm you (happend to me too). But now, I know most registers by name/number out of my head and I don't even use gba.h :P
Jinroh at
Floormapping?
heh, I find it the otherway around. I like the GBA because it's a small clean machine. While with PC coding (or mobile, even worse) I need to focus on so many problems that may, or may not occure on a differtent pc/mobile.
Yeah, I imagine you are right, especially with larger projects. None of mine are especially large yet so I guess I've not experienced that, but I've had a lot of frustrating things go on as I advance so I'm getting there I suppose.
But yeah, at first glance, the GBA might overwhelm you (happend to me too). But now, I know most registers by name/number out of my head and I don't even use gba.h
Wow, that's awesome. I wish I coded the GBA enough to be that familiar with it. lol. It's nice to know I'm not the only one who got smacked by the GBA starting out though. ;)
I'm working on a PC Mode 7 application I tested it with my raycaster floormapping and it worked pretty good but I want to do a method similarly to how you would do it on the GBA. The code you posted there 100% accurate or not is a lot more straightforeward than a lot of the code I've seen. I appreciate it.
I'll probably try Mode 7 out on the GBA first and then port it to the PC, I need the practice. :lol:
Now I know it's just off the top of your head but I'm going to try and reason it out,
Screen_Width: is obviously the width of the screen.
Distance: Now is this the distance from the viewers face to the screen or the distance along the imaginary Z-Axis?
FIXED I'm assuming is a fixed point data type?
m is the current Tile Map Pixel that we're going to scale?
So this code fills the REG_BG2X with Pixels to Render the Scene? I think that's what I'm seeing.
How am I doing? Besides the Bit Shifting I think I'm getting it, what do you think?
Anyway, thanks again,
Jinroh.
0xC0DE at
Screen_Width: is obviously the width of the screen.
correct.
Distance: Now is this the distance from the viewers face to the screen or the distance along the imaginary Z-Axis?
Viewers face (sorry should have told that).
FIXED I'm assuming is a fixed point data type?
correct.
m is the current Tile Map Pixel that we're going to scale?
correct.
So this code fills the REG_BG2X with Pixels to Render the Scene? I think that's what I'm seeing.
correct.
How am I doing? Besides the Bit Shifting I think I'm getting it, what do you think?
I think you are correct :D
The bit shifting has a purpose though; it creates an offset ( .8 ) !
Looking back, I should have put in more comments and use better var
names (like map or tilemap rather then just 'm' ). But I didn't think about it
because it looked clear to me at the time :?
Jinroh at
Viewers face (sorry should have told that).
Hey, it's cool. I figured it must have been since we are dealing with projection but I wasn't 100% sure so I thought I'd check.
Anyway though, I've been doing some more research and writing down notes so I can attack this head on.
:EDIT ALL QUESTIONS HAVE BEEN ANSWERED THROUGH THINKING, WRITING NOTES, AND RESEARCH:
I think I'm getting a pretty good grasp on this Mode7 rendering for the PC. I had some suspicions that I coupled with the theory from you and TONC and my raycasting method. I'm mostly following the Mode7 function but I had to use my raycasting stuff for parts of the rendering. Everything's still on paper now, but I'm getting some progress. I'll post some screens as soon as I have something more concrete.
Thanks a ton for all of your quick responses too, they are much MUCH appreciated.
Jinroh.
0xC0DE at
Jinroh said
Viewers face (sorry should have told that).
Hey, it's cool. I figured it must have been since we are dealing with projection but I wasn't 100% sure so I thought I'd check.
Anyway though, I've been doing some more research and writing down notes so I can attack this head on.
:EDIT ALL QUESTIONS HAVE BEEN ANSWERED THROUGH THINKING, WRITING NOTES, AND RESEARCH:
I think I'm getting a pretty good grasp on this Mode7 rendering for the PC. I had some suspicions that I coupled with the theory from you and TONC and my raycasting method. I'm mostly following the Mode7 function but I had to use my raycasting stuff for parts of the rendering. Everything's still on paper now, but I'm getting some progress. I'll post some screens as soon as I have something more concrete.
Thanks a ton for all of your quick responses too, they are much MUCH appreciated.
Jinroh.
well, mode7 isn't possible on the PC (since it need a tilemap mode). You could fake it, but
that would take the complete point of mode7 out.
Just readed the TONC tutorial, it's very nice. His sample code looks alot like my way I
think I learned it from him (he seems to be coming from the same city I live in). But i'm
not really sure.
I just wrote a new gfx2gba tool after reading his stuff about bitpacking 8)
Jinroh at
Well...yeah.
well, mode7 isn't possible on the PC (since it need a tilemap mode). You could fake it, but
that would take the complete point of mode7 out.
Yes, I suppose that's true since it's a hardware mode. I wanted to "fake" it on the PC from the beginning. That was my original intent I guess. I'll do one on the GBA eventually but it's somewhat more simple (for me anyway) on the PC. It's actually turning out to be almost the inverse of my raycaster with more simplicity though.
Just readed the TONC tutorial, it's very nice. His sample code looks alot like my way I
think I learned it from him (he seems to be coming from the same city I live in). But i'm
not really sure.
Yes, TONC is pretty cool, that's how I learned the basics on the GBA. It's very well written.
(he seems to be coming from the same city I live in)
Really, that would be cool. When I lived near Philadelphia there were people around that coded but not many here :D Not many game coders (or would-be game coders like me) anyway.
I just wrote a new gfx2gba tool after reading his stuff about bitpacking
Man, you don't mess around :lol: I've been working on a graphical tile map editor the last couple days so I actually get something done while I'm writing out my Fake Mode7 code. It's coming along pretty well. The last time I did a tile engine was a year ago for my Kagegumi Badminton game. I was pretty pleased I remembered how to do everything from scratch. :lol:
Jinroh at
Screenshot
Yesterday Evening I finished up the Basic Mode7 Software Renderer! It took some tweaking well a lot of tweaking until it looked relatively like Super Mario Kart (Perspective-wise).