Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Games [WIP] EcoPico V0.0.23- Prototype (DOTS) - Making Creature

Discussion in 'Works In Progress - Archive' started by Antypodish, Nov 7, 2019.

  1. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Here I would like drop some light, on one of my experimental project, while playing with Unity 2020 and DOTS.

    At current state there is no fun factor as of yet. Mainly working on stable mechanics. The goal is, to control evolution of life instances, by directing "genes mutations".

    V0.0.21 (Hexsphere planet intergration)




    Link in case, video pn the forum is not accessible
    https://forum.unity.com/attachments/upload_2020-10-29_22-6-23-png.726434/




    Earlier V0.0.7 (Testing hex planet and lifeforms)

    upload_2020-10-25_17-47-52.png

    Earlier < V0.0.7 (Lifeforms testing)




    Earlier V0.0.3



    When more is to be presented, I will post an update.

    The birth of this project was derived, from my main project, which I was working earlier
    [WIP] Hovercrafts Sandbox Prototype
    However, since Unity DOTS evolves quite rapidly and I still learn it and most optimal pattern to work with, I decided to work on something, which I can experiment. Also, developing features and utilities, which I can use later in my main project.

    Even this small project, it is quite demanding, while looking for best approaches.
     
    Last edited: Oct 29, 2020
    Ruchir, ADNCG, jdtec and 2 others like this.
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    I had posted for initial feedback few weeks back.
    Feedback Friday #83 - October 11-14, 2019
    Feedback Friday #84 - October 18-21, 2019

    Quite a bit has changed since then.

    But this time creating this thread.

    Among multiple challanges, I wanted to figure out, best approach for rendering meshes and shaders, with parameters, while using DOTS. I have had created following discussion for that purpose, which allowed me to resolve major issue.
    How to correctly set up Shader Graph for MaterialPropertyBlock?
    That not to say, rendering is done. I want to step up a bit further at some point. But I got massive improvement already.

    If anyone is interested, I have also other older vids from this project
    V2



    V1



    V0

     
    Last edited: Oct 25, 2020
    warthos3399 and SparrowGS like this.
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Cool, I love this sort of stuff.

    I've been contemplating some kind of eco system sim to do after my current project, been wanting to do one of these for a while now, how does the gene mutation work?, a modification to the health/speed/whatever stat each generation?

    I've thought of a system where creatures have some kind of intellect level that they can increase by doing stuff like interacting with the environment and discovering things and the higher intellect level allows them access to more advanced actions in a GOAP type system, this also goes well with a social system where creatures can create tribes/packs and learn from each other, passing on knowledge and so on. (and you still have like a lone predator teaching the baby how to hunt thus raising him to his intellect level and let him continue accumulate)
     
    Antypodish likes this.
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    I was going back and forwards with eco games for years. Been building some simple simulations, with different tools over past years. But just now, with DOTS, it struck me, this may be actual something interesting and possible to build.

    I have played multiple prototypes of different peoples, so I see how they approached such problems, I will be facing. None however I have seen, had placed whole thing on a sphere.



    For now gene mutation is rather simplistic. I didn't went for sexual reproduction, but rather asexual. Just like cell divide. Weather I will go for sexual reproduction, by mixing DNA, I am not sure yet. Definitely mutation would then be, within group of similar specie.

    However, now mutation is done on randomization of each gene. Game can mutate each individual gene by increasing or decreasing properties. Or order to not mutate. By default direction of mutation and the factor is random within a permitted range. Each new offspring is mutating.

    I want player, to be able have certain degree of control, on mutation of selected group. Then allow evolve

    I was thinking recently, to add at some point brain and neural networks, for intelligent species. Then they will learn by evolving. But that may be still ahead I got algorithm for NN anyway, which I was working before and can teach at runtime by players. I don't use Unity tool, which is python bonded. However, first, I would go with simplified mechanics, using Utility AI as per discussion in attached thread.


    How I will approach this problem not sure yet. I got tons of idea, but I focus only on immediate steps, to not go astray with, too far :)

    Social behaviours would something cool. Like flocking etc. If I use boids algorithms and NN brains, I think that pretty feasible.

    Another thought, but rather difficult at this moment, is to make plants being able to grow, something like trees. But I may just stay with simplification, of height. If I could come up with better DNA structure, I could mutate anything with anything.

    Also, I may actually voxelise species. For example, instead base structure of creature / plant to be a mesh, to be blocks. Then I could create some interesting formations. Tree could for example loose branch, or gain a branch in next generation mutation. Animals could have more / less motor mussels, allowing movements. All in simplified form of course. Maybe I will make kind of each voxel as relevant functional cell. But again, I would need have redefine DNA concept. For now, I am not marching in this field. But is heavily in my mind.

    At current, herbivores can technically be also plants and vice versa, if they got relevant genes, to generate food from the sun. Plants produce food faster, but metabolism is generally slower. That however can be enhanced by relevant mutations. In fact, sun position affects photosynthesis. In night there is none. Movement will cost energy. Is not yet implements.

    Greater challenge is, how to make sure that plants / animals hybrid are not too OP :)
    I need figure out some sensible penalties system. Photosynthesis is good step toward direction.

    Another though is, since I don't consider using shadows as factor for reduced photosynthesis, how to give benefit for plants, to grow higher. I could take just higher plant, then it become more efficient. That kind of sort I got now. Then kind of grass, which is low and flat, but wide. How can it get good benefits.

    These all are thoughts of course. Some may just stay as thoughts.



    On side note, planets on vids are between 15 to 25 radius. I hope with DOTS, to allow make them bigger, to be able populate planets. If species can evolve bigger, then could expect have pretty big creatures / plants there.


    On side note 2, by default, I am not allowing for cannibalism. :) Saying that, if DNA difference is close enough to the threshold, then life form is treated as same species. But I plan also add this factor to DNA pool. Is just not linked yet.


    Edit:
    I think I have figured out, how I could make cellular/voxelized based DNA :p
    I will grab some concepts from my Hovercraft projects.
     
    Last edited: Nov 7, 2019
    bb8_1 and SparrowGS like this.
  5. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,692
    Nice bro, love the concept :)
     
    Antypodish likes this.
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    This time little show case, of life instances, where cells now hold specific functions.
    For example green are leafs, generate energy from sun, via photosynthesis; Red are herbivores, which eat plants, of other life form; and blue, none functional yet, mussle, which should permit to move.

    While cells are randomly generated, structure of 12 cells is atm predefined for testing.

    I will add more types of cell of course. Also, I want certain types of cells, to best function at certain location in the life form. So for example green leafs should be most optimal on top and then sides. But not inside of life form.
    Movement mussle should be best near the ground (at the bottom). Sight cells similar as leafs cells. And got few more in plan :)

    I play this on small planet for now.



    This wasn't really planed to implement yet, but was drilling my mind so deeply, I decided to implement it. I had to add and test few new systems, to support such mechanics. I managed to break couple things. For example highlight, since I changed, how cells are rendered. At current each cell is rendered by same material, with shader parameter, to change color. I may add at some point texture options. But I improved by chance other stuff. In general I am happy how it work so far :)

    One thing current changes have affected, is stable evolution, so I need rebalance things, to playable state. No big deal, by every little adds up.
     
    Last edited: Nov 11, 2019
    ShiftedClock and warthos3399 like this.
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Update for version 0.0.6.

    I wanted this update earlier, but I was away for few days.

    Either way, much work has been done, to streamline evolution and mutation process. A bit of tinkering was involved, to find optimal solution. I refactored some of code, which allowed me to break things. But fixed now. (I think) :)
    Probably many iterations there will be ahead, but at least I am much more happy about how it is.
    There are certain things, which I still want to resolve.

    I this iteration, I allowed my new life forms to evolve, by generating new cells. Each cell type (color) has special abilities. Green is to convert sun energy to food. Red allow movement, which can be seen later in vid below. Purple is like stomach, which allow store more food. Etc.

    As I already indicated, green plant cells, will be penalized, when light will be obstructed by other cell. Then that will allow, to mutate existing cells, to different cell. Or grow new cells around existing life form. Growing of new cells is permitted in any direction, other than below the ground. I am not considering making roots, like plants.

    One of challenge with evolution and mutation, I want preserve energy conversion of the world. Meaning, I don't want extra energy be added, or removed by accident to the world. I have described briefly in some previous post, that atmosphere affects how many plant creatures can exists. Performance can be improved with mutating photosynthesis, to allow get more of energy from atmosphere. But amount of available energy to spent is limited.

    Then death of course returns energy to ecosystem. Other creatures like herbivores and in future carnivores, will act as energy conversion, by eating plants for example, and storing in themselves. Until they die of course, or getting eaten, moving energy to different form.



    As I work with DOTS, I would like put as much code on burst as is feasible. Birth of new offspring requires much of optimization. Also I have some systems, which I temporary disabled burst, for testing purposes. Also, I am trying work around determinism, so using this project as testing ground.

    Some shader modifications was done as well using Shader Graph, to life form status, to contain few more information. For example, how much energy is required to next growth of life form. Or how much energy is required, to allow new offspring.

    With current shader, I don't know yet, how to add shadows. They don't work :(
    Is not that critical, but could be nice to have.

    Obviously, shader status need be higher, as is clipped by the planet surface, which hides info. Also, first cell need be also higher, as it is too low in ground.

    There are other issue along the line, which I want to resolve, but will come in time.
     
    Last edited: Nov 22, 2019
    SparrowGS and warthos3399 like this.
  8. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Ops, it become a bit messy :p
    Result of changing few mechanics.

    upload_2019-11-26_8-8-56.png

    In meantime, I decided to spend a bit time on bugs hunting, ensuring game is stable.
    Also I changed couple things behind the scene, which appears behaves much better. At least cleaned up some code.

    I have fixed highlighting systems, so that should work in some next video.
     
    Last edited: Dec 20, 2019
  9. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Fighting with one irritating bug.
    Unable hunt down the reason, why after approx 5 min of runtime, I got one entity become position NaN. I need to catch the moment of such occurrence.
    I keep searching.
     
    warthos3399 likes this.
  10. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,692
    Nice work bro, you got this...:)
     
    Antypodish likes this.
  11. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Previously had issue with AABB throwing error, due to entity position was NaN. I did couple changes, including Unity restart. Positive side is, game was left for 45 min, with no crash so far.
    But I found that ECS seems does not like interaction in editor UI elements at the same time. When selecting Unity editor option at runtime, it pauses the game. And DOTS threads are still running at the same time. So I suspect that is the issue.

    That push me for quicker implementation, of rendering selection options, as I couldn't control reliably this option setting from Unity Editor. Now option allow to choose rendering meshes FactionMarker, Cells, Any, None.

    Colors of faction show, how life instances invade space of each faction.
    I am still thinking on best approach, to render only selective faction.

    I have also slowed down movement of entities, with herbivore component. This is more alike I want, with freshly mutated movement gene. Later I will allow to move faster, if mutation will take in place accordingly.

    Of course, clipping through planet is still present. Haven't touched that problem yet.

     
    warthos3399 likes this.
  12. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,692
    Clipping through the planet is a prob, but the ONLY one i see. The render only selective faction should solve a few probs.
     
  13. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    There is few clippings through planet. Depending on location. Is because sphere is not ideal sphere, it has flat surfaces up close. I probably would need increase number of sphere polygons. Then increase altitude by a little of faction icons.

    I won't be touching for a while the overlapping of factions icons. I got some ideas, but I leave it, for better time :)

    I just look at frame rate, it should be higher. I have switched off/on somewhere, with recent changes. Also, on recent vids, I run accelerated simulation, so I can stress test and easier look for bottle necks.
     
    warthos3399 likes this.
  14. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Little update more just for fun :)



    Let them be and they will take most of the planet. Effect of growing and expanding nearly 7k life forms. It looks like suburb town was resounded by large skyscrapers.

    Edit:
    Additionally few bugs squished in highlight system.
     
    Last edited: Nov 29, 2019
  15. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Well, implemented light shading.

    upload_2019-11-29_11-31-51.png

    Is not perfect, since for now planet does not block light, but generally works with sun position. However, now life forms can be easier recognized, what is where. Before meshes without light shading were kind of merging visually.

    The thing is, since I use DOTS with Shader Graph, and Universal Rendering Pipeline and Unlit Master node, I had to implement own lighting effect, considering light position.

    Camera at lower altitude, below atmosphere.

    upload_2019-11-29_11-37-56.png

    And when is a bit darker.

    upload_2019-11-29_11-39-56.png

    The obvious immediate issue now is, is too crowded :)
    That not planned effect. I will need tackle it.

    Another issue having, is highlighting during the night. Atm. is dark / bright as other meshes.

    Past time, I also reworked a bit genes, hoping to be more friendly later, to work with.

    Edit:
    Improved overcrowding matter.

    upload_2019-11-30_4-16-56.png

    Is not ideal and will require further work, but is much better. Recent changes reduces probability of overlapping new life forms when they are born. It still may happen, but mainly because of multi threaded jobs. If the issue become critical, I will work further on that.
     
    Last edited: Dec 20, 2019
    warthos3399 likes this.
  16. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,692
    How will you deal with the "crowded effect"? Also is light a big factor?
     
  17. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Every new born life form, checks for available space to grow. If is occupied, meaning, if is too close to existing life form, then that offspring is discarded. To deal with existing occurrences of two offsprings in same space, I will need execute new offspring system single threaded, rather than currently multi threaded.

    Currently, I could just add single line of code, to trigger it. But for now, I keep as it is, until I will make sure I am happy with performance of that particular system. So far I am :)

    There may be something I don't know, or don't understand with DOTS and custom rendering mechanics.
    But as far I am concerned, to allow changing shader properties, like color of blocks on each life form, or energy, food etc status bar of each life form, I need use Unity Graphics API. Additionally with that, I have been advised so far, that with Sader Graph, only Unlit Master node work, not PBR Master note. That means, I need manually handle any shading effects, which normally we take for granted, when dropping light source into the scene and few cubes. All shading and shadows are taken care for us.

    But shadows are least of concerns for me atm.
     
  18. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Growing my new hair.

    upload_2019-12-17_0-39-39.png

    • General a bit of work, for moving life forms and some testing.
    • Movement requires now muscle cell within an organizm.
    • Few additions and fixes to UI, allowing display summary of genes.
    • But discovered another bug in meantime, should be rather quick fix.

    upload_2019-12-17_0-45-2.png

    However, past few days I was mainly focused on my older side project:
    [WIP][DOTS] Octree (U2020.1a - Entities 0.2).
    Which was old as 2018.3.

    Now will be about time, start focusing toward fun factor.
    I suspect, this may be a bit challenging, for such type of game.
    Got some few thoughts about direction, and unless I wont be able to decide, I may make few options, as game modes. Or some sorts like that.
    Plus eventually kind of sorting data that is displayed in UI.

    I would like of course add more genes and cells in future.
    But still improving current mechanics, keeping resealable balance.

    Ah, and still chloroplast cells need receive their handicap. Too superior atm:)
     
  19. Darrkbeast

    Darrkbeast

    Joined:
    Mar 26, 2013
    Posts:
    125
    Very interesting project, I need to start messing around with DOTS. I have always been interested in making a project like this mixed with rts elements. In any case keep up the great work, looking awesome.
     
    Antypodish likes this.
  20. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Thx for kind words.
    To be honest, I don't know what genere that project would fall in:)
    I suppose it could be RTS, if I put enough strategy elements into it.

    I think is really worth it in long run. It will be requiring quite a bit of time, to spend learning it. But once it is past, rest comes much easier. The only downside yet, DOTS still evolving, so is prone to changes. Maybe Visual DOTS could soon accelerate this process.
     
  21. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    @Antypodish some real intereseting stuff here. Any chance you have the source on github?
     
    Antypodish likes this.
  22. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    @iamthwee thx.
    Sorry, no planning on source code to share at current time.
     
    iamthwee likes this.
  23. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Fair enough, but a lot of people are getting started with DOTS myself included, it would be useful to see how you're going about it, because you seem to have a good grasp of it.
     
  24. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    @iamthwee as it is DOTS itself, I use many experimental features. I don't always know, which approach is best, or most optimal for given problem. So I try different things. I wouldn't call it most exemplary code, worth strictly studying. Potentially introducing unnecessary confusion, for someone who is learning DOTS.

    Lets consider first DOTS FPS sample as an example, which was loaded with all mix of stuff and approaches. Was nice to look into it. But it wasn't what I really expected in terms of utilization of DOTS. There was too much noise for me, or I was not ready yet, to understand what is going on. Then I still refereed back to DOTS samples, as clean and simple examples. And of course, such great support on Unity forum.

    I think DOTS samples present very good introduction, of how to bite specific problems. They narrow problem to minimum. Good basics blocks. I can not imagine better way to learn, even without current docs. Unity keeps updating them, with latest DOTS features. Which is something really nice.

    Then we have Visual Scripting for DOTS, which allow to show principles, of building systems. Personally I don't use it. At least not in this project / not now.

    DOTS Lambda is another thing, which I don't really fancy. Weather right, or wrong, I simply don't use it and I am not planning anytime soon. Maybe I am not convinced about it yet. However, I suspect, for someone who is starting, it may be good jump into DOTS approach, using lambdas.

    Most likely, opening source code, would flood me with questions, why I did thing way I did, or what things actually do. They may have been very valid questions, considering rework etc. But I don't want to get occupied with such atm. I want make thing functional and playable first. :)
     
    iamthwee likes this.
  25. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Oh my apology I was faster. I promie, I haven't looked into your notes on your desk :p

    But out of curiosity, if willing to share, what was your concept regarding the "world"? Like in my case is the spherical planet. Was that something similar, or maybe more like Spore game of cellular game stage concept, or other?

    It is so many ways, such game mechanics can be approached. That besides OOP, or DOTS.

    I like that you brought organelles topic.
    I was debating with myself, weather I should go more into that direction, regarding evolution of cells, or maybe more casual way, with more familiar terms by potential players. Not something that can not be changed, or added later of course.

    And by all means, don't feel put of, because I make somehow similar game.
    You probably could make something with different concept, game play etc.

    Either way, it is good field to try and learn DOTS :)

    Thx, I will keep posting.
     
  26. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    In meantime, while dealing with X-Mas period, and eventually failure of my 5y old GPU, I managed to cobble something.

    Somehow my GPU's fan was lost capabilities of slowing down, making terrible noise. Cleaning and pulling it off, didn't resolved the issue. Somehow, after multiple trials and eventually, when installed alternative cooling and drivers update to GPU (somehow suspicious, but could be anything else), GPU decided to not talk to me anymore and switched permanently to VGA mode :(

    I pulled it out completely, and replaced with even older alternative, which I had in my stock of spares. But that leaves me with one monitor unfortunately. At least for meantime.
    Looks like it will be for me after X-Mas / new year shopping time, for new GPU.

    Besides my little GPU ranting ...

    Nothing specifically spectacular in recent coding, but I now converted my UI, into separate HTML, JS, CSS files, while previously I had them embedded in *.cs script. Which makes now nicer to work with, as I can focus on specific language.

    While allowing modding is not my focus on this project, but that should potentially allow, for easier UI modding in future, as well, as applying HTML5 features, if I decide to.

    Next thing on board, is to add a bit more interaction for a player, to allow a bit more control and involvement in direction of life forms evolution. I got partially core ready, but I haven't exposed hooks to UI.

    Some added and little organised info to UI panels, and visual scaling values to display in units (like 1000 is 1.00).

    upload_2019-12-22_22-54-19.png
     
  27. Deleted User

    Deleted User

    Guest

    Regarding the desk notes thing LOL no way dude. I understand coincidences happen. :)

    The spherical surface thing is a really unique idea. There was a more 2d idea I had in mind.

    There's this weird habit of mine where I yearn to do something new and innovative, its bit of a personality quirk. That's sort of what stops me from completing things at times.
     
    Last edited by a moderator: Jan 11, 2020
    Antypodish likes this.
  28. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Tell you one thing, you not alone with this one for sure. I love new tech and experimenting too. But I realized, just doing that, leads me nowhere. So I decided lock on focus. Is not easy however. But I keep trying :)
     
    Deleted User likes this.
  29. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    With little time to spare over holiday period.
    Hope anyone had a good time.

    I managed to squash few bugs here and there.
    For example some unintended cells duplication.

    Increased cells highlight intensity. But I need a bit more work on this, at some point in the future.
    Implemented range selection via UI of life forms, also with respect to genes similarity.

    Enabling multi direction cells grow of each life instance. This feature was shown in past, but I haven't really enabled it yet until now, as I needed work on other stuff first.

    upload_2019-12-28_1-51-46.png

    Of course faction marker is a bit too big atm :)
     
    iamthwee and warthos3399 like this.
  30. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Happy New Year 2020 :)

    Update for V0.0.10

    Here I got small update, which allows player, to display filtered cells of each life form.
    It is basically a frame, which hides cells outside boundary. Later this hopefully should allow players, for better add, replace, or remove cells inside life form, or in particular place. Also the purpose, for better investigate, how life form is structured.

    upload_2020-1-2_2-7-29.png

    In red frames are marked sliders changes, besides top left screenshot, which is default rendering. Other renderings are representing highlighted life forms, with applied filter.


    I think to let player choose, which and where new mutation should occur, by allowing growing new cell. This should bring more strategic management and potential better engagement to players.

    AI for now, will be relay on random behavior, of mutations.

    Once cell is mutated and gives offspring, such mutations are carried on.

    I need also consider, if to leave certain random mutation factor for players as well.
    These however, can be decided sometime in future.
     
    Last edited: Jan 2, 2020
  31. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Update for V0.0.11

    Yep it was a while since last update. I do however go through big life changes, hence big stagnation.

    But here whats is new.
    I worked on life form builder and cell editor, as mutation.
    At its current state it is in very crude form, but functional.

    Existing life form can be mutated, as cell can be added, updated and removed.
    I plan in future apply some restriction. Cost of energy, maybe some player earned points. Also possible limit on number of cells, that can be added per new life form. For now, it stays in debug / sandbox mode for testing.

    Life Form Builder



    Other than that:
    • I tidied up number of scrips. Some refactoring and other organizational changes.
    • Number of fixes to life form editor.
    • Update to camera handling and filtering what is rendered, when switched to life form builder.
    • Here I had to play a bit with shaders as well, to keep as much on DOTS side.
    • A bit messing with GUI, html and js.
    • Some experimenting with multiple cameras and skybox switch, to allow better visualization of the life form editor. However, for now I use single camera and just switch skybox.
    • I broke sun rendering :) That Unlit shader of URP / Camera matter.

    There is obviously lot of work with camera, when switching to editor mode.
    Need sorting out editor life form going "underground", when adding vertically cells.
    Also, I got some camera stuttering. Haven't investigated yet the source. Is not FPS issue however.

    Next, I am planning finally, work with penalties for cells, depending on their position in life form and obstruction of other cells in same life form. Like for example blocked by other cell, sun light for chloroplasts, or sensory (sight / hearing / smell / other). While general problem is not difficult to solve, I want to do it optimally, to avoid unnecessary calculations when not needed, for example when individual cells are added / removed / updated. Problem is simpler, when creating all cells at once.

    Yet I need figure out best way, to apply different penalties / bonuses for different type of cells.

    There are also other matter on that part, but I leave it for later.
    Basically tons of work is required behind the scene.
     
    Last edited: Mar 3, 2020
    SparrowGS and Deleted User like this.
  32. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Update for V0.0.12.


    Penalty system

    I have implemented finally, basics of penalty system.
    Chloroplast cells now obstructed from up to 5 directions, reduce their performance, proportionally, to number of obstructed sides.
    Now I can apply obstruction penalty to any type of cells. But I need run more tests on that mechanics. Specially when adding and removing new individual cells.


    UI small changes

    I have modified part of UI, to display corrected data.

    upload_2020-3-8_9-45-11.png


    More stability

    Then I focused on stability of the game.
    I had a bit fighting with it for few hours, to track specific issue.
    I decided to rearrange execution order of few systems, related to searching and consuming food.
    Appears to be working so far.
    That at least until 30th minute of accelerated runtime.
    The error is however, from different shelf. I hope to track it down. Mater of be able to reproduce it first.

    Below just for fun, planet (rather lack of it) with rendered lifeforms, populated and evolved from single chloroplast cell. I just gave it some boost at the beginning. Then let it be. :)

    upload_2020-3-8_9-50-7.png

    upload_2020-3-8_12-42-39.png

    Screenshot however, probably looks very similar, to other one earlier posted.
    Well changes were made ... at least you need keep me for a word :p


    Bugs lurking

    It is far however, from being even minimum playable as of yet.
    There are certain bugs, which are lurking about. While I know how to track them, just didn't get change to put my foot on them.


    Some inspiration time

    On side note, a bit for inspiration, while I was looking for completely different, I found following

    Coding Adventure: Simulating an Ecosystem
    by Sebastian Lague YT channel.

     
    Last edited: Oct 25, 2020
    JohngUK and SparrowGS like this.
  33. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Update for V0.0.13.

    Just quick log update on current progress.


    UI rendering filter

    From simple parts of work, I have extended functionality of the rendering mesh filter

    upload_2020-3-12_17-20-5.png

    Added few more options. Later I want to make a UI matrix, to select particular filter on/off. I use bitmask for that, as it is convenient and simple to implement.


    Annoying bug hunting

    Another thing I was working, kept on optimizing and refactoring code. I wanted reduce utilization of DOTS Entity Command Buffer. I think that went ok. But I managed create bug, which I was hunting for few hours, causing critical error. I was debugging, putting logs and couldn't figure out. I even updated DOTS Unity Entities package.

    Then eventually I have added another log, in the begging of the system I was working on. And of course, I realized I call system twice, as result of the previous testing and changes, while working on ECB reduction. Only that, I forgot to remove testing bit, duplicating system execution. Huh.

    Now I removed faulty line of code and all seems work back smooth as butter. I will keep working a bit more on ECB reduction.


    Changes to spatial mapping

    Also, what I was changing, but yet not fully complete, is spatial mapping of lifeforms in the world. While I had own spatial mapping system in place already, using NativeArray, I was experimenting with borrowed concept of spatial mapping from DOTS Boids example, using hashmap. These are to look for available spaces near existing lifeforms, prevent overgrowing, if space is occupied and for hunting prays. It will most likely replace older mechanics.

    Using NativeArray, or DOTS Dynamics Buffers concepts, were borrowed from my postponed project. However, there was spatial mapping per entity, using own octree system, to define blocks of construct and their local position. and compute flood algorithms. Also, there could be many complex constructs per world. Hence I opted out back then, from using hashmap, to avoid management nightmare and potential hash collisions. At least what I thought could be.

    I don't need that here however, for defining local cells position in lifeforms. Complexity should be much lower. Hence I use different mechanics with hashmap for lifeforms and simplified grid system for storing cells. It is not even octree.

    Current implementation is rather crude atm, but appears to be functioning so far.


    More bugs hunting

    And finally some general bugs fixing, which sneaked out behind my attention.


    Great circle

    On side note, just as I looked into scripts here and there, I remembered that for movement of lifeforms, I use calculations of great circle.
    https://en.wikipedia.org/wiki/Great-circle_distance

     
    Last edited: Mar 12, 2020
    SparrowGS likes this.
  34. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    oh hey is this like conways game of life?
     
  35. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Hey,
    Yes, that is the idea behind. At least what I am trying to do, but a bit simplified.
     
  36. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Update for V0.0.14.

    Rather brief one:
    • Camera motion improvements. I wake up morning, and came to me such obvious, that I forgot put camera transform in FixedUpdate. Instead I had it in Update, which caused previous camera motion jitter.
    • Some corrections to cells index calculations.
    • Updated random lifeforms movement behavior, when no pray was found and no sensory cells are available.
    Now focusing on food searching, with / without sensory cells (like for example eyes).
     
  37. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Currently working on UI rework and prototype.

    Since I starting adding more bits to UI and initial design was just hastily coded, I decided to sit a bit on it and do some major improvements. It is quite a bit of work, but it need be done at some point anyway. I think I am at good point, to redesign UI, based on knowing more-less what I need.

    upload_2020-3-21_21-38-18.png

    For now, on the screenshot all these are just test and template of UI elements with placeholders, with reference to previous UI.
    • I am doing major UI rework.
    • While is unfinished yet and not linked with correct data, I hope for significant simplification. But stil experimenting with things I must say, since UI layout is partially populated dynamically.
    • Using this time jQuery as my UI backbone, with HTML and CSS.
    • Bringing and expanding upon experience from my previous game prototype and combining with recent UI.
    • Nothing is definite.
    • Some of new features, which I wanted earlier to bring in are:
    • jQuery, over just javascript;
    • dual handled sliders,
    • functions simplification, do to use of jQuery;
    • Optional tooltips, when hovering over titles;
    • Draggable panels;
    • Resizable panels;
    • And some other minor backbone stuff;
    • Because all UI is written as HTML/jQuery/CSS, it can be technically modified by anyone.
    • Unfortunately panels blur does not work within a game. So possibly I will be needing to adjust transparency.
    • While most set of data was generated automatically, I want to simplify, how data communicate between UI and game. I am thinking about more generic methods, hopefully reducing number of methods to pass data, which may become messy otherwise. Still things are not 100% clear on final approach.
     
    warthos3399 likes this.
  38. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,692
    Thats going to be alot of work, best of luck bro :)
     
    Antypodish likes this.
  39. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Yep. I got already some improvement in mechanics of UI itself.
    But it is quite time consuming, testing different options. Once something works, then suddenly I change some order, and breaks. So I need rectify and look for source of issue.

    For example in javascript there is console.log, equivalent of c# debug.log. I called console.log for debugging at certain point and it invalidated my array. Never had that bug before. Removing debugging solved that issue. So lots of little thins like that. But I am certainly moving forward :)

    As I already mentioned earlier, I am still looking and testing optimal solutions for certain things.
    Good thing is, I don't need to restart Unity runtime, every time I change something in UI, unless I modify actual cs files. I just reset UI interface, after javascript files changes, while game is still running.
    This is massive time saver.
     
    warthos3399 likes this.
  40. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Update for version 0.0.15.

    Been while, sine my last update, however, I rather been busy with other matters as priority.
    Yet I did some major changes over the time.

    • Tons of code refactoring.
    • Hunting for bugs.
    • Optimization.
    • Continuous focus on determinism.
    • Major HTML5 based UI changes and lots of additions. Colors fiddling.
    • Adding skills mechanics, to allow life forms for faster growth, with additional light source. Is like a spell, where user move his pointer with a light bulb, which shines for few seconds. Any lifeform nearby with chloroplasts, can take an advantage of it. Strength also depends on the distance, form cast light.
    • Adding and modifying custom URP shaders, to accommodate visual aspects. Here still using Shader Graph as base, then modifying generated shader scripts accordingly. That yet to be compatible with DOTS, which brings additional challenges.
    • Changed shader for the atmosphere.
    • On the image below, red cubes indicates chunks / regions, which are charged with points, based on lifeform's faction.
    Basically how it works is, when lifeforms exists, it charges the region that is present in it, to mark that is occupying it. The neighbor chunks are affected by influence, of "stronger" chunks. Player skills can be cast only in areas, of enough influenced regions / chunks, which spend that charge point. The brightness of cube/chunks indicates, level of the charge. Only percentage of stronger chunk is passed away. None occupied, or distance chunks, will decay over the time their charge. Only one faction can own the chunk.

    However, this is not fully implemented feature yet and color will be depending on owned faction. So if faction is red, chunks are red. If influence of green faction is stronger, chunk will dim red color (strength) until reaching 0 level and turn accordingly to green.​
    • Highlighting lifeforms, now not only highlights themself, but also shows white borders around their cells, to make the more prominent and ease to see. This is purely custom shader side. No texture change is involved.
    • While I have ported to Unity 2020.x, I am avoiding for now DOTS Lambda approach, since IJobForeachWithEntity is depreciated. I want make sure, I have valid candidate for replacement. Potentially, I may go back to lower abstraction Jobs. There is large topic on DOTS forum on that subject as well.
    upload_2020-9-10_12-49-40.png

    upload_2020-9-10_12-52-49.png

    upload_2020-9-10_13-5-57.png

    What next?
    • Infinitely lots :D
    • Of course more bugs hunting.
    • But major thing I want to change, is the way, how influence cube / chunks are presented.
    • I was thinking about using shader, and painting feature alike, to change texture color for planet regions, depending on lifeforms' faction ownership. But I wasn't sure, how to bite efficiently the problem with DOTS.
    • However, I want make planet hex based. So I have OOP based hex planet generator, but I am writing now own ECS based hex planet generator, where each tile pentagon / hexagon is an entity. That involves mesh generation, UV assigning, and correct neighbor pent / hex tiles assigning, for future easier path planning. Still having some bugs on that side.
    • Then I want make tiles 3D, so their height can be changed as well, during planet initialization. This should allow to introduce some landscape variety.
    • Pent / Hex tiles would allow me, for better and more intuitive indication, which tile belongs to which faction. That of course on player benefit side as well.
    • That would be followed by further lifeforms interaction, with some environment influence.
    • Then further UI improvement.
    • Adding more skills, but that long way off goal.
    • Shader fixes.
    • Altitude fixes (see visible mesh cuts / overlaps in the ground).
     
    Last edited: Sep 10, 2020
  41. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,692
    Good to see you back at it bro :)
     
    Antypodish likes this.
  42. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Did anyone had ever an impression, that something else is secretly watching you?
    Possibly AI?

    See, I was working toward hex sphere planet, to replace current one.
    But some bugs start creeping in.



    StarWars fans anyone?

    Dead Star foldable toy :)
    Quite similar?


    So of course I tried to find source of bugger.
    It happened, it was very hidden.

    Then after long time of debugging, I shockingly discovered that::eek:



    (find differences)



    I took the battle upon and finally squeezed the bug. Well at least it lets me believe in that.
    But after seeing that, I think, there is higher inteligent AI form (skynet redy?).

    Anyway, I got that in the end. So far so good.



    I think here is around 40k tiles, if i recall correctly. It works smoothly.


    About the rendering approach

    For rendering I use atm mix of URP, Shader Graph and DrawMeshInstanced. Is not ideal, but so far, so good.
    Each tile has DOTS entity equivalent, but mesh actually, is not stored on entities itself.
    I rather have dedicated rendering script for the planet.

    I really would love to use
    Code (CSharp):
    1. https://docs.unity3d.com/ScriptReference/Graphics.DrawMeshInstancedIndirect.html
    , but I don't know, how to marry that with Shader Graph. I need control over tails, to change their colors. And my expertise regarding coding shaders by hand, is rather calling for a cry.

    I tried couple approaches, but didn't work for me so far.
    I even opened the thread, with a question, on the matter
    Marrying ShaderGraph code with DrawMeshInstancedIndirect code, possible? (URP)

    Regarding rendering effectively various hex tiles itself, I opened thread here.
    Rendering thousands but many unique meshes (need for optimization)
    Big thx to @neoshaman for an assist.

    In short, the challenge was, that each hex tile, is slightly different. And I wanted to keep each tile, as separate instance, so I can have more control over it, using ShaderGraph, rather building singular mesh.

    Building thousands of different meshes, cause hiccup for rendering, using DrawMeshInstanced. So I had to figure out, how to reduce number of meshes, not destroying the concept of the hex sphere.

    Hence came though from above threads, about controlling vertices with vertex color and using shaders.
    Then passing vertices position data in material Property Block of each tile, to ShaderGraph and map with corresponding vertex color ID. So I did :)

    In the end, there are only 2 meshes, passed to DrawMeshInstanced. Pentagon and Hexagon. ShaderGraph does the magic, to adjusts vertices positions for each tile. That is on the GPU side.

    The only thing regarding DrawMeshInstanced, is that I am tide, to 1024 tiles per batch. Hence I need multiple batches.


    The next?

    Well,
    • I am optimizing hexsphere generation algorithm, using DOTS, wanting to reduce further tiles generation time.
    • I want to add different tiles colors.
    • I want implement tiles groups, as of different land surface.
    • I want to figure out extrusion, using ShaderGraph, to allow for different tiles heights. Hence introducing variations of landscape. This subject was very trouble some for me, as I didn't know, how to bite it, with previous approach.
    Then
    • I would like implement path finding, so the life form can find their way. My tiles already know about their tiles neighbors.
    • Tiles will indicate using colors and replace current occupation region mechanics.
    • Each relevant, tile will have some form highlight, which will indicate, which faction it belongs to and possibly at what strength.
    • Further in the line, tiles types / height should affect lifeforms behaviours.
    • Still unsure, weather I want one lifeforms per tile, or should allow multiple lifeforms per tile. Kind of like Civilization game, where only certain friendly units can be on same tile.
    I hope, that hex tiling system, will open many routes, for adding further feature. More so, than my current approach.
    Including finding neighbor / nearby lifeforms.

    I need to say, I am a bit excited about it. I would like to see eventually, both planet and lifeforms coexisting together :)
     
  43. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Working on my URP pent/hex tails shader.

    upload_2020-9-23_14-51-49.png

    Which is responsible for extrusion of tiles faces, changing color and applying lighting effects.

    While basics works relatively fine, with still some bugs on side faces (colors are completely random),

    upload_2020-9-23_14-51-16.png

    but I can not say same thing, on larger scale (at least not yet) :)

    upload_2020-9-23_14-53-12.png

    However, here is few funny / nice / inspiring buggy results.

    upload_2020-9-23_14-54-44.png

    upload_2020-9-23_14-55-7.png
     
    warthos3399 likes this.
  44. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Inside hex sphere

    upload_2020-9-23_14-55-39.png

    And one more

    upload_2020-9-23_14-56-13.png
     
    warthos3399 likes this.
  45. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Now this one looks much better.
    I think I managed to fix couple of things in shader. Had issue with material normals, causing uneven side faces extrusion.
    At the same time, I slightly simplified the shader.
    Still I need do few more tweaking and corrections.
    Looking for an optimal way.

    I can control colors and heights.

    upload_2020-9-24_13-16-38.png

    And I think these two looks very cute :rolleyes:

    upload_2020-9-24_13-17-24.png

    upload_2020-9-24_13-17-39.png

    Almost like a virus :p

    Edit:
    I have opened other day a thread with funny / weird bugs
    https://forum.unity.com/threads/share-your-funny-weird-bizarre-bugs-and-errors-during-deving.972708/
     
    Last edited: Oct 27, 2020
  46. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Finally I got to the point, to quite nicely functional hexsphere planet, which is procedurally generated.

    • Using of course DOTS Jobs, to generate tiles. This particular example, has just over 10k tiles. Each tile is represented by DOTS entity. Feature not fully complete yet.
    • Rendering is accomplished with Graphics.DrawMeshInstanced.
    • At initialization are generated 2 meshes, 3D pentagon and hexagon, with extruded top faces.
    • ShaderGraph is used, to align vertices correctly, apply height, color of tiles, shiny borders of each tile, representing faction and the source of lights (sun and optional secondary).
    • Using Perlin noise, to generate terrain variation.
    • Able to dynamically change height and colors of tiles.
    I think it looks quite good :)

    upload_2020-9-25_23-43-22.png

    Sure, water tiles are also with different height for now.
    At some point, probably I will make color variations to tiles.



    • Had tons of challenges to overcome, to get to that point with hexsphere planet.
    • Been doing such procedural generation for the first time.
    • But eventually I got here.
    • There are still minor things to fix, but I am happy so far, with an outcome.

    Now I need correctly associate lifeforms to tiles.
    Still not 100% figured out how to make it, but I got few ideas, crawling my mind.
    Then I need introduce appropriate behavior for lifeforms, depending on tile.
     
    Last edited: Sep 25, 2020
  47. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Next little stress test (160k hex tiles) after couple jobs optimizations.
    This is not anything critical in terms of gameplay.
    But may be potentially used feature, to adjust planet look, before game startup.

    Initially I tested dynamically changing noise of hex planet, for 10240 tiles.
    5 consecutive noise changes tests, for different type of job.
    • Burst Parallel
      • 11, 2, 2, 2, 2 ms
    • Burst Single thread
      • 28, 6, 5, 6, 6 ms
    • Single thread
      • 27, 23, 23, 23, 24 ms
    • Parallel
      • 8, 5, 6, 6, 5 ms
    So of course Burst Parallel is best so far.

    Then I run stress test of 163 842 tiles on my hex sphere.



    Burst Parallel job takes approx between 30-50 ms, when changing noise property.
    It is important to notice, that for 160k tiles, CPU take +20ms. This is something I would love to reduce.

    This largely has to do with me using Graphics.DrawMeshInstanced rather Graphics.DrawMeshInstancedIndirect.
    But until I figure out, how to couple things with ShaderGraph, I stay with first approach.
     
  48. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Just quick one, I have add some extra features to my hex planet.

    upload_2020-9-27_2-47-57.png

    • North and South poll ice caps, with adjustable range, how far they can go toward equator.
    • Also with light blue toward polls, there is indication of frozen water.
    • Mountains / hills ice caps, with adjustable height.
     
  49. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Just quick drop, what I am up to, regarding hex sphere / hex planet generation:

    What so far:
    • I wanted to implement and integrate further features, but ...
    • I am focusing atm, on optimizing my hexsphere generator under stress test, of 163k tiles, on my 5-6 year old PC, with i7 8 cores.
    • I switched from shader graph and GPU focus, of individual tiles generation and rending, to CPU combined tiles into bigger meshes.
    • As the result, I have gained in runtime, of on average 2-3 ms, for 163k tiles planet. That also freeing up my GPU.
    • The primary downside was that planet generation took now 50sec, and modification well over 100 ms.
    • However, after further refactoring, bursting and jobyfing, I dropped such large planet generation below 5 sec (10x improvement), and reducing planet modification time too.
    • I remove Garbage Collection (GC), by replacing mesh.vertices and mesh.color assignment, for mesh.SetVertices () and mesh.SetColors (). That was massive gain as well. Now I can pass directly NativeArrays.
    • I broke my shader behaviour, responsible for sunlight angle. It works only partially.
    • I build also my little interface, for quicker hex sphere generation and real time modifications. It helps a lot in debugging too.
    upload_2020-10-5_19-15-13.png
    I can extend list of noise properties, to add more variation, of Perlin generated hex tile meshes.


    My last stress test:


    • I would like to say special thanks to Taylor S, for technical discussion on my multiple hex sphere youtube videos and encouraging for further optimizations on part of this project.
    • This is not something I want to use normally at gameplay, but stress testing, profiling and optimization is coming good out of it. I would expect planet size of 2k, 10k to up to 40k tiles.
    • Optional generating GameObject meshes for debugging purposes.

    TODO:
     
    Last edited: Oct 5, 2020
  50. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,716
    Nothing fancy to showcase today.

    However, while investigating my last TODO tasks, I also looking, how to best spawn initial lifeforms on tiles.

    So here is my little goal:
    • I want to be able to populate certain tiles with life forms, in designated areas by factions, at starting points.
    • I want to limit vertically, toward north / south polls, how far initial spawning will happen.
    • Weather I want to allow multiple lifeforms per tile, is additional think to consider.
    The challenge:
    • I want to select only given tiles, in specific area. For example square, or circle selection around equator, for only one faction.
    • Due to nature of tiles shape (hex and pentagon), I want to avoid overlap of meshes in spatial map.
    • Further tho, creating individual colliders of thousends of different shapes (nature of the hex sphere), potentially kills the benefits of ECS. Yet I need to confirm that, if this same applies as per meshes for rendering.
    • I am uncertain atm, if using octree, or other spatial map, just to store tiles ( hex / pentagons ) locations, is suitable application.
    • I would like also be able, to select 3D tiles with respect of their heights in the future. Yet solution should be optimal, when applicable.
    My current approach:
    • I am currently implementing Unity.physics based raycasting for tiles selection. In such way that tiles collider will be a combined mesh collider and I will be using raycsted faces normals and hash map, to define which tile is selected.