Elysian Shadows Off-screen Tiles
Moderator: PC Supremacists
- tinni5
- Chaos Rift Newbie
- Posts: 8
- Joined: Sat Aug 22, 2009 4:11 pm
- Current Project: shader supporting game engine
- Favorite Gaming Platforms: PC, Dreamcast, PSP, PS3
- Programming Language of Choice: C++
- Location: United Kingdom
Elysian Shadows Off-screen Tiles
Hi guys! This is more a question for the developers but if anyone knows, how do you guys go about handling off-screen rendering? I was skimming over the photos on the site when I came across the Mario World 1-1 recreation and noticed the polygon count was 3000+. Not that it would be a problem for todays hardware or more specifically, the hardware you're developing for but i think it would make a nice feature if some kind of culling method was used for the tiles off-screen. Considering that you are planning to release libGyro to the public you can't really predict the projects that will be developed with it. I could be wrong and you have already implemented something like this but i thought i would ask as i've not seen it mentioned before.
Also, i remember Falco commenting on developing for the iPhone/iPod Touch/iPad saying he was against it? Why are you so against it? You could make some serious cash that way. I know objective-C isn't the most desirable language to use but from my experience you can use C/++ and leave objective-C for the specific hardware "communication". I think it wouldnt take long to add an objective-C rendering system specific for the Apple products. Although, i think i would stick to the iPad as the screen size for the other two devices seem too small for a game like ES. Anyway, thats my two-cents
Also, i remember Falco commenting on developing for the iPhone/iPod Touch/iPad saying he was against it? Why are you so against it? You could make some serious cash that way. I know objective-C isn't the most desirable language to use but from my experience you can use C/++ and leave objective-C for the specific hardware "communication". I think it wouldnt take long to add an objective-C rendering system specific for the Apple products. Although, i think i would stick to the iPad as the screen size for the other two devices seem too small for a game like ES. Anyway, thats my two-cents
- RyanPridgeon
- Chaos Rift Maniac
- Posts: 447
- Joined: Sun Sep 21, 2008 1:34 pm
- Current Project: "Triangle"
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/C++
- Location: UK
- Contact:
Re: Elysian Shadows Off-screen Tiles
If you do not have camera rotation, and you're rendering tiles from an array, then you can simply loop through the array for the tiles that WILL be on screen and ignore all the others, like
for (column = camera.x / tileWidth; column <= (camera.x + camera.width) / tileWidth; column++){
for (row = camera.y / tileHeight; row <= (camera.y + camera.height) / tileHeight; row++){
renderTile(tiles[column][row] );
}
}
If this doesn't suit the job, you could always look into something more advanced such as quad-trees. But for a simple 2d game, you really shouldn't have to worry that much
for (column = camera.x / tileWidth; column <= (camera.x + camera.width) / tileWidth; column++){
for (row = camera.y / tileHeight; row <= (camera.y + camera.height) / tileHeight; row++){
renderTile(tiles[column][row] );
}
}
If this doesn't suit the job, you could always look into something more advanced such as quad-trees. But for a simple 2d game, you really shouldn't have to worry that much
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Elysian Shadows Off-screen Tiles
Well for a rotated/zoomed camera, you can do something like this.
- calculate coords of rot/zoomed camera rect
create an AABB around it (so you don't have to deal with all the crazy collision stuff)
use RyanPridgeon's method, treating the AABB as the camera
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- tinni5
- Chaos Rift Newbie
- Posts: 8
- Joined: Sat Aug 22, 2009 4:11 pm
- Current Project: shader supporting game engine
- Favorite Gaming Platforms: PC, Dreamcast, PSP, PS3
- Programming Language of Choice: C++
- Location: United Kingdom
Re: Elysian Shadows Off-screen Tiles
i wasnt actually asking for tips on how to actually perform tile culling but thankyou anyway lol i was just wondering how the ES dev team do it if at all. Doesn't look like they do.
Re: Elysian Shadows Off-screen Tiles
If that is the case, it would definitely make my day According to some forum posts they consider even ASM optimization. I don't think they've missed the easy way.tinni5 wrote:Doesn't look like they do.
- tinni5
- Chaos Rift Newbie
- Posts: 8
- Joined: Sat Aug 22, 2009 4:11 pm
- Current Project: shader supporting game engine
- Favorite Gaming Platforms: PC, Dreamcast, PSP, PS3
- Programming Language of Choice: C++
- Location: United Kingdom
Re: Elysian Shadows Off-screen Tiles
According to the Mario World 1-1 images they are rendering 3500+ polygons which seems excessive in my opinion. There seems to be IMHO < 600 triangles which amounts to about a 2400 polygon overdraw per frame. Im just trying to find out if they are using a method which im overlooking. I think the Mario remake was before the engine was rewritten so they might have made some changes but it was just something i noticed.K-Bal wrote:If that is the case, it would definitely make my day According to some forum posts they consider even ASM optimization. I don't think they've missed the easy way.tinni5 wrote:Doesn't look like they do.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Elysian Shadows Off-screen Tiles
Oh, right. I remember that.
It had nothing to do with offscreen tiles. If you have a look at the minimap, you'll notice that every "solid" is represented as 2x2 quad. A great way to assfuck any hardware.
That minimap was more of a "conceptual" thing at that point in time. We weren't sure how we wanted to handle it, so I just kind of threw it together. As you said, it ran fine on a PC, but I had literally put the thing in #ifdef #ifndef blocks to make sure the thing wasn't running on Dreamcast... that wouldn't have been pretty.
In the past, we had simply made sure 1) to only iterate through onscreen tiles to render and 2) to check if an entity is onscreen before rendering. Once we introduced uniform zoom/scale, it got QUITE a goddamn bit more messy to determine what was and was not onscreen. We haven't really decided on any one algorithm.
It had nothing to do with offscreen tiles. If you have a look at the minimap, you'll notice that every "solid" is represented as 2x2 quad. A great way to assfuck any hardware.
That minimap was more of a "conceptual" thing at that point in time. We weren't sure how we wanted to handle it, so I just kind of threw it together. As you said, it ran fine on a PC, but I had literally put the thing in #ifdef #ifndef blocks to make sure the thing wasn't running on Dreamcast... that wouldn't have been pretty.
There are plenty of areas for improvement with assembly once I get around to it. Not even "optimization" necessarily either. The PSP's vector unit is only accessible via straight assembly. The Dreamcast also has 4x4 Matrix and 4x1 Vector registers that allow for ultra-fast calculations. Both of these really SHOULD be happening in assembly to take a load off of the CPUs.K-Bal wrote:According to some forum posts they consider even ASM optimization. I don't think they've missed the easy way.
In the past, we had simply made sure 1) to only iterate through onscreen tiles to render and 2) to check if an entity is onscreen before rendering. Once we introduced uniform zoom/scale, it got QUITE a goddamn bit more messy to determine what was and was not onscreen. We haven't really decided on any one algorithm.
That's a great temporary fix, but as the camera zooms farther and farther out, and you look at rotating your viewport something like 45 degrees, you're still going to be potentially overdrawing a FUCKLOAD.Ginto wrote:Well for a rotated/zoomed camera, you can do something like this.
calculate coords of rot/zoomed camera rect
create an AABB around it (so you don't have to deal with all the crazy collision stuff)
use RyanPridgeon's method, treating the AABB as the camera
- Lord Pingas
- Chaos Rift Regular
- Posts: 178
- Joined: Thu Dec 31, 2009 9:33 am
- Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
- Programming Language of Choice: C++
- Location: Hiding In My Mum's Basement With My Pokemon Cards
Re: Elysian Shadows Off-screen Tiles
They are using off screen tile culling in there engine.
When I asked Falco how he implemented it, he said something like this:
When I asked Falco how he implemented it, he said something like this:
Take the top left of your screen and divide it by your sprite size.
Then write a for loop within a for loop that iterates from the top left to the bottom right.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Elysian Shadows Off-screen Tiles
looks like bresenham's line algorithm is gonna be use for more than just sprites, eh? I still haven't really been able to figure that thing out SAT collision would just be a clusterfuck, and even circular collision would probably be overkill, and overdraw too much.GyroVorbis wrote:That's a great temporary fix, but as the camera zooms farther and farther out, and you look at rotating your viewport something like 45 degrees, you're still going to be potentially overdrawing a FUCKLOAD.Ginto wrote:Well for a rotated/zoomed camera, you can do something like this.
calculate coords of rot/zoomed camera rect
create an AABB around it (so you don't have to deal with all the crazy collision stuff)
use RyanPridgeon's method, treating the AABB as the camera
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- RyanPridgeon
- Chaos Rift Maniac
- Posts: 447
- Joined: Sun Sep 21, 2008 1:34 pm
- Current Project: "Triangle"
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/C++
- Location: UK
- Contact:
Re: Elysian Shadows Off-screen Tiles
Oh god no, you'll wanna be looking into a tree structure for this. Like mentioned before, the quad tree is a good way to tackle it. Checking collision for all the tiles is definitely not a way you're going to want to tackle performance.Ginto8 wrote:looks like bresenham's line algorithm is gonna be use for more than just sprites, eh? I still haven't really been able to figure that thing out SAT collision would just be a clusterfuck, and even circular collision would probably be overkill, and overdraw too much.GyroVorbis wrote:That's a great temporary fix, but as the camera zooms farther and farther out, and you look at rotating your viewport something like 45 degrees, you're still going to be potentially overdrawing a FUCKLOAD.Ginto wrote:Well for a rotated/zoomed camera, you can do something like this.
calculate coords of rot/zoomed camera rect
create an AABB around it (so you don't have to deal with all the crazy collision stuff)
use RyanPridgeon's method, treating the AABB as the camera
I imagine when GyroVorbis said he was checking if a tile was on screen before rendering, he meant checking using the final transformed vectors, as I recall something about Elysian Shadows or LibGyro using its own transform system.
Anyway, @OP: you just use the for loop, these methods are only for more advanced cameras which allow zooming and rotation etc
Re: Elysian Shadows Off-screen Tiles
He already said he knows how to do it, he was just wondering about the team >.>RyanPridgeon wrote: Anyway, @OP: you just use the for loop, these methods are only for more advanced cameras which allow zooming and rotation etc
- tinni5
- Chaos Rift Newbie
- Posts: 8
- Joined: Sat Aug 22, 2009 4:11 pm
- Current Project: shader supporting game engine
- Favorite Gaming Platforms: PC, Dreamcast, PSP, PS3
- Programming Language of Choice: C++
- Location: United Kingdom
Re: Elysian Shadows Off-screen Tiles
Ye...so....TAKE THAT!! Thanks for clearing it up Falco and everybody else.eatcomics wrote:He already said he knows how to do it, he was just wondering about the team >.>RyanPridgeon wrote: Anyway, @OP: you just use the for loop, these methods are only for more advanced cameras which allow zooming and rotation etc
May i ask how the PSP build is coming along? Or has it been placed on the back burner for now whilst libGyro is developed? I'm guessing i have to wait until ESRev 3 to see more lol
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Elysian Shadows Off-screen Tiles
It's coming along just as well as the others.tinni5 wrote:Ye...so....TAKE THAT!! Thanks for clearing it up Falco and everybody else.eatcomics wrote:He already said he knows how to do it, he was just wondering about the team >.>RyanPridgeon wrote: Anyway, @OP: you just use the for loop, these methods are only for more advanced cameras which allow zooming and rotation etc
May i ask how the PSP build is coming along? Or has it been placed on the back burner for now whilst libGyro is developed? I'm guessing i have to wait until ESRev 3 to see more lol
With libGyro, there is no "putting <insert platform here> on the backburner." The engine itself is a completely separate entity from the platform. As long as the libGyro implementation for each platform implements all functions that the engine needs (which it does on all three), it's completely platform independent.