0
\$\begingroup\$

So I am currently working on a small Game(/engine) in OpenGL and I want to build a little world editor. Nothing too fancy: Just some functions to add objects to a scene and manipulate them (rotation, translation etc). Up to now I have everything set up for loading models into the scene and setting up simple directional- and pointlights.

But one thing has been bugging me since the start: What is an average floor / ground made out of? I would guess that, for exmaple, a grass floor is just a lot of vertices / faces with a grass texture wrapped on them. But how are those textures connected and how can you change the elevation for certain vertices to create hills?

I am essentially asking how the recommended implementation of floors is in 3D environments (preferrably OpenGL 3.3) since I can't find anything on that topic on Gergl.

\$\endgroup\$
  • \$\begingroup\$ Look up textured heightmaps. That's what you need. They're connected in chunks, usually, or one big mesh if your world is small enough. As for how, well, vertices that are next to one another but belonging to different triangles are "Connected". \$\endgroup\$ – Lolums Apr 10 '16 at 11:53
  • \$\begingroup\$ Thanks I'll have a look at that! I know that vertices are connected, but I can't get my head around on how you can wrap texture patterns on faces so they match up. Hard to explain but still thanks for tha answer! :) \$\endgroup\$ – Niklas Vest Apr 10 '16 at 11:59
  • \$\begingroup\$ This is probably wider and more discussion oriented question than you intended. First of all, it is not clear whether you are asking for OpenGL specific back-end implementation(3rd paragraph) or general terrain representations(2nd paragraph) or perhaps even physics(?), and even if you clarified that it is based mostly on personal opinion what is best/recommended/most common way of doing this. (we do not have statics of all games ever made) \$\endgroup\$ – wondra Apr 10 '16 at 12:17
  • \$\begingroup\$ To change the elevation you just change the Z coordinate (or Y depending on your favourite coordinate system). The textures are connected by careful U/V coordinates. \$\endgroup\$ – user253751 Dec 8 '17 at 3:06
0
\$\begingroup\$

They're usually just big planes cknsisting of smaller planes, and each vertex has a separate heoght attached to them.

For heights, people usually use heighmaps or pseudo random noise generation using Perlin or Simplex noise.

Some other games only use a small amount of pre-generated terrain, then scale it up to the size of the whole terrain, and lastly put the information on it again, but repeated multipke times with smaller sizes. This creates a fractal look and is able to generate huhe terrains with only a fraction of the information it would need.

Objects, such as grass, flowers, trees etc get generated procedurally too.

If you use OpenGL 3.2 and above, there's a chance ypu can use geometry shaders to create vertex information on the fly. This is not recommended though, as of 2016 it's still missing from many GPUs.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.