• 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
eggmatters

Design question: How many polygons is ideal for a landscape surface?

7 posts in this topic

Hi, I have a fairly rudimentary design question.
I've created an artificial landscape using the diamond square algorithm. Overall, I'm happy with it. I decided to use Triangles as the base polygon for rendering because they're the easiest to compute normals against.
I have a question about how to proceed concerning two factors:
1. Vertexes with local maximums in the height map "spike" as the higest vertex is the top of a triangle. I have these pointy bits in my landscape. It seems to me that the only ideal solution is to subdivide the polygons over any given set of vertices and apply noise to "weather" these spikes.
2. My vertices are seperated by one whole integer value (althogh they're rendered using floats.) When aplying a texture to polys with a lot of surface area (due to vertical relief) the texture is stretched. I once again expected this but would like some feedback on how to proceed.

I've attached a screenshot. This is with the roughness factor turned way up. I've only applied one texture so you can safely ignore that except for the stretching effects on the mountain and cliff faces.

If I divide a polygon into several smaller ones, what would be the ideal "depth" to achieve this?
Is there some other, better, method to map textures to polygons with varying surface areas? (I haven't seen anything like this, nor would expect to.)

There's no real code to show as this is basically a design question but would be happy to provide a sample if you'd like.

Thanks! Edited by eggmatters
0

Share this post


Link to post
Share on other sites
If anybody is interested, I was able to remove the spikes and subdivide the terrain. In the diamond square algorithm, the square step was adjusted to accept a random number within the range of the average of the surrounding points modified by 2 factors, overall height and roughness.

The algorithm ran for all points rendered (including the subdivisions.) Each x and y of the terrain heightmap were whole integer values, so I added a "subdivision" factor so that when I rendered the vertices, they were each placed on a point between 0 and 1.0 per subdivision.

So,

[source lang="cpp"]Terraingen::Terraingen(int dimension, int polyDepth) {
//polyDepth is the number of polygons to render between 0 and 1;
dimensions = dimension * polyDepth;
srand((unsigned)time(0));
range = 300;
roughness = 10;
//heightmap:
terrain = std::vector< std::vector<float> >(dimensions + 1, std::vector<float>(dimensions + 1, 0.0f));
//run diamond square
. . .
//During rendering:
void GLWidget::testDiamondStepTerrain(int polyDepth) {

int Width = dsTerrain.size(); //dsTerrain is the heightmap.
int Height = dsTerrain.size();
std::vector<TRIANGLE> triangles;
float poffset = 1.0f / polyDepth;
float scaleX, scaleZ; //floating point x and z values between 0 and 1.

for(int x = 0; x < Width - 1; x++){
if (x > 0) {
int tmpX = x / polyDepth;
int modX = x % polyDepth;
scaleX = ((modX) == 0) ? tmpX : tmpX + (poffset * modX);
}
else { scaleX = 0; }

for(int z = 0; z < Height - 1; z++){
if (z > 0) {
int tmpZ = z / polyDepth;
int modZ = z % polyDepth;
scaleZ = ((modZ) == 0) ? tmpZ : tmpZ + (poffset * modZ);
}
[/source]

So this works for polyDepth = 2, but not for 4 or higher (polyDepth must be a multiple of 2.) I know why, but can you spot it?

[attachment=10957:landscape3.png]
0

Share this post


Link to post
Share on other sites
[quote name='eggmatters' timestamp='1345851282' post='4973146']
I decided to use Triangles as the base polygon for rendering
[/quote]
There are no other polygons (with more edges), unless you are using the deprecated legacy OpenGL. But maybe that is a conscious choice you did? Just to warn you that it may lead into an irreversable dead-end.
0

Share this post


Link to post
Share on other sites
Not sure I follow you Lars. But, that's good news as it was a conscious choice because in an earlier incarnation, I [i]was[/i] using quads. When I tried to compute a an upright vector (for POV) I wound up splitting the quad into triangles anyways. But, that being said - all of the openGl literature I've seen (whose dates are dubious) allows for Quads, triangle fans, quad strips, multi-sided polgons etc.

But, what is the dead end that you're speaking of? Using something other than triangles or some other piece of my post? Thanks!
0

Share this post


Link to post
Share on other sites
See some explanations:

[url="http://stackoverflow.com/questions/1218449/opengl-whats-the-deal-with-deprecation"]http://stackoverflow.com/questions/1218449/opengl-whats-the-deal-with-deprecation[/url]
[url="http://www.opengl.org/wiki/Fixed_Function_Pipeline"]http://www.opengl.org/wiki/Fixed_Function_Pipeline[/url]

In the immediate mode, you do a glBegin(), you define some vertices, possibly some information about each vertex, and then glEnd(). This is limited in functionality. There are enhancements, but from Opengl 3 it was deprecated (though still available in compatibility contexts).

The modern way to do this is to define a local buffer with all your vertex data. This data can be of any type or meaning, OpenGL doesn't care. You then transfer the buffer to OpenGL memory, and tell OpenGL how to extract data from the buffer (still not depending on what is a coordinate, what is a color, or UV, etc.). Finally, you define the vertex shader and fragment shader. Here, the interpretation of the data is done, producing coordinates, colors and mapping textures. And much more. It is obviously more effort than the immediate mode. But it is far more flexible. You are guaranteed to reach a point where you want to do something if you have a "real" project, and the best answer is to modify the shader to get it done.

For a goot tutorials how it is done, see: [url="http://www.arcsynthesis.org/gltut/"]Learning Modern 3D Graphics Programming[/url] or [url="http://www.opengl-tutorial.org/"]http://www.opengl-tutorial.org/[/url].
0

Share this post


Link to post
Share on other sites
Thanks for that. Was just at that stage. I was aware of the need to buffer vertex data and found a good tut but I am appreciative of the links. What the code snippet didn't show was that I compile each terrain section into a list. That helped somewhat. Can I compile the list using vertex arrays or are the two implementations mutually exclusive? (Sorry to ask such a naive question, will probably find out on my own. -- Just found: "Remember that you cannot place any client state commands in the display list, therefore, glEnableClientState(), glVertexPointer() and glNormalPointer() should not be included in the display list." )
I was led to vertex arrays by
1. seeing it in the literature and knowing that I would need to implement it once I started throwing a lot of polys around and
2. A bug in my vertex rendering inserted a neat little space between the edges of all of my polygons (I forgot to redefine an offset) and voila! the rendering screamed. I looked around for ways to eliminate polygon edge repetition and was pointed towards some literature on the arrays. Thanks for pointing me to some more.

BTW, I'm running openGL 2.6.(the QUADS support) I installed it in May I believe. I'm developing on a Debian system and their package management system is notorious for out of version packages since they are so meticulous about what they accept in their repos. Waiting to compile the latest jars from Mesa.
0

Share this post


Link to post
Share on other sites
You say OpenGl 2.6, but I think it is 2.1 (which was the last in OpenGL2+). Some older graphics cards doesn't support better than that, but they are quite old today and have low performance. Unless your target is to support really low performance systems, you may as well go for OpenGL 3+. OpenGL 4+ adds some advanced features that can wait for now.

I find names in OpenGL highly confusing, and the documentation isn't very helpful.

VBO, Vertex Buffer Object: This is the OpenGL buffer where you can store data. Almost any kind of data, usually vertex lists, texture coordinates, etc.
VAO, [url="http://www.opengl.org/wiki/Vao"]Vertex Array Object[/url]: This is a kind an object that saves a state and pointers. From OpenGL 3, you always need at least one. They are actually quite helpful, but at first it is a little confusing what they store. When it is setup correctly, all you have to do is bind it before the draw call ([url="http://www.opengl.org/wiki/GLAPI/glBindVertexArray"]glBindVertexArray[/url]), and OpenGL will know where to find all vertex data. I couldn't learn how to do this from the documentation, but using examples helped a lot.

There are some really nice reference implemtations at [url="https://github.com/progschj/OpenGL-Examples"]https://github.com/progschj/OpenGL-Examples[/url]. They are as small as they can get, easy to read, but still provide a complete one-file application. My experience from OpenGL is to never change too much at a time. I copy a lot from example, and do small changes. OpenGL is sensitive to mistakes, based as it is on many global states. The famous "black screen of death".

Btw, sorry for not answering on your original questions in a straight way!
0

Share this post


Link to post
Share on other sites
Great stuff! Thanks. I'm re-aligning my code for VBO's now. I'm at < 1000 lines in and luckily, am doing small changes + VCS (local git) to keep things manageable. Appreciate the directions!
0

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