Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Xarit's Logs on Unity Engine Game Programming  (Read 7698 times)

xaritscin

  • Bay Watcher
    • View Profile
Xarit's Logs on Unity Engine Game Programming
« on: December 22, 2018, 08:42:56 pm »

this is mostly a bit of a dumping thread for my records regarding prototypes in Unity. its not the first time i delve into game development of course, i used to have a little thread here for a 2D space simulator and many of the prototypes were promising to a degree but due to some issues with my original PC i have been unable to keep on that so i just got lazy and abandoned the programming side alltogether for some years already.

however, recent boredom and looking at some cool titles out there in the industry has revitalized my intent on developing something playable to show to the world. this is more or less the thread where i will be posting whatever i can produce with my current PC.

The Current Aim:

since this is mostly returning to the basic lvls i had in programming i dont expect to advance much honestly. despite that, i'd like to produce some prototypes that i could use as basis to make a larger simulation. i mean, trying to develop different things that i can later fuse to make into a single game once i figure out how every piece works. i considered different engines and libraries but in the end it seems that Unity is the most common tool for this and i already had some experience with it so i decided to stick to this one for the time being. im also going 3D this time, 2D was fun and i saw much progress with it but the current hope is to dominate certain 3D systems for future reference.

im gonna try to post whatever cool screenshots i can get from the prototypes then document some interesting finds regarding the development. for a start, this is a screencap of the first prototype "Galaxy Generation".



some info about this one: basically the idea is to generate a basic galaxy with enough detail to be able to land on planets or visit things like asteroid belts and gas clouds. im trying to go step by step on this as this is supposedly the first phase of "worldgen" for the game. so far the system uses a basic arrangement of 3 types of galaxies (Irregular, Elliptic and Spiral) along with asking for the "density" (how much stars compose the galaxy) then just produce everything after pressing the Generate button.

this took me the whole day to figure out because i had to relearn a lot of stuff and i had to check some info on the internet as reference while figuring out the code on my own (no copypasted code so far). right now im analyzing how to adapt the system to use particles instead of instancing prefabs, it should be less intensive for the machine but im currently discussing myself on the implications of using effects rather than ojects. moreso when taking in account that i have to make sure those stars are also something you can interact with in 1st/3rd person view.
« Last Edit: December 22, 2018, 08:53:42 pm by xaritscin »
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #1 on: December 23, 2018, 06:07:32 pm »

Log #1:

the main reason to replace the current generation method is because as it currently stands it generates several instances of the same object, this can be heavy for the machine even at its most basic numbers. changing to particles would have solvented this issue, i found some interesting tutorials flying around until i got to make a very crude particle generator. the problems i found with that system were the following:

1. Particles weren't spawning in the supposed position assigned to them from inside the script: the code is meant to give its respective Vector3 position to each particle before packing them up into the Particle System but apparently Unity doesnt understands that simple logic so they just end spawning all at the same point of origin unless you give a shape to the emitter (among other things that end up throwing more issues like particles drifting apart or forming completely different shapes while disregarding the positions they were given)

2. Particles arent objects and thus they cannot provide certain functions: from an effects standpoint they should get the job done, but we're talking about a Space Simulator so im not sure if its possible to use particles in order to represent the Stars, from a distance it makes sense but in the case of the player actually getting close to it or looking at the Solar System Map im not sure how would that work.

in short -> it seems particles only serve their purpose in terms of special effects, i need to find something else to replace those primitive objects.

What is currently being done:

seeing that the generator works so far im currently trying to flesh out the classes more further. there's several pages documenting ways to generate a Galaxy but there's still some things my brain cannot grasp like how to apply color based on the Stellar Temperature. Procedural Generation is something i've never done before so im currently trying to think on the main variables required. so for example Stars contain Temperature, Radius and Mass apart of an array that contains the known Stellar Classifications.

that data is mostly for reference but there may be an instance where im gonna need something from there, probably when i start messing around with planet orbits and the like. as for the Galaxy Class, i currently use Density, an array for the known basic types and added variables for the central and outer boundaries (it seems most galaxies are simulated by setting up an inner and outer radius then using that to show the arm lengths and the core density).

