What is the best way to represent a large field of objects while using minimal resources?

Started by
4 comments, last by Norman Barrows 8 years, 2 months ago
I have recently started to plan a project in Unity that will be for android. I have a database that consists of over 150,000 stars (may trim this down if I/O cripples the overhead). The game will hopefully consist of a free to explore universe creating the illusion that the user is flying amongst a realistic representation of the stars.
My biggest concern at the moment is how do I create a realistic environment, while keeping the (phones) resources to a minimum? Some people mentioned using octrees, would this be wise?
What are some common errors many people run into with such development?
How do I manage the stars looking realistic and the background looking realistic at variant distances while once again keeping resources minimum?
How do game objects different from what is in immediate view to far view?
What type of navigation mechanics work best for such a setup?
This is my first game that I am looking to create so any help would be much appreciated to this novice! Thanks in advanced!
Advertisement
I would first try to render each star as a point sprite. I would group the stars in clusters in a regular grid and make each cluster a single mesh so the cluster could be drawn in a single draw call. Unity will figure out which clusters are on screen so you wont have to worry about culling.

If you want 150,000 stars you will may need to make a max render distance so you aren't trying to draw too many stars per frame, but test this first, maybe it will run fine. In this case you would want to have the stars fade gradually as they get farther away. Those are my two cents.
My current game project Platform RPG
Why such a trouble for a first game. Try something more simple like tic tac toe in 3d. I dont think you will have good performance because of overdraw. Fill rate will be your bottleneck. Instancing is a must, so you are automatically limited to devices that support opengl es 3.0/3.1. I dont understand something about the scale of environment. Are you talking about real scale, star distance in light years??? I hope not, as I think 64bit memory address is too small.

I have a database that consists of over 150,000 stars. The game will hopefully consist of a free to explore universe creating the illusion that the user is flying amongst a realistic representation of the stars.

Representing the star data itself is among the least of the difficulties.

While the scales you are talking are fun to think about, in practice they tend not to work well in games.

The idea is fun in theory, and a few games have explored the theme. But there are very good reasons the games do not use realistic representation of planets and stars and interstellar distances.

There are many major obstacles.

Consider the engines and graphics systems are using floating point numbers. They have about six decimal digits of precision, so you can count to about a million stepping by single-digit values. After you get to around 4 million or 8 million or so, you can no longer increment by one. Adding 1 more leaves the number unchanged, it is too small for that scale of floating point.

Usually games work with a meter scale, with a useful region around one km in size. The largest local area is a few city blocks, the smallest distance is about the width of your fingernail. That means a scale of around 1000 to 0.001 meters. Anything outside that tolerance throws off the six decimal digit precision.

The distance from Earth to the Sun is about 150 billion meters. If you attempt to mix the scale of meter-sized objects and space ships with the scale of interplanetary distances, floating point precision means the smallest increment between two objects is a kilometer distance. Anything smaller than a kilometer is too small to exist at that scale.

The distance from our sun to Proxima Centauri, our probably-nearest star, is about 4 light years or 4*10^16. Represented as a float with six decimal digit precision, even the entire star is too tiny to exist at that scale. If you can represent an interstellar distance in a float you cannot also represent the size of a ship, a planet, or even an entire star; the distance is so huge it overwhelms the scale.

There are solutions to the problems of scale, but they take either a bunch of difficult math or some complex systems of relative scales and relative distances. They are a bad for for a first project, a second project, or any project before several years of experience.

The next problem will probably be that realistic distances means a lot of distance.

The scale of objects tends to break down terribly, planets are only a tiny spec unless you are very close to them. Traveling from one planet to another planet at speeds we know we can reach means travel times of months. Traveling the distance at light speed means times ranging from minutes to hours.

If you're looking at realistic interstellar distances, they are so much farther. Again, our nearest star is 4 light years, our galaxy is over 100,000 light years across. If you have light-speed travel in your game, then waiting around to reach your destination means many years, possibly many lifetimes, before reaching the destination. You can include faster than light travel in your game to shorten that to game-friendly times of a few seconds or maybe even a full minute, but you're mixing realistic distances with travel measured at light-years per second, you lose any credible claims of having realistic star distances.

Most space games do this by faking everything and not pretending they are realistic. You have a tiny group of asteroids or satellites but they are not a realistic scale. Something is drawn nearby on the skybox picture that looks like a planet, something else is drawn on the skybox picture that looks like a star or two. Physics and motion are all faked to values that feel good to play. Travel is through sci-fi jump gates or warp speeds or hyperspace or some other fiction so you can jump directly to the action.

The project you describe is ambitious even for an experienced team of professionals who are comfortable finding good alternatives to these problems. For a first game this is bad selection. Think much smaller in scale for now.

