Discovery Gaming Community

Full Version: Took me two weeks to get asteroid field to work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
We are all pretty used to the way asteroids work in Freelancer and we took for granted how smooth they are!

I haven't realized what a challenge it is to make an asteroid field that spreads out long distances without stuffing GPU's memory with millions of objects. I had to figure out a way to dynamically place asteroids around the player as the player moves around in the field, and also to ease out the eye sore when asteroid pop out of nowhere, I had to write a shader that makes the asteroid transparent when they are far away and solidify as player gets closer.

On top of that, if the asteroid field is foggy, the sun has to look more gloomy, and lighting has to adjust along with it. It was truly a lot of work to do simple asteroids. But I finally achieved something that looks half decent:

https://www.youtube.com/watch?v=IbnHG7XO...e=youtu.be

You may occasionally see distant asteroids popping out, but usually it doesn't bother my eyes that much.

Actually the real challenge was how to render the asteroid field when the player is some distance away from it. I made a very stupid algorithm to line the asteroid "cells" (each cell is pre-loaded with randomly placed asteroid objects) along the edge of the field, increased the transparency threshold in the shader, and actually it didn't look too bad from a distance.
That looks really nice!
(09-21-2018, 06:11 PM)Rotorist Wrote: [ -> ]We are all pretty used to the way asteroids work in Freelancer and we took for granted how smooth they are!

I haven't realized what a challenge it is to make an asteroid field that spreads out long distances without stuffing GPU's memory with millions of objects. I had to figure out a way to dynamically place asteroids around the player as the player moves around in the field, and also to ease out the eye sore when asteroid pop out of nowhere, I had to write a shader that makes the asteroid transparent when they are far away and solidify as player gets closer.

On top of that, if the asteroid field is foggy, the sun has to look more gloomy, and lighting has to adjust along with it. It was truly a lot of work to do simple asteroids. But I finally achieved something that looks half decent:

https://www.youtube.com/watch?v=IbnHG7XO...e=youtu.be

You may occasionally see distant asteroids popping out, but usually it doesn't bother my eyes that much.

Actually the real challenge was how to render the asteroid field when the player is some distance away from it. I made a very stupid algorithm to line the asteroid "cells" (each cell is pre-loaded with randomly placed asteroid objects) along the edge of the field, increased the transparency threshold in the shader, and actually it didn't look too bad from a distance.


Great work. We could use some of your skills on the Discovery Dev team.
(09-21-2018, 08:42 PM)Riehl Wrote: [ -> ]We could use some of your skills on the Discovery Dev team.

Being good with C# doesn't mean those same skills will apply to working with ini files. To clarify, I'm just saying the skills aren't that comparable or transferable.
Looks great! You can also abuse of hardware instanced meshes if you want to beef up performance when using the same mesh a lot
That's a really smooth transition between nebula and open space.