those variables apply mostly to Spiral Galaxies and i found interesting that most of the simulations end rendering something similar to the SPORE Galaxy (NOICE!). i may want to have something like that, but in addition, i was considering the possibility of having multiple Galaxies like in Shores of Hazeron. how the fuck im gonna be able to render that is subject to conjecture but perhaps the Particles will come handy for that in the future (something like while in Galaxy X all other Galaxies are rendered as particles and stuff, only the current galaxy has its systems rendered when needed).

so for now the highest possible outcome should be find a way to render only 1 of those with everything in place and perhaps moving around.
« Last Edit: December 23, 2018, 06:20:25 pm by xaritscin »
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #2 on: December 24, 2018, 08:16:50 pm »

Log #2:

in order to start looking for options regarding the star generation algorithm i decided to move the current methods from GalaxyManager to the Galaxy class directly. that ended being a bad idea because i required a class that inherited from Monobehavior in order to do certain actions. i had to recreate the stuff i had erased, leading to the creation of a new UniverseManager object with a Universe Class/Script. this Script in theory should be the one in charge of simulating the whole system so it contains the main generation algorithm, Galaxies and below elements would be abstract classes containing data that would be later used by the game systems.

at the same time i was designing this new hierarchy i tried to find ways to replace the Primitives and Particle systems for something more efficient. one option was rendering the meshes directly but i couldnt find a way to do it and most tutorials looked quite complicated to pull off. the second option was editor tied and consisted on the Gizmos class, the idea was to represent everything with the Gizmos.Draw method but for some reason the system was throwing errors saying that i was missing some kind of controlling class for it.

so in order to test the algorithm i just used the Debug window with a simple printing method:



so far the system just generates a random amount of galaxies, each one with a randomized number of star systems (with a minimum and maximum limit for the randomizer). a loop prints a log with the information of each galaxy including its distance from the player (assuming the player is sitting at the origin).

Issues Found:

-Unity seems to have a problem with referencing Arrays from other classes: the Debug Log was originally going to use the index name of the galaxy directly from its respective array, and was also going to provide information on which kind of class was that galaxy in specific. the system was throwing errors related to instances so i can only assume that either im supposed to directly provide the data to index on each iteration or the engine cannot reference the arrays i use to contain the Galactic and Stellar Classifications on their respective classes.

-Most of the graphical things requires me to extended or import from other classes i still dont know much about (Mesh Renderer for example), i still need to analyze how to actually represent everything on screen without using Primitives via Game Object.

What's Next:

keep delving into the generation algorithm directly and try to show as much information as possible. no need to think on orbits or rendering the celestials, just find a proper method to generate everything in the simulation datawise. best if i can implement a Seed system on top of it but random ranges so far have been usefull.

what i could do however is to create a method to compare the positions to ensure no Galaxy or Star occupy the same position in the map.

UPDATE:




i was just being fucking stupid, turns out i was just creating the Arrays but wasnt providing any data input into the system so yeah, the engine was trying to find the information needed to produce the log. this was corrected and i made some slight changes to the code. the Galactic part of the generation algorithm is more or less complete and now i have to figure out what to do with the Stars.
« Last Edit: December 24, 2018, 08:52:44 pm by xaritscin »
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #3 on: December 25, 2018, 10:07:43 pm »

Log #3:

the Star generation algorithm was looking promising at first but eventually it came to issues when trying to make a bidimensional array to contain the info. after wasting the whole morning writing the methods and putting a thread in the Unity Forums, it turned out that there was an issue from the very beginning of the method. Arrays werent flexible enough for the kind of things i was trying to achieve so i had to rewrite everything from the Galaxy generation method and down.

instead of using Arrays i swapped to List which are supposed to be way more flexible while doing more or less the same functions. it took me a while to figure out the functions i was looking for in order to achieve the same things i was getting with the Array system but it ended saving a lot of lines and headaches. Lists weren't the only things added to the code, i remembered how to use Constructors to a degree so i started swapping a lot of declarings that were done directly in the Universe script.

this is the current advancemente so far:



i had been able to write up to Planets. HOWEVER, since Planets were supposed to work with orbits and that stuff i had to write its own calculation in the positions method which is of course not representative of how distances are supposed to look so there's those huge magnitudes separating the planet from its parent star.

What's Next:

so far the system has been succesfull and is producing the 3 basic celestials that you can see in any space simulator, at least for debuffing purposes. but if i want to keep going with the rest  of the code i may need to jump into the rendering part again, one option could be to test with primitives and print a single galaxy with very few solar systems and some planets. but eventually im gonna have to find and probably build the required scripts to generate the objects directly instead of using prefabs which will probably be a nightmare to implement compared to what i have achieved so far.

