Jump to content
  • Advertisement
Sign in to follow this  

Rendering a cell grid

This topic is 4442 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

Hi, I'm trying to render a city, GTA1 style, but then isometric. Therefore, I have a 2D cell grid. Each cell contains information about entities (trees,bins, etc.) and the amount of 'stores'. Each cell can have multiple stores. Each store is a cube with a certain material, so this way you could create simple houses. Now my question is, how to render it fast? The geometry / polycount isn't a problem, but I'm afraid the 'material switches' could be. With material I mean the texture applied on a cube(a brick wall, a road texture etc.). For example, I could render with this pseudo code:
// Loop through the 2D cell grid
for x=0 to width
  for z=0 to depth
    // render stores(cubes) for each cell
    for y=0 to cell[x,z].height
Pretty simple, and I could check the camera position to cull cells outside the view frustrum. But as you can see, I need to apply the material for each cube again. A couple of switches is not that bad, but things will get slow if I need to render many cubes. Normally I would fix it by sorting everything. First render everything with texture1, then texture2, etcetera. But those were static scenes where the culling wasn't that dynamic, so the sorting had to be done only once. Is there a fast way to sort for this type of game? Or maybe there's another better approach? Greetings, Rick

Share this post

Link to post
Share on other sites
Of course! Smart idea. Normally this won't work since the textures are repeated, but in this case I could use texcoords offset. The texcoords are always in the 0..1 range, so that should work.

Thanks for the tip!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!