55
votes
Accepted
Optimization of rendering of cube world
No high-performance voxel renderer draws individual cubes or cube faces.
To get good performance, groups of voxels are assembled together into a single mesh, called a "Chunk".
A chunk is ...
44
votes
Is the Microsoft recommendation to use C# properties applicable to game development?
But my impression is that in game development, unless you have a reason to do otherwise, everything should be nearly as fast as possible.
Not necessarily. Just like in application software, there is ...
28
votes
How can I shorten the length of time spent on finding a path using my A* pathfinding code?
Let's start with some general C# optimization advice:
Avoid heap allocations in your hot path. That means anywhere you have new Foo(...) where ...
24
votes
Accepted
How do Minecraft know where village's buildings are if the village is not generated yet?
Yes, it generates more chunks (or at least more of the village tree) than you think it does. This is what I call "area of interest" in my voxel code. There are two kinds of area of interest:
Logical (...
18
votes
Accepted
How to reduce the time taken to path-find to an unreachable location?
Using a bidirectional path finder usually solves this issue if the area the player is stuck in is small. They basically advance from the player's position and the destination at the same time and when ...
18
votes
Accepted
How are NP-Hard problems managed in game development contexts?
In my experience, the main way NP-Hard problems are solved in game development involves relying on the fact that our instances tend to be quite small.
We usually don't need to solve NP-Hard problems ...
14
votes
How can City-sim simulate hundreds of characters?
Like so much of gamedev, the answer to how city sim games accomplish this seemingly-impossible feat is: they probably don't. They're just faking it well. ;)
Sims like these will typically operate on a ...
13
votes
How to reduce the time taken to path-find to an unreachable location?
You should make a sort of connectivity map - by flood-filling all unconnected walkable areas and marking each one with a different tag, once at game start (and every time when terrain changes). Then, ...
11
votes
How do Minecraft know where village's buildings are if the village is not generated yet?
Technical stuff
During Minecraft's chunk generation a chunk passes several stages before it is done and can be rendered.
These stages, in order, are as follows:
...
10
votes
How to optimize collisions
Query only nearby objects
As you already know, you need to check only nearby objects. This means that you need a way to retrieve a list of nearby objects to check.
To do that, you need to divide the ...
10
votes
Is the Microsoft recommendation to use C# properties applicable to game development?
When in doubt, use best practices.
You are in doubt.
That was the easy answer. Reality is more complex, of course.
First, there's the myth that game programming is ultra super high performance ...
7
votes
Accepted
C++ Object management/deletion
You're using a std::vector<Bullet>. This has the advantage of keeping data contiguous in memory, so iterating over it is fast (it has something to do with ...
7
votes
Is there a difference between using one large mesh with 100k polygons and using 1000 meshes with 100 polygons each?
There are two main components to the time it takes to process a draw call:
The time it takes to calculate all the results for every work item in the batch
The time it takes to upload info / switch ...
6
votes
Accepted
Is it possible to calculate a direction vector without sqrt?
If you want a correct mathematical result (correctly rounded to within floating point precision), a square root is the way to go.
It's true that it's more expensive than a multiply, but it's still ...
6
votes
Should I model with quads or with n-gons?
It doesn't really matter. 3d models with faces that have more than 3 vertices don't really exist in 3d graphics*. They are a usability-convention of the modeling program. 3d rendering engines can only ...
5
votes
Accepted
How can I improve my rendering performance in Java?
First of all, instead of relying on the ideas of people, who didn't see a single line of code or even a picture of your game, try profiling it, finding the bottleneck and removing it.
If that isn't ...
5
votes
Avoid useless copies of buffers
The answer is using a PBO, Pixel Buffer Object.
You map a opengl buffer and put the image data into there. Then unmap and bind that buffer to GL_PIXEL_UNPACK_BUFFER...
5
votes
Accepted
Do empty Update() methods get executed and slow down the game while playing?
As stated in the Unity Blog post 1000 Update Calls:
[If you have empty MonoBehaviour messages], all these methods will be called each frame for all your scripts, mostly doing nothing at all!
One ...
5
votes
Accepted
Factorio style conveyer belts, how to implement multiple speeds?
Apply the optimization to sequences of belts of the same speed only. When items reach a belt of a different speed, they leave that belt section and enter a different belt section, just like if they ...
5
votes
Accepted
How does Godot 4 copy vectors?
Checking the GDScript reference docs:
Built-in types
Built-in types are stack-allocated. They are passed as values. This means a copy is created on each assignment or when passing them as arguments ...
4
votes
Most efficient way to get the closest point to a 3d rectangle
This is actually a pretty simple problem if you first rotate the rectangle so it lies flat and at right angles on one plane, and also apply the same rotation to the player location. Now, everything ...
4
votes
Is there a difference between using one large mesh with 100k polygons and using 1000 meshes with 100 polygons each?
Using more meshes with fewer polygons per mesh can improve performance when it allows the renderer to cull more objects. Culling refers to skipping objects during the render process, which improves ...
4
votes
Accepted
Are spritesheets worth it? Is a zip a good alternative?
First of all, there are already image formats with compression. In particular the PNG format supports lossless compression. Furthermore, while it is true that taking a bunch of PNGs and zipping them ...
4
votes
How can I shorten the length of time spent on finding a path using my A* pathfinding code?
Consider using a grid-optimized pathfinding algorithm
A* is the canonical pathfinding algorithm. It's great for general purpose pathfinding on a graph.
It looks like your terrain is a 2D grid ...
4
votes
Accepted
Efficiently find all points within a circle
About this algorithm:
You don't have to check whether every object is inside the circle. If a node square is completely inside or outside the circle, you can use all objects in it directly without ...
4
votes
AI for global decision-making in 4X games
There is a reason why the AI in most 4X games is so bad that it can only challenge a moderately experienced player through blatant cheating: AI for 4X games is a really complex issue. It has to handle ...
4
votes
How to optimize an infinite runner game?
Around 500K - 800K triangles could be rendered in the scene. (models aren't optimized at all)
So my question is : how could I reduce the amount of triangles rendered?
If the models aren't optimized, ...
3
votes
How to reduce the time taken to path-find to an unreachable location?
Add a "maximum number of iterated nodes" parameter to your pathfinding algorithm. When the limit is reached, simply give up and claim that there is no path.
3
votes
How to optimize collisions
My game is working fine for now, but there's no real way to test with 50 players until people actually start playing.
There is. Just write a bot client for stress-testing your gameserver. While it is ...
3
votes
Unity frame-rate drops / stall
As Nico says, your profiler seems to show a big spike of garbage collector activity, which is consistent with the symptom of a sudden isolated stall.
This happens when your scripts allocate and then ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
optimization × 1360unity × 294
opengl × 130
c++ × 111
c# × 102
rendering × 71
java × 69
xna × 65
2d × 62
collision-detection × 60
android × 56
textures × 51
javascript × 47
shaders × 46
3d × 44
algorithm × 42
graphics × 36
gpu × 36
libgdx × 30
path-finding × 30
physics × 28
architecture × 28
voxels × 28
mobile × 27
frame-rate × 27