i should also start looking into making a player object to start testing space movements but that wasnt really part of the plan, still there's only a few things needed to pull it out. the vectors and everything however will probably be way more complicated. so its kind of a floating idea, the main objective is to be able to show those celestials.
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #4 on: December 26, 2018, 07:31:37 pm »

Log #4:

i was initially going to look for ways to render the celestials but i didnt have much time to make a serious survey on documentation related to it so i ended just writing some lines of code for simulating them using game objects. this was the end result:



on each position check of each method the system creates a XModel game object which is equal to an instance of a primitive sphere. the object is then resized and recolored based on the class. the only exception to this rule is in the galaxy method, where we only generate a model of the GalacticCore (the big black sphere in the image). in reality the Galactic Core  should be just an oversized Black Hole but since there's no BlackHole/Wormhole class i have to make it an special case.

in order to achieve what is being shown i also had to do some slight changes to the distances system so now the stars are only a few LYs from the core, the colors of each stars are also quite bad but i havent been able to add coloration based on temperature. but its a start.

Current Issues:

1. GameObject Nomenclature: as you can se everything is shown as "Spere" or "Sphere(Clone)", i cant remember which tutorial i saw where you could apply certain properties to prefabs so it will take a while to figure how to implement those kind of specifications.

2. Scale and Field of View: the method that manages the size for gameobjects is complicated because at first glance it doesnt seems that the objects have any increase/decrease in scale, to make matters worse, the Camera doesnt go as far. i have to find documentation regarding the camera distances and that kind of stuff

What's Next:

as far as the code goes i think i cannot go further. i mean, before adding more code i should try and find proper documentation because there's a lot of stuff that i dont know how to manage, among those things are

-procedurals (the universe generation algorithm is still very plain, i need a trully procedural method for generating the universe)

-rendering (Game Objects are mostly fine for now and they will probable be usefull for local things near the player but its different for the larger things so i still have to find a substitute to represent those stars and galaxies in the Skybox)

-orbital calculations (this prototype is suposed to have newtonian physics or something like that)

-Camera Hacks (apparently one of the ways where Space Sims can fake the sense of scale is by managing different cameras or something like that)

-Unit System Calculations and Reference (the text shows units in AUs or LYs and is good to represent those kind of scales but in the grand scheme of things, Unity cannot cope with realistic sizes so i have to find a way to compress the universe to make it consistent with the units managed by the engine)

-player ship/avatar FOV and Controls (so i can start messing around with movement)

this should wrap the log for today, there will be a lot of stuff that i need to find and test so i dontk now how much its gonna take me before the next update. if any of you have some good links referring to what i listed above please dont hesitate to add a comment with them.
« Last Edit: December 26, 2018, 07:33:35 pm by xaritscin »
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #5 on: December 28, 2018, 07:16:48 pm »

Log #5:

the little day of rest allowed me to refresh the braincells for a while, but i was still keeping on looking for tutorials, guides, references and so on for the prototype. i decided to ditch the space vehicle part for now, but i left the script avaliable should i return to tinker with it. in the meantime i kept looking for how to improve the generation code. it seems the code is already pseudo-procedural (things dont go as random as one would expect due to certain ranges being applied). this has been the end result so far with the revisions:



-celestials now have a proper nomenclature (GLX for galaxy, STR for star systems, PLT for planets and so on...)
-no duplicates like in the past logs (albeit there's still a lot of delay at runtime due to the sheer amount of objects)
-scales are actually properly showing in the inspector
-stars are using actual color temperature calculations (they still look dull, but that's because its just a recolor over the material, no extra effects added)

i also started implementing the necessary code to form specific structures depending on the galaxy type. due to the complexity of cosmic calculations it seems using static positions for the Star Systems and the Galactic Core is the way to go. as long as the local Stars and system objects have dynamics going on it shouldnt be much of a turnoff , i mean, i dont really expect people to actualy measure the movement of the ingame galaxy seeing that it takes millions of years for them to rotate.

Current Issues:

1. star system distances fuck with the galactic structure: i tried fixing this by disabling the position refactoring, this means a lot of stars end being swallowed by the others due to spawning in the same positions but even then they are still appearing at extremely far distances and i cant grasp why. will probably have to ask in the forums because the positions given at runtime shouldnt be counting in the tenths of thousands.

2. elliptical galaxies dont generate properly: this is a sideffect of the issue No. 1, since stars spawn at ridiculously far distances from the galactic core the shape isnt equal to what it shows in the article which should be more or less a bunch of dots congregating at the center with spread distance at the edges of the circumference. if i cant get past this one i cant get to produce spiral galaxies either because first i need to setup the disc then do the arm changes and so on.

What's Next:

im getting really close to finishing the most important part of the generation algorithm, Planets just need to be enabled and perhaps receive a recolor but at its most basic state the thing works like i wanted it to be (with a few missing things). once if figure out how to make the geometry of these galaxies to work i could just focus on the inner system details like orbits, asteroid belts and moons. then it  would just be about improving the objects in terms of complexity like actually giving textures and proper meshing to the objects. swapping from these basic primitives to custom made Prefabs would take out a lot of callings inside the code but first i want to make sure the algorithm is actualy putting everything in its proper positions.

im done for today but gonna try and ask for a lead regarding the distance issues.
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #6 on: December 29, 2018, 11:20:45 pm »

Log #6:

i wasted the whole day trying to figure out how to fix the distance issues. in the forums i didnt get an answer until recently and it meant watching a video about how the devs for Kerbal Space Program fixed the floating point issue. in r/proceduralgeneration i got some answers about using things like Normal Distribution instead of uniform random numbers, Lloyd's Relaxation (which means also applying Voronoi Tesselation) and Poisson Distribution.

my knowledge of computer graphics and mathematics doesnt goes as far si i lost a lot of time trying to even grasp how to implement that in a method. so instead i went and tackled how things were being managed in the scene directly. as far as the code goes the objects were being spawned into the world without any kind of hierarchy, that seemed to have caused a lot of adjustments during generation as the world scale had to change to fit all the objects shown in the scene.

im not sure what was the floating point issue that was fucking up things in KSP but the solution is probably very complicated to fix so for the sake of keeping things on my lvl i just re-wrote some of the processes related to the galaxy generation. this was the result so far:



the hierarchy system fixes a lot of problems that i was having with generating everything on the same lvl. now whenever a Galaxy is generated the system creates it as an empty object, the Galactic Core was properly created now as its own entity (the Black Hole class which manages also regular Black Holes and Wormholes). the core is placed over its parent position while the rest of the generation follows its regular routine with a few changes added.

Current Issues:

1. Stars are overlapping: the generator works faster because im not iterating on the positions of these things but i have to find a way to spread their position so they dont overlap, this will probably mean adding the distribution algorithms. i like the idea of Voronoi but it seems really tricky to implement in C#.

2. StarGenerator is still very robust: this is because of the way i calculate the color and size of the stars, i was originally planning to leverage the amount of code lines in the Universe class by spreading some declarations into their respective relative classes. this worked for shortening the GalaxyGenerator but i havent been able to find a way to do the same with the stars because both Scale and Color are based on the Type of the star and the Temperature value of it. so there's 2 things i have to return from the method.

3. Planets not included: i have to apply the same things i did for Galaxies and Stars into the Planet class. its possible that im gonna suffer the same issues of length for the PlanetGenerator but these should be way more forgiving (albeit im not sure honestly).

What's Next:

now that the position issues have been fixed (for now) i can start focusing on fleshing out the shaping algorithm, but first i have to analyze how to implement the distribution methods to evade the stars from overlapping. the elliptical shape is already obtained allthought it doesnt look very convincing  yet, perhaps when the stars star to space out properly while aglomerating towards the center. there's also the deal with irregular galaxies which still use the typical randomized placements, this is supposedly fixed by using Poisson but again, i dont know shit about this so it will probably take me a few days more of study, trial and error.
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #7 on: December 30, 2018, 07:54:50 pm »

Log #7:



today's log is all about tinkering with the placement algorithm. the image above shows the results of hours trying to figure out how to create the galactic halo (the void between the galactic core and the surrounding systems). this isnt exactly what it should happen in reality i think, but i've been more inspired by SPORE recently, allthought i also keep my own view of trying to churn as much realism as i can. the SPORE galaxy is a good reference as its not too big in terms of scale and not too small (well, that's debatable actually). the galaxy created by Maxis was 41560+ systems in density, it dwarfs my 5000(max) star clusters but it was less diverse in terms of star types, according to the wikis the SPORE galaxy was composed fundamentally of O, G and M type stars (blue bright stars, sol-like and red dwarves) with a few other types making a special appearance as unique phenomena.

my globular cluster covers the most common classification and i actually managed to modify the code to store the Star creation method inside the class rather than doing everything in the Universe class. this same route should work for Planets later on as they too are objects with a lot of internal workings that would eat too much on the generation methods. so i have to spread them into their classes to fast things up. the galaxy generated is irregular but it follows a lot of calculations close to ellipticals, the potential range of distances for the stars are defined by the boundaries of the galactic halo and the density of the galaxy which means that no two galaxies will have the same diameter and that theres big distances to space the systems enough to evade overlapping.

the X and Z components of the star are then multiplied by trigonometric equations (Cos and Sin) with their respective angle to make them generate on a circle (this is the main component that forms the halo around the galactic core). the Y component is a bit of a wildcard as i have tried different functions to produce a more "blobby" shape for the stars, the one used in the image multiplies 1/2 of the distance offset with the result of a Normal Distribution (someone in r/worldgen posted me a link to an implementation of a galaxy generator from a popular article that just had the implementation of the Normal Distribution calculations so i shamelessly copied it for reference).

Known Issues:

-there's still some overlappings: but this one is caused by the scale of the objects rather than the distances, now that stars are actually using values like Radius, Mass, and the like things like blue stars are colliding with other stars in the vicinity, this is because the distances are still too short compared to what is normal (the distance from the Sun to the Milky Way's center is like 30K LYs). the problem is that galactic diameter is dependent on the galaxy's density so i have to find a way around it.

-Normal Distribution is counterproductive for some reason: yes it spreads everything so it looks like the core is more crouded and it looks really cool when all the components use it but i havent found a way to fuse that with the offsetting calculations to ensure that even if the stars congregate in the center they dont blob around the core

-planets still not included: i have to give the same treatment to planets but in order to do that i have to produce a good star generation method where the systems are at distances big enough to support planetary orbits without crossing with each other.

What's Next:

im gonna keep tinkering with what i have right now to see how can i shorten the methods. perhaps changing planet generation to its class and call it from the universe script. the thing is giving good results but it still doesnt have the shapes im looking for. there's actually a lot of things i could do for this like adding system to system boundaries or increasing the size, i was also considering looking for ways to replace the primitive spheres with a procedural shape but im not sure which one, let alone know if this saves extra computing power to go for higher density.
« Last Edit: December 31, 2018, 12:13:52 am by xaritscin »
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #8 on: January 01, 2019, 06:01:12 pm »

Log #8:

this log was skipped because honestly i didnt do much in the last day of 2K18. most of the 31 went up trying to figure up how to make the stars to glow in the scene, tried point lights and the shader from a tutorial but the implementations weren't working as intended so i scrapped it and just wrapped it for the day. i did however, advanced in reorganizing and distributing the generation methods, nowadays most of them just require instancing a new object in the universe script then use it to call the generation method with the naming convention added as parameter.

as for the first day of 2K19. i finally found a way to make the objects glow, the implementation im gonna do for the Galactic Mode/Map is very simple actually. Stars (and hopefully the Core later on) and everything else in the scene is taken as an static object, this allows me to make use of the "Emission" mode that goes on the standard materials, this basically makes the objects produce light themselves and it only requires a few lines of code to ensure the system checks the option at runtime.

it doesnt stops there, i also managed to figure out a StarSystem class which is now the one managing the positions given by the galaxies during worldgen. basically the class defines where will each system appear, how many stars compose the system (i can count from Binary to Quintuple configurations, with proper chance percentage based on some references i found somewhere), the Planetary and Asteroid counts were moved there including the Galactic Index. so this class is the base for making most of the orbitals now.

this required a lot of rearrangement of the current worldgen methodologies and i had to make a new method for star generation but the results are quite interesting, here's a preview of an elliptical galaxy generated with the new scripts:



it looks similar to past generations but if you look closely you can see each star system now has its own hierarchy inside. the total count of stars is also shown at the end of the algorithm to give an idea of how many stars are generated. speaking of stars, here's a preview of a Quadruple system



i think the most interesting part is that the algorithm already spaces out each star form the supposed center of the system. here's a configuration composed of 2 Ms, 1 K and i think a G-F class star. there's also another star from another system photobombing the image :P

Current Issues:

1. there's overlapping present: on each iteration of the code there's been collisions between stars, this has been reduced by changing the distance mechanics overtime and the implementation of Star Systems as their own class was supposed to help with spacing them up but there's still some instances where 2 stars spawn right on the same place of the stellar center, so there's still some things to fix.

2. Static means cero dynamics: when you set an object as Static it means that this object wont be able to move at all and is just part of the scenery. in the long run this means that i wont be able to animate the galactic mode and it will work like a static map. this may be beneficial anyways because not all space simulators have animated maps, HOWEVER!, this doesnt mean i cannot do some camera tricks to give the impresion that the galaxy is moving.

3. its stills looks very empty: this is mostly because of the depth field, and because there's not much stars generated atm, highest amount has been a bit over 9000 and this means those cases where the galactic density goes close or right on 5000 systems. perhaps in the future i will be able to generate bigger numbers. but its not just the amount of stars, there's no Nebulae or particles added into the scene yet (its already hard to load all these systems), im just starting to look into that.

4. no Spiral Galaxies: this is mostly because i've been focused on improving the system rather than adding more, will have to check on the references to see if i can implement the required code (shouldnt be hard if ellipticals can be generated now)

What's Next:

as mentioned above, Spiral Galaxies should be the way to go soon. Ellipticals and Irregular have more or less the shape they are supposed to have so i need to move on onto something else. in addition to this there's the thing related to representing the systems at runtime. we dont have any kind of interaction, seeing that this is more or less the "map" it should have some kind of way to look around, perhaps add a sort of zooming system, and selector.

that last part opens another pandora's box which is loading different scenes. the Galaxy is more or less generated and everything looks dandy. but what about planets? if the current scene consists on selecting a system then i have to find a way to implement one that shows the current solar system, planets, satellites and asteroids included. this is a new feat of strength i have to deal with. and it gets bigger because:

1. i dont have a player in the scene yet
2. i dont know how to save data as in saving files, using seeds, etc...

im gonna see what comes up as 2K19 goes on.
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #9 on: January 02, 2019, 09:26:31 pm »

Log #9:

spiral galaxies are a cancer to setup but i finally was able to understand which parameters required modifications in the example tutorial i found in the internet. here's the result:



at first glance the code given in the site looks easy to put in the script but Unity has a different way to move things so it required adding extra things to the code in order to make it work with my game object system. this took the whole day to figure out so there's not much advancement for anything else but it paid out because i can now focus on improving performance before adding the nebulae. well there's was also a bit of reworking the Y component for these and ellipticals to make it more consistent.

Current Issues:

-larger density means larger swirls: realism breaks for galaxies with more than 10K systems, this is because the rotation is dependent on the distance so when the density gets larger the swirls are longer too so it stars to look less like a Grand Design and more like a Polywag's belly.

-lots of hard divisions: the main problem of this system is that i have to put direct values to divide the offset and the rotation, otherwise the system looks like a mess, i will have to find a way to dinamically change the offset and rotation divisors in order to ensure i can cover larger sizes or something.

What's Next:

now that i have more or less finished the base of the generation algorithm i can focus on optimizing the meshes. it seems Octahedral Spheres are a good option for this, and they dont really seem much hard to implement but yeah, time will tell.

the main reason to choose those is that apparently they behave in a sort of middle ground between detail and performance with much more balance compared to Quadspheres or Icospheres. so im going to give it a try and see what happens. besides, Octahedrons may serve well for zonification later on compared to the other meshes.
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #10 on: January 03, 2019, 08:31:25 pm »

Log #10:



this day has been more bountifull in terms of features. first of all i was able to procedurally generate meshes for the scene using a Geometry Class which should be capable of producing from simple Planes to Octospheres (Octahedron Spheres). in the case of Galaxy Mode this means Octospheres with triple subdivisions, round enough to look decent in the world map while still having less polycount than the old Primitive Spheres.

in addition to this i was able to implement a camera control script so now you can Pan, Zoom and Rotate around the galaxy, i was also able to implement a very important feature related to gameplay which is a System Selector. now whenever you double click on any star you can get a reference of the system this star is attached to, in terms of gameplay this should count as the basis for changing from Galaxy Mode to Star Mode. here's a screen of the system in action (with some master lvl MS Paint editing):



Current Issues:

1. no LOD: procedural meshes and geometries are a recent addition but a LOD system has to be implemented eventually, i just need to figure out how to make that work with the camera or the like.

2. Camera Controls are weird: its mostly the relation between Rotation and Panning. no Rotation would be good for a "Cartographic View" of the whole galaxy but due to the Z plane being included inthe generation the players need a way to rotate the camera to see certain systems. i basically need to rewrite the whole script (probaly look for tutorials on RTS view)

3. Selector doesnt properly focus the view: i added the first Singletons in the whole prototype to be able to locate things like the Star System list or the GalacticCamera coordinates but havent been able to properly match the camera position to the currently selected Star System. in addition, there's no way to highlight them because the Star System is a game object of its own, would have to be able to get the child stars and find a way to make them glow or something, which means another set of complications relating to check when the system isnt selected and when it is.

What's Next:

i'll probably end tinkering with the afforementioned issues to ensure this thing work properly, it is a necessity that this first part works fine because im gonna need reference to certain things in order to be able to open the Star System Mode. the most important thing is finding a way to show each system in the screen, perhaps some kind of UI that links the system to a popup with the important details, i'll have to look into drawing elements into the screen directly or something (you know like putting a square or circle around the object to show its selected).
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #11 on: January 04, 2019, 11:20:44 pm »

Log #11:



i was supposed to do changes to the previously mentioned issues in the simulator but i got some IRL stuff in the way. also, i found it hard to implement Nebulae in the scene, the particle system approach doesnt work for this kind of thing apparently and i dont know how to make volumetric clouds directly so it seems i'll have to reduce some visuals, or at least represent these phenomena with different methods on the background.

that got me thinking, the galaxy already loads like its supposed to and most of the celestials are intended to be used on their supposed scale so instead i have decided to make Galaxy Mode into a sort of map interface. the image above shows the galaxy with its respective number of systems but each one is loaded as a node you can click on to select. if you have played other space games you may get the idea (EVE, SPAZ, Evochron?). all the nodes would be connected into a sort of webway for cosmographical purposes just to make them look like they are charted.

i would have liked a more seamless approach but those kind of things are for people with better understanding of programming so instead im going to have players moving around "rooms". the Galaxy Map is the main interface from which you select a system as destination (allthought i'd like a much more interesting way of doing it). the general idea is that the ship will initialize the warpdrive briefly before jumping into the selected system (kinda like when you move to another system in Starbound or open the Jumpdrive in X3).

Current Issues:

-not visual enough: this is the barebones version of the galactic map so you can understand why it looks so empty in some parts, its supposed to show only the galaxy and its connected systems so there's not much visual details added to it, the most minimalistic the better. still there's parts where i have to find a nice balance, for example, the color coding for the systems. i already added some sort of color code for them based on how many stars they have but the chosen colors look awful in general compared to plain white, i need better colorations.

-no connections yet: i tried using a line renderer to show the connections between these systems but i found out several issues with that, it seems im gonna have to look for a procedural algorithm that helps me with that as using regular queries with the System List didnt work.

-Galactic Core is absent: this is some of a personal thing, im divided into whether black holes should be considered locations you can visit or not. if they are then that means adding the core as another system in the webway so players can visit. it could work as a source for connection tho.

-no info on selected system: as i was busy with other stuff i couldnt put my hands into working for the selection indicator, but i more or less have a lead on how it has to be done, just need to find a texture and so on.

-UI?: there has to be one eventually, best way to visualize this system should be having a menur in the lower bar and have some kind of popup opening when selecting a system which shows the basic information on the thing. then have the button to jump added into it.

What's Next:

there's a lot i have to look after for this. the best part is that everything is in place so just have to focus on those details, the galaxy on itself is working as intended. the only downside is that i havent touched planets, or asteroid belts, or moons but that can be implemented later by just fleshing their classes and their generation scripts. orbits are far too since im not goingto show movements in the map, its a thing for the stellar environment of each system.
« Last Edit: January 04, 2019, 11:28:24 pm by xaritscin »
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #12 on: February 24, 2019, 10:52:56 pm »

PTW, eventually I'll go read through this whole thing, it seems really interesting, keep up the hard work!
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #13 on: October 06, 2019, 04:57:51 pm »

bit of a necro but wanted to notify that i didnt abandon the project, just got into a roadblock and focused on other stuff in the meantime. story:

at the time the Galaxy Map generator was practically done at its main lvl. the system was able to print a galaxy of the desired shape along with an assorted list of systems with their respective celestials created at a semi-random order. trying to connect the systems into a grid proved unsuccessfull and processing heavy as it was already managing a lot of objects at the same time so instead i decided to go onto another route and just show the solar systems as "dots" that you could click around (think SPORE map), that just required changing the amount of divisions of the octahedron sphere and so to make the model consume less processing power.

after that was done i decided to move into a prototype for the solar system mode inside the same project, so i settled up a new scene for that and started messing around with models. the Octahedron Sphere method was good for simple representation and i was planning to use it to generate a test planet (spent a lot of time in Photoshop trying to make a believable texture and then make the normals and UVs). however, it turned out wrapping the planet texture to the model left a lot to say so i went to look for alternatives to it, this was also a need due to some of the concepts related to planet generation that i had to tackle at the same time (tectonics, procedural terrain, zone delimitations, etc..)

Octahedrons were good for moments when you didnt need to enforce detail and thus would be used easily for the galaxy map but at the solar system/planet level it was horrible at the seams and poles. one particular guide/set of articles showed the process of producing an Hexagon grid out of an Icosphere. the code or methods required to make the Icosphere were easily found and understood but the code went to the dumpster once it came the part of generating a new mesh grid of hexagons from that model. either because i had misunderstood the theory explained in the articles or because i was missing something in the mesh generation algorithm.

Spoiler (click to show/hide)

i spent several days tackling that issue until i finally snapped out of it and decided to focus on other prototypes or some RL stuff. right now the system just generates an Icosphere but outside of that there's not much after it. one of the other projects i decided to move around in Unity these last months was a 2D Block game i had flying on my sketches for some years already. i showed some of the progress in the forums recently but there has been a stop too due to lack of knowledge. the code is very basic but it works really fine for the most part, with the system being able to make a player character with its base testing sprite which can move around (including jumping), the world generation algorithm gets to divide the map blocks in chunks and use them to draw everything in an orderly manner but i have found at the last time that using several Game Objects on screen is a bad move that makes the machine go heavy at the start before working. im not sure if Terraria or Starbound has to deal with the same shit so the last time i touched the code for this 2D prototype was trying to find how to make Chunks as Meshes in the engine rather than separate copies of the same sprite.

Spoiler (click to show/hide)

i hope it wont take much time before i get a glimpse of inspiration and find a way around solving the issues of any of these projects in order to move on. but for now im gonna delve into getting into my roots and see what i can get out with Java now that i found a nice tutorial about making Roguelikes which has taken my attention lately thanks to different titles here in the forums like URR or Cogmind and of course, DF.

see you the next time i get something done, i guess.
Logged

xaritscin

  • Bay Watcher
    • View Profile
Re: Xarit's Logs on Unity Engine Game Programming
« Reply #14 on: September 19, 2021, 06:00:17 pm »

Rising this thread out of the grave because i have returned to do prototyping (or at least trying to set up some time for it apart of Work days and the weekend). i stopped working on 2D stuff and decided to refocus on 3D Space Simulation stuff. mostly inspired by checking videos from recent space games and brainstorming ideas for EVE updates and gameplay changes. There's a lot more better youtube tutorials and other sources to get started with this so i've been staying out of any galaxy generation algorithm for now and focusing solely on the most basic part of the prototype which is being able to move a ship around system and on planets with realistic physics (The old Galaxy Generator was in my main PC which i cannot access atm so had to start all over again on this other PC).

Spoiler (click to show/hide)

Stuff working so far:

-A static star made out of shaders
-A Starfield background based out of shaders
-A testing ship object with X series style controls (WASD for strafe, QR for rolling, arrows for steering and ZX for main thrust control)
-A testing planetoid for landing mechanics

Current Issues:

-No Orbital mechanics yet (im checking on Sebastian Lague videos on star system prototypes and other sources but need to see how to generate stable orbits instead of adding inputs)
-Ship acceleration is very clunky (the ship accelerates very slowly, may not even be trully newtonian style flight mechanics, need to check the movement calculations)
-Planetoid is dark on all sides when it should be being baked in the light proyected by the star object

Im gonna tackle the ship movement script first seeing that its the less problematic. the other's im currently asking around on Reddit to see if can get some insight on what's happening rendering wise. i had to add a Global Volume to the scene in order to show the star brightness and coronal emissions but im not sure if that should be darkening the other objects.

Logged
Pages: [1] 2