• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Shawn619

Better FPS with high-poly terrain

12 posts in this topic

I recently increased the poly count on my terrain from 7k->33k in order to get more smooth movement I need to walk across the terrain in my new First-Person-Shooter game. However, FPS(frames per second) is now an issue as you can imagine. I'm looking for an easy, simple solution, if it exists.

 

2r724o2.jpg

 

I'm aware of some techniques: 

 

(i) Frustum Culling: Never tried, but looks lengthy and difficult

 

(ii) Backface cull: I use 

glEnable(GL_CULL_FACE); glCullFace(GL_BACK); 
in my init, but I don't see any significant change in FPS.

 

(iii) LOD: I believe this only applies to terrain that is far away, which wouldn't be appropriate for my situation.

 

 

Any other solutions would be greatly appreciated.

0

Share this post


Link to post
Share on other sites

What hardware are you using? On most modern machines (even phones) 33k faces should not be a big deal.

Are you using VBOs and FBOs?

 

If not, than this should be the first thing you do. A VBO + FBO are perfect for terrain because terrain does not move or change. If it's only 33k faces, then you can throw the entire thing in a single FBO (at least on a PC) and get lightning fast performance.

 

Also, it's 10 lines of code, so it's pretty simple.

0

Share this post


Link to post
Share on other sites

Geforce gtx 650 + i7 3770 (3.4ghz)

 

I'm actually using display lists for everything I draw. Are display lists deprecated? This is how I draw my terrain(inside a display list):

//draw terrain
for(int i=0;i<faces.size();i++){
     glBegin(GL_TRIANGLES);
         glColor4f(colors[faces[i]->colorNum-1]->r,colors[faces[i]->colorNum-1]->g,colors[faces[i]->colorNum-1]->b,1.0);
 
         glNormal3f(normals[faces[i]->faces[1]-1]->x,normals[faces[i]->faces[1]-1]->y,normals[faces[i]->faces[1]-1]->z);
         glVertex3f(vertex[faces[i]->faces[0]-1]->x,vertex[faces[i]->faces[0]-1]->y,vertex[faces[i]->faces[0]-1]->z);
 
         glNormal3f(normals[faces[i]->faces[3]-1]->x,normals[faces[i]->faces[3]-1]->y,normals[faces[i]->faces[3]-1]->z);
         glVertex3f(vertex[faces[i]->faces[2]-1]->x,vertex[faces[i]->faces[2]-1]->y,vertex[faces[i]->faces[2]-1]->z);
 
         glNormal3f(normals[faces[i]->faces[5]-1]->x,normals[faces[i]->faces[5]-1]->y,normals[faces[i]->faces[5]-1]->z);
         glVertex3f(vertex[faces[i]->faces[4]-1]->x,vertex[faces[i]->faces[4]-1]->y,vertex[faces[i]->faces[4]-1]->z);
    glEnd();
}

How would I transform these draw calls into a VBO/FBO?

Edited by Shawn619
0

Share this post


Link to post
Share on other sites


I'm actually using display lists for everything I draw. Are display lists deprecated?

Yes. They are still reasonably performant though, as long as you are using them correctly.

 

This is how I draw my terrain(inside a display list):

To hit the performance path with display lists, you have to specify the same set of vertex attributes for every vertex.

 

You are missing that by only specifying the colour attribute once per face. You can see if repeating it for each vertex gives you a performance boost.

0

Share this post


Link to post
Share on other sites

VBOs and FBOs will be way more performant than display lists. Especially for terrain.

VBOs and FBOs are ideal for stuff that doesn't change (Terrain).

 

It basically means:

1. Put a big object on the video card

2. Draw that object

3. draw again

4. etc...

 

Notice that you only put the giant object on the video-card once. In GFX programming, the most expensive thing is telling your GFX card to do something. It's usually more expensive than what the card is actually supposed to do. So if you can give it as few commands as possible, you should see a great performance increase.

A display list consists of many commands per face which are repeated every frame.

 

In a VBO you write the "many commands" once when you configure your program. Then every time you redraw, you send the GFX card one single command (Draw what I sent you before).

 

