Hot answers tagged

44

There are couple of things you can do to increase drawing performance. You said they were pretty far away. You could use LOD to decrease the vertex count of those trees, and thus decreasing time required to go through all the vertices being drawn. Even though this is most likely not the issue at hand (GTX1080 with just 10k trees with 200 tris each, puny ...


39

In the real world, those provincial borders will often be following geological features like rivers. So maybe a good approach would be to model the geology of the island and have the borders fall out of this? Red Blob Games has some good articles on this subject, with nice looking results. His approach seems to involve using Voronoi tessellation, and ...


27

I would solve this problem with two passes of Voronoi diagrams: First Pass: Region Partitioning The first pass would use a somewhat sparse distribution of points (i.e. the distance between the points should be relatively large) in order to roughly divide the island into regions (see the note below regarding point generation). Next generate a Voronoi diagram ...


14

You want to mix different wave lengths with different levels of intensity. E.G. Have one long wave, that has a high intensity, and a short wave with low intensity. Now add the two(or more) waves together. Black line being long waves and high intensity. Red line being short waves with low intensity. Green being the final result. float getHeight(float x) ...


13

Basic chunking is a good way to start. You can move to more sophisticated data structures like octrees later, if you need. For now, simply divide your terrain into chunks of given dimensions when loading the model from disk. Depending on your data, you might either want to split your terrain into pillars on a plane spanning the full height, or in cubes in ...


13

Ok, so the problem was simply that I wasn't using pre-computed realtime GI. I check that on a little while ago but it didn't have an immediate effect so I left it and forgot about it, and the lighting processing time was so long too. However, it just finished processing it, and my word, my fps has jumped up by 3x. So for now, I'll leave it at that and in the ...


11

One simple way is to use something like the midpoint displacement algorithm. It can be used to generate terrain, lightning, clouds, and other things as well. (It's a bit old, but easy to understand.) It would also be possible using a Fourier Transform to add in various frequencies at various amplitudes to generate terrain. Some systems, such as liquid flow,...


9

Check out Amit Patel's excellent article that I feel is kind of a quintessential resource for procedural generation of terrain... http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/ The key thing he does is use graph structure to model his terrain, not straight up noise maps (Perlin et al). I won't embed his illustrations, ...


6

When rendering terrain, for efficiency you usually want to reduce the level of detail of geometry in areas far from the camera. As the camera moves around, you would adjust the level of detail to keep the area near the camera at high detail. Geomipmapping, geometry clipmaps and suchlike are ways of managing this on the CPU. Although the GPU always does ...


6

so, to rework from comments: this is Z-fighting. The math is very well explained here: http://chaosinmotion.com/blog/?p=555, and the ways to solve it here: https://www.opengl.org/wiki/Depth_Buffer_Precision, but the gist is that Z-buffer is discrete, non-linear, and depends on the ratio of farplane/nearplane. discrete: the distance between near and far ...


6

You need Terrain as it allows you to add vegetation (Trees & Details), make adjustments to the relief like rise land to form mountains and also it gives you ability to paint textures on it. A plane is a simple game object that can only be scaled on two axes and none of the above can be done with it. They are both rendered only on one side of the object. ...


6

Before Diamond-Square begins, you'll have to make sure the outermost boundaries (and the maximum number of potential midpoints generated therein) are set equal on either side of the map (in x and y). Only then can you begin full generation of the centre with something approaching a seamless wrap. What they meant by "consistent" is "all outermost corners and ...


6

I have little experience using Unity directly, but I've been a level designer for years and a much easier approach rather than worrying about cutting holes into your terrain is to simply build up a C shaped ridge in your terrain for the size of your cave and then cover it with rock meshes to give it the illusion of a cave. Another approach is that you ...


6

Here's one (relatively exhaustive) method you can try: Take your terrain heighmap (left) Mask the areas that are too steep to build on (orange, center) Propagate a distance field from the too-steep region (blue-green gradients, right) until you reach your maximum town radius: (You can also use the Jump Flooding Algorithm to speed up this part) The ...


6

In addition to what Pikalek said, it's also known as the Midpoint Displacement algorithm (because you perturb the midpoints of each edge) or Diamond-Square algorithm when working with a square instead of a triangle.


6

Storage of destructible terrain For the terrain I would recommend looking at the quadtree data structure. It provides an efficient way to store destructible terrain. For an excellent, in-depth explanation, see Coding Challenge #98.1: Quadtree - Part 1 by The Coding Train. The core idea of a quadtree is that you don't need to store every individual pixel. ...


5

You can read a more detailed answer here:Which is the best LOD method for planet rendering? I'm doing exactly something similar for my computer science degree thesis and attacked the same problem. The problem you have is jitter, and you will find another one more called z-fighting. Jitter: Most of today’s GPUs support only 32-bit floating-point values, ...


5

I create random map scripts for Age of Empires 2. My most recent one is for the HD version. If you're looking to understand how to create maps for Age of Empires 2, there is this excellent guide to RMS (Random Map Scripting). Age of Empires uses an expert system, allowing scripts to write routines for the generation rules, which you can learn a lot from. ...


5

I think the obj file format is what you need. OBJ is pretty commonly used in 3D graphics, and it's a text file. You will need to walk through your mesh properties and write your own file. Then you'll be able to load and display it.


5

Non sequitur, your question does not entirely make sense. You cannot store infinite chunks. You can only ever store the subset that is currently of interest, i.e. those around the player(s). So how does the infinite part work? You generate chunks according to some global function. For example, Minecraft's use of Perlin noise (a global function) means that ...


5

I suggest this aproach. Let fs(x,y) be your simplex noise function. Let's introduce a second function : f(x,y) = ((float)Math.Sin(((float)x/(float)WIDTH) * Math.PI) ) * ((float)Math.Sin(((float)y / (float)WIDTH) * Math.PI) ) or any function that rassemble the following and that gives values from 0 to 1: at this point take your simplex noise fs(x,y) : and ...


5

You'll probably want to do a 2nd pass and carve caves after doing the regular quick height-map generation pass. Find a steep slope in the low-frequency height map layer (if you use multiple resolution height map layers) and dig a cave started by using the slope's negated normal. Same goes with crevices, canyons, and other terrain faults. Once you build a ...


5

This is due to Back-Face Culling. You'll have to create a shader and set "Cull Off" in the SubShader section: See Unity Documentation on shaders. Be warned that the normals will be inverted on the back side and will cause lighting to be incorrect on two-sided lit materials. If you need your surface to be lit correctly on both sides you will need to either ...


5

Sim city uses a an XY grid, and the heights are discrete. In addition to this, the slopes seem to be limited to one "step" up or down. So just handle all possible cases for a grid-cell. Each cell has four corners: N0, N1, N2 and N3. Let's designate the height at N0 as "nominal." Then for each for the remaining corners (N1,N2,N3) there are three cases ...


5

This is a maximum subarray problem in disguise! It's a popular interview question. Instead of finding subarray sums, we're finding terrain that can hold water, and instead of finding the biggest subarray, we're finding all subarrays. With the maximum subarray problem, we can track the current maximum subarray as we scan the array. The key insight is that ...


4

One (expensive) approach I've been playing with is Constructive Solid Geometry (CSG). csg.js, for example, is a nice clean short piece of code (if inefficient BSP approach) that can subtract and union meshes together. It'd be straightforward to port the approach literally to any other language. And there are more efficient CSG algorithms that can be ...


4

Starting from Unity 2019.3, you can properly cut holes in terrain surface (see https://blogs.unity3d.com/2019/08/27/unity-2019-3-beta-is-now-available/#attachment_82836) However, this won't create the cave mesh for you. If you are looking for a terrain hole system that creates meshes automatically you may want to use a plugin like this one: https://...


4

By looking at your picture your problem seems that you need to smooth(average) your normals. That is when a vertex is shared by multiple triangles and yet has one normal you have two options to deal with this problem: Smooth edges: You calculate the normal of each vertex for each adjacent triangle and then average them. Hard edges: You duplicate each ...


4

The shape is irregular because of the obstacles. If you shoot a ray in every direction (360 cicle around unit), you determine if you hit an obstacle, and if yes, at what distance. If the ray does not encounter any obstacles before reaching the line of sight distance, then it stops, otherwise it stops at the point of encounter. This is by no means efficient ...


Only top voted, non community-wiki answers of a minimum length are eligible