Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rendering/culling chunked diamond iso map?

Started by Gotta Aug 5, 2010 at 3:27 PM 3 replies 3k views
Original Post
Gotta
Gotta
Hello guys,

I'm sure that its been solved here many times, but I checked about 40 topics in this subforum and I did not found a solution to my problem. All I found was rendering routines for staggered map.

I have a large isometric map, which is chunked into blocks that are also diamond-like (its just like a small diamond map). I load 3x3 chunks of that map, to be sure that I can render also corners where chunks concatenate on screen.

I've managed to write loading/rendering algorithm for that map, but problem is that its very slow, about 20 FPS, even when I'm not rendering offscreen. When I disable all OpenGL rendering calls, I still get 20 FPS, so its definitely caused by rendering algorithm and not by rendering itself.

I render like this (pseudo code):

int BLOCK_WIDTH = 32; // number of tilesint BLOCK_HEIGHT = 32; // number of tiles POINT cameraPos = getCameraPos();for (int i = 0; i < 3; i++){	for (int j = 0; j < 3; j++)	{		BLOCK block = blockMatrix[j];				POINT blockPos = getBlockDrawPos(cameraPos, block);		int xMin = 0;		int xMax = BLOCK_WIDTH;		int yMin = 0;		int yMax = BLOCK_HEIGHT;				for (int y = yMin; y < yMax; y++)		{			for (int x = xMin; x < xMax; x++)			{				POINT tilePos = getTileDrawPos(blockPos);				if (isTileOffscreen(tilePos))					continue;				else renderTile(block.tileMap[y][x], tilePos);			}		}	}}


As I said, the problem is that this algo is very slow (and stupid), even when I remove renderTile() line.

I guess that I need to find correct yMin/yMax and xMin/xMax to speedup rendering. But I'm not sure if its enough, maybe there is better algorithm to render it without rendering 3x3 block matrix.

If you have some working snippet, I'll be very grateful if you share it with me. Or link to some topic where it was solved already is enough.

Thank you very much for any input...

(Ah, and sorry for bad English :)

PS: My tile sprite resolution is 80x40 pixels, and it looks like this one:
tile.bmp

Here is image how that diamond map looks like:

diamond_staggered.png
GenPFault
GenPFault
Is renderTile() doing basic glBegin()/glEnd() stuff? If so, you may just be making too many calls into OpenGL for it to run well, due to the per-call overhead.

I'd suggest batching all your geometry for a given frame and switching to vertex arrays (VAs) or vertex buffer objects (VBOs) to cut down on the number of OpenGL calls.
relsoft
relsoft
You do some spatial partitioning of your huge level (ie. a grid or a quadtree), then you find out which box of your grid resides inside the view frustum and render your tiles if the box is either inside or intersects the view frustum.

http://rel.betterwebber.com/mytutes/octreetute/octree_tute.zip

Try to see the difference in speed when you run example 4 and 4a.
Hi.
Gotta
Gotta
Thank you guys for you replies.

To GenPFault:
As I said before, its so slow because of rendering algorithm, not by rendering itself. So when I remove that line with renderTile(), there is almost no difference in FPS (max about 10).

To relsoft:
I've tested that octree demos, and with version 4, I get about 250FPS, and with version 4a, I get no more than 15FPS. However, I can't right now rewrite whole map loading and rendering stuff because of spatial partitioning. But anyways, thank you again.

To everybody else:
I bet my shoes that there is much "simpler" method how to find out which tiles are visible/offscreen. (But well, I'm too dumb to find out that by myself.)

Also, Is there any way how to calculate yMin/yMax and xMin/xMax? Look at that pseudo code I posted in post above.

Thank you for any answer.
leopardpm
leopardpm

Thank you guys for you replies.

To GenPFault:
As I said before, its so slow because of rendering algorithm, not by rendering itself. So when I remove that line with renderTile(), there is almost no difference in FPS (max about 10).

To relsoft:
I've tested that octree demos, and with version 4, I get about 250FPS, and with version 4a, I get no more than 15FPS. However, I can't right now rewrite whole map loading and rendering stuff because of spatial partitioning. But anyways, thank you again.

To everybody else:
I bet my shoes that there is much "simpler" method how to find out which tiles are visible/offscreen. (But well, I'm too dumb to find out that by myself.)

Also, Is there any way how to calculate yMin/yMax and xMin/xMax? Look at that pseudo code I posted in post above.

Thank you for any answer.


are you rendering a 2d iso Map? With sprites as tiles? If so, then I have a routine for you which is lickity-split fast, and easy to put into a LUT because it draws the ISO tiles in correct order (from upper-right to lower left, in diagonal strips from top to bottom). Also, the output is a Staggered block map which is rectangular.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.