Since there is one command per frame, your performance will sky-rocket.

 

Since you are using glbegin and glend, I am assuming that you are using openGL in "fixed pipeline" mode. That's great, because it's very simple.

Search the internet for a tutorial on VBOs.

 

Unfortunately, I've learnt this long ago (and in DirectX) so I cant point you to good & recent tutorial for openGL.

 

But here is a random one from the internet:http://sdickinson.com/wordpress/?p=122. If it is not easy enough, search for something else on the internet. VBOs today are quite common. The site that you originally learnt openGL from should have a VBO tutorial.

 

Learning VBOs, I was able to render a 50k face terrain without breaking a sweat on my Geforce 2 (in 2002). So your 650 should be able to do much much more.

Edited by SillyCow
0

Share this post


Link to post
Share on other sites

 


I'm actually using display lists for everything I draw. Are display lists deprecated?

Yes. They are still reasonably performant though, as long as you are using them correctly.

 

 

 

This is how I draw my terrain(inside a display list):

To hit the performance path with display lists, you have to specify the same set of vertex attributes for every vertex.

 

You are missing that by only specifying the colour attribute once per face. You can see if repeating it for each vertex gives you a performance boost.

 

Thanks for your replies.

 

I'm, not quite sure what you're saying, but i'm almost certain that I am using display lists correctly.

 

Yes, I think I will stick with display lists, for now at least.

 

I figured out the problem. My trees alone were 50k, and my grass alone was 44k, and removed both of these had no effect on FPS, so clearly an increased terrain polygons of 7k->33k isn't the problem.

 

The problem was with something completely different. Every frame I am doing a line-triangle intersection test on every terrain triangle to detection which polygon my character(camera) is currently sitting on, so that's why an increased terrain triangles from 7k-33k was such a big deal.

 

Can anyone recommend how I can reduce the number of line-triangle tests I need to do each frame? Because currently i'm at the worst possible solution, O(N) line-triangle comparisons, where N is the # of triangles in the terrain.

0

Share this post


Link to post
Share on other sites


Can anyone recommend how I can reduce the number of line-triangle tests I need to do each frame? Because currently i'm at the worst possible solution, O(N) line-triangle comparisons, where N is the # of triangles in the terrain.

Your terrain is a height map, correct?

 

In that case, there is no need to do triangle intersection tests. You can calculate the intersection directly against the height map.

0

Share this post


Link to post
Share on other sites

 


Can anyone recommend how I can reduce the number of line-triangle tests I need to do each frame? Because currently i'm at the worst possible solution, O(N) line-triangle comparisons, where N is the # of triangles in the terrain.

Your terrain is a height map, correct?

 

In that case, there is no need to do triangle intersection tests. You can calculate the intersection directly against the height map.

 

 

No, not a height map. And please don't tell me to change my terrain to a height map.

 

It is a .obj model that is imported, then line-triangle tests are done on the imported triangles from the .obj model.

0

Share this post


Link to post
Share on other sites


It is a .obj model that is imported, then line-triangle tests are done on the imported triangles from the .obj model.

In that case, you are out of luck.

 

General solution would be to provide a lower-resolution version of the mesh for collision detection.

0

Share this post


Link to post
Share on other sites

You could always use an octree,

That should make your intersection tests faster.

However, it is fairly complicated to implement.

 

But that is the standard "make my intersection tests quicker on an arbitrary mesh" solution.

 

If this is not a school project, you can probably grab an octree off the internet.

 

Hoever, if you can use a height map ,you'll have less work ahead for you.

0

Share this post


Link to post
Share on other sites

Update:

 

I randomly thought of a method that allows me to create a short list of faces to test intersection each frame, instead of testing all faces in the terrain(O(N)) on every frame.

 

With my method, I was able to narrow down the amount of intersection tests from the original 33000(all terrain faces) to ~100 each frame, which is quite manageable and resolved the FPS issue.

 

In computational complexity, I was able to reduce intersection tests from O(N)->O(sqrt(N)).

Edited by Shawn619
1

Share this post


Link to post
Share on other sites

In other words, you implemented a O(log n) solution a la spatial subdivision?

2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0