I have recently started to plan a project in Unity that will be for android. I have a database that consists of over 150,000 stars (may trim this down if I/O cripples the overhead). The game will hopefully consist of a free to explore universe creating the illusion that the user is flying amongst a realistic representation of the stars.
My biggest concern at the moment is how do I create a realistic environment, while keeping the (phones) resources to a minimum? Some people mentioned using octrees, would this be wise?
Yeah it may help.
What are some common errors many people run into with such development?
I'd say overdoing stuff.
For performance you need clear goals, Take your minimum required hardware and test on it.
Set up your goal before testing for performance.
How do I manage the stars looking realistic and the background looking realistic at variant distances while once again keeping resources minimum?
Games are illusion to what happens. The best thing is to create something that looks good, however it does not need to be accurate.
How do game objects different from what is in immediate view to far view?
Looking for afar usually makes the objects less detailed, which mean you can either ignore them, or draw minimal objects. (Just a sphere with no texture, or even a point if it's really far)
What type of navigation mechanics work best for such a setup?
Depends on game design. I'm not sure what is your question here.
This is my first game that I am looking to create so any help would be much appreciated to this novice! Thanks in advanced!

Learn the technology as much as you can before you actually implement stuff. Play around and see what really looks good.

You have really general question. This is due to lack of knowledge.

My advise, just grab some tutorials, and dig in unity to learn how to implement what you want.

first off, the difficulties peculiar to the game type make it a poor choice for first project. that being said...


how do I create a realistic environment, while keeping the (phones) resources to a minimum?

stars background for your skybox. boom - you've drawn all the stars right there. "don't need no stinkin' database!". the database comes in when you draw a single nearby star system.

3d billboards for nearby stars and planets, and distant galaxies, nebulae, etc.

the stars database should be stored in a sparse matrix, IE a list with the location of each star and necessary details about the system: start type, planet types, moon types, planet and moon orbit radii and periods, etc. combined with a game clock, you can calculate the exact position of any planet or moon at any time for drawing and collision purposes.


Some people mentioned using octrees, would this be wise?

probably not. octrees tend to be better for different types of scenes.

you'll probably start with a simple range check, followed by a frustum cull, and that's it. maybe some type of collision map for faster range checks, or perhaps some sorted indexing system to go with the stars database, allowing you to only check nearby stars, such as those in the same "sector" or whatever. but collision maps and indexing systems are possible optimizations, only to be considered if brute force is too slow. in this case, brute force would be "for each star, if close enough, draw the system".


What are some common errors many people run into with such development?

getting the scale, lighting, and SFX wrong. frob already mentioned the typical hacks used for scale. lighting should be harsh and stark. lots of diffuse, little or no ambient. and there's no sound in space (like explosions).


How do I manage the stars looking realistic and the background looking realistic at variant distances while once again keeping resources minimum?

high quality textures. just use public domain photos. works great.


How do game objects different from what is in immediate view to far view?

they don't. you never see more than part of one system at a time close up. IE maybe one star, a few planets, and maybe a moon or two if your're close to a planet. that's it. the tricky part is drawing them to scale and realistic visual ranges. most graphics libraries use floating point internally, giving you only about 7 or 8 digits of precision to work with. so a separate world coordinate system is required. you can't just use floats for your world coordinates.


What type of navigation mechanics work best for such a setup?

normal 3d guided missile AI. the big problem is if you model both sublight and FTL travel. programming the AI to fly to a set of coordinates without overshooting takes a bit of work. took me about a week for SIMSpace 8 (currently under development). the good news is that's the hardest thing to do in these games: get the AI to fly to a target at FTL and sublight without over or undershooting the target. from there is all downhill, standard gamedev stuff. the AI that controls ship speed, and drawing star sized objects with incredibly long visual ranges are the only really unique things in these games. everything else can be found in other games like flight sims and shooters.


This is my first game that I am looking to create so any help would be much appreciated to this novice! Thanks in advanced!

SIMtrek was the 4th game i ever made (guess the number, lunar lander clone, flying saucer shooter arcade game, then SIMTek) - and the first i ever published. Its big claim to fame is it was the world's first Star Trek flight sim, a top 10 download on AOL back in 1990 when it first came out. I'm now working on my 8th major version of the game.

there are 3 things you'll need to deal with:

1. a world coordinate system. location are stored in world coordinates, and converted to camera relative coordinates for drawing. the world coordinate system must be able to hold the longest distance in the game, to whatever resolution you want. so perhaps an int for light years or something, and a float for location within that one light year across cube. that kind of idea. don;t recall what i'm using in simspace 8, but its big. it can cover the entire galaxy with a resolution of 10cm or something like that.

2. drawing big stuff far away. basically you draw it 1/X in size at 1/X distance, and it looks the same. X is chosen so its within floating point distance of the camera for drawing.

3. AI to fly to a location using both FTL and sublight speeds. getting it to stop on a dime can be a total B-tch! coping out by using jumpgates etc is an alternative.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement