DEVLOG 1
Introduction
This is the first public showcase of the project. It started as a proof-of-concept to explore the feasibility of creating a Space 4X using Contruct 3. With the aim of pushing the boundaries of this engine and take advantage of the streamlined eventing system and ease of use to creating the game logic.
As I started the first tests, the results showed promise right away, as I was able to get pretty good results very quickly, with much better visual quality than I was initially anticipating.
The engine also seems to allow much a higher triangle count for 3D objects than I was expecting, which is great plus for graphical fidelity.
Overview
Everything you see in the video is generated during runtime. In this version I implemented a procedurally generated Galaxy, Star systems with Stars and Planets.
- How the Galaxy Generation works
• I start by creating a galaxy Sprite object that contains some basic variables for the galaxy creation
• Next a Galaxy Map array is created that serves to plan out where the star systems will be created on the layout. Each cell will be assigned a value to determine whether that location can spawn a star system or not.
Cells with the value "0" are valid spots to spawn star systems; cells with the value "2" are invalid and can't spawn star systems; and cells with the value "1" are cells that have been chosen to spawn star systems.
• I make a first pass that turns all cells into 0, then I make a second pass where every other cell is set to 2. This makes sure that the star systems won't be spawned perfectly aligned.
• Next I will do a Second pass which will determine the shape of the galaxy. For this I start by creating a Drawing Canvas which will be used to check a heightmap.
• I create a Sprite object with the Heightmap, this is a sprite that contains a black&white image of a galaxy shape like so:
• I paste this sprite into the Drawing Canvas and take a snapshot, in order to evaluate each pixel color of the image.
• I run a for loop for the positions corresponding to each of the cells of the Galaxy Map Array on the Drawing Canvas, and compare the Red value on each position. If the red value is low (for example <20), that cell is invalid to create a star system. This makes sure that no star systems will be created in the dark areas of the heightmap, and lots will be created on the light areas.
• Finally I run a for loop for each of the Galaxy Map Array cells and spawn star systems on a random amount of cells with the value 0. (I have some parameters that make this more controlled, such as a density variable that is also affected by the brightness of the heightmap)
The great side of this system is that it allows me to easily create pretty much any shape of galaxy I want by making a quick doodle on photoshop. The way I have it set up, is each galaxy type is a different animation of the sprite object, and I can easily determine which type of galaxy shape I want by simply changing the animation before pasting it into the drawing canvas. Pretty cool!
Then as soon as a star system is created, it automatically populates it with a star and planets. Currently there isn't much into it, but on a future version I will create arrays that house all of the star systems, planets etc, including info related to each one, in order to easily track them.
Problems Encountered
1. As expected, before doing any optimization, I encountered problems with frame rate, which were being caused by there being so many 3DObjects on scene. I solved this issue rather easily, by simply making any 3DObjects that are far away, invisible. Considering the nature of this game, where each star system is very far away from each other, this works extremely well, as usually no more than 2 or 3 stars are close to the camera at one given point. So, as soon as they're a bit farther away, it's completely unnoticeable, as I can turn them off and simply display the white aura around them. The images used for the Star System ring graphic and star glow are also pretty big, so I introduced different LODs (Levels of Detail), having lower resolution images be displayed for farther away objects.
This worked like a charm and put the frame rate at top performance.
You may notice on the video that frame rate drops sometimes, this is because I haven't implemented this into the planets yet, as they were a last-minute addition, but once I do add some optimization, it should be back at max frame rate.
2. A pretty bad problem that I did come across however, is that the Drawing Canvas paste object function doesn't always work unfortunately. It's very finicky, and I had to go through a lot of different experiments to get it to work consistently, as it would just decide to not work every now and then, sometimes it would simply not work. The only way I could get it to work was if I called the generation function from the "Start of Layout" condition. Otherwise it would not paste the image. (Yes the function is asynchronous and I have "Wait for previous action" after this action).
I ended up brute-forcing it in order to getting it to work consistently. Which would consist in destroying the existing heightmap object, creating a new one and paste that one. It repeats until it works basically. This seems to be a problem of the Drawing Canvas Object, that should be addressed Ashley
3. Effects very touchy with 3D shapes / 3D objects. They look great and and achieve amazing results, but there's an issue where the object gets sliced at the top or bottom with certain camera angles. Often the more the camera angle is closer to the 0-Z value, the worse it gets. The object I have that uses the most effects and requires those effects is the Star Object, somehow I was able to find just about the perfect values to make not show this issue I'm mentioning, the main solution being placing the the Star object in a layer that has a Z elevation of 1. Yeah lol.
However, with other objects, I seem to not be able to circumvent this, and am often forced to give up adding an effect, and finding a different way to achieve the look I wanted. I would be great if this could be solved, although I don't know if it's a fault of Construct 3 or the 3DObject plugin. I found that this only happens if the effect is on the object itself instead of the layer, but it often is the only way where the results are worth it to keep the effect.
4. Working around the drawing priority (where 3D objects disappear behind of semitransparent pixels) will be admittedly a pain in the ass. But I hope that that with a lot of tests I'll get there.
Graphical Enhancements
I worked a fair bit on the look of the stars, but still need to do a lot with them, such as improving the texture and mesh. I'm also going to create different LODs for each of the 3DObjects, to further improve performance.
Overall it works for now.
Conclusion
If you managed to read through all of this, you're insane. But I hope it was informative, and not too boring.
This is probably the longest Devlog I will ever write, as I wanted to cover the main topics of what I did with this project. There's a lot of stuff that I didn't cover.
If there's anything you saw in the video that you're particularly curious about, feel free to ask.
Overall it's been a lot of fun working on this project, sometimes I get stuck with something for a couple days, but overall I've been able to overcome it one way or another.
Feels like I'm pushing boundaries, and making the most out of this Engine, which is a great feeling.
I'm looking forward to see where I'm able to get the graphical quality here.
Video of this version:
Future Features to Implement
- Generate background stars and nebula, including a skybox
- Create arrays that track planets and star systems (and assist on their creation)
- Different types of planets
- Create a Twin Star system when 2 star systems overlap
- More Optimization