Skip to content

Strieglitz/Unity-Dots-WireframePlexusEffect

Repository files navigation

Unity-Dots-WireframePlexusEffect

Table of contents

  1. Overview
    1. Render Pipeline Compability
    2. Unity Version Compability
  2. Getting Started
    1. Play around in the Repository ExampleScene
    2. Import to new project and setup
    3. How to Spawn a PlexusEffect
  3. How it actualy works
  4. Tips
    1. loading performance gain with Precalculated PlexusGameObject
  5. Visual Examples

Overview

A Plexus like effect with glowing vertecies and connection-lines based on the wireframe of the mesh. When the vertecies move around they connect and disconnect based on the distance. Implemented with ECS, parallel running jobs and burst compile.

Had no idea how to implement this effect in Shadergraph or Effectgraph so i tried it with ecs/dots. Would love to know how to achieve this with Shadergraph or an Effectgraph!

You can set any mesh and andjust some values like how fast and far the vertecies move from their original Position or how thick the connection lines are and how streched they have to be until they get invisible.

There is still tonns of room for improvements like adding lots of options to make the the effect more variable. If you have an idea or an request please let me know.

Render Pipeline Compability

The effect does not run on heavy Shaders and can be used in ALL RenderPipelines. The development Unity Project was build with the URP Renderpipeline. If you want to use the HDRP Renderpipeline you just have to convert the 2 Shaders that are used in the project. Im not sure if you can automaticly upgrade them to HDRD in a HDRP-Project. But you can always rebuild them. In the URP-Project just open the shaders with the shadergraph editor and you can see how the shader is built. then open the HDRP project and rebuilt the Shader in a new Shadergraph.

Unity Version Compability

i built the Project with Unity 6 but i dont know in which version it will break. I tried out with 2022.3.55f1 and it worked just like described, so i just assume the 2023 will work too until some says otherwise.

Getting Started

how to get started with this repository. you can just download it an play around in the sampleScene, create a new project and play around or load it into a existing one.

Play around in the Repository ExampleScene

After donwloading or cloning the repo, open it with the corresponding Unity version. The opne the "SampleScene" from "Assets/PlexusEffect/ExampleScene/". In the Scene you have to make sure the "EntitySubScene" is activated (is ticked) grafik

Then when you enter the Playmode the PlexusObjects should load and animate due to the parameters. Now you can change the paramters, exit the PlayMode select the Gameobject "PlexeusObjectSphere" and change the parameters, then restart the playmode to what changed.

Import it into your Project and Setup

here is an example on how to import the effect into a fresh project.

  • Download this Repository.
  • Create a new Project NewPorject
  • Open The "PackageManager" window to import the needed ECS dependencies NewPorject
  • In the "PackageManager" window, switch to the "UnityRegistry" section NewPorject
  • Install the "Entities" package, which grabs all the neccessary packages for ECS NewPorject
  • Install the "EntitiesGraphics" package, which is needed to render meshes with ECS NewPorject
  • to import the "WireframePlexusEffect" package, close the "PackageManager" and rightclick in the Project panel and click "Import Package" -> "Custom Package" NewPorject
  • navigate to the location where you donwloaded/cloned this repository and select the "plexusEffectPackageToImport" package from the "assets" folder, and confirm NewPorject
  • in the import dialog click "import", this will genreate a new folder called "PlexusEffect" where you can find all the PlexusEffect realated stuff
    NewPorject
  • now that that the plexusEffect is imported, lets make some effects. In order to use ECS Entites a "Subscene" is needed. So rightclick into the "Hierarchy" and create a new Subscene. The Subscene is like a Scene but for ECS Entites only, so we will fill it later with ECS life. NewPorject
  • give the Subscene a meaningfull name NewPorject
  • now that the Subscene is created, make sure that it is ticked and enabled, because a subscene can also be disabled NewPorject
  • In order to fill the Subscene with life, we have to register the Entities that we want to use later in the Subscene. To do so, navigate to PlexusEffect/prefabs/Subscene folder in your assets. NewPorject
  • and drag and drop all 3 "EntitySpawner"-Prefabs into the Subscene we created earlier. These will tell the Subscene how to Instantitate a new Entity instance. NewPorject

Great, now the PlexusEffect stuff is setup and ready to be used to actualy render something!

Spawn PlexusEffects in your Project

in this example we create a simple PlexusEffect on a Unity-sphere

  • In our regular Scene lets create a new Gameobject and choose the default Sphere, with rightclick into the "Hierarchy" and select GameObject->3D Object->Sphere NewPorject

  • Add the "PlexusGameobjectFromMesh" Component to the Sphere Gameobject. This Component will iterate over the MeshData and convert it to a kind of PlexusEffectMesh data that will be used by the Effect. this will happen when the scene starts and is quite a heavy calculation. for an example like this, it is fine, but for a more preformance critical setup you should consider using the "PlexusGameObjectPrecalculated" Component NewPorject

  • now the Spehere is a "PlexusGameObject" but you will not be able to see it, because there are no values in the "PlexusGameObjectData" Field of the "PlexusGameobjectFromMesh" Component. So lets fill it with some values.

NewPorject

  • to better see the actual Plexus Effect, move the Sphere Closer to the Camera, because the position of the PlexusEffect will be synced with the position of the Sphere, even at runtime. NewPorject

  • test out the Effect and press the play button. If you used the values from the previous section, you should get a blue Sphere with the plexusEffect.
    NewPorject

  • the effect could look much better, with the default settings you will see aliasing and hard edges, so lets set the AntiAliasing. In this case with an URP Proejct you can set the AA in the PC_RP.asset
    NewPorject

  • Postprocessing will also help, increasing the Bloom will also result in a better look with softer edges on the edges and vertecies. NewPorject

  • Now you have a working example and can play around with the values and find out cool combinations and visuals. NewPorject

How it works

Todo

Tips

PlexusGameObjectPrecalculated

the loading Of PlexusGameobjectFromMesh is quite slow because on start of the GameObject it iterates over every vertex and edge to calculate how the PlexusEffect needs to be. on objects with ten or hundreds thousands of vertices this can take multiple seconds. To adress this issue there is also the fast loading PlexusGameObjectPrecalculated which generates all the neccessary data in advance.

Examples

Example with the buildin sphere mesh

Example with 5 buildin sphere mesh stacked on top of each other

Or you can abuse it as a Wireframe Shader, when setting the vertices to not move around

Multi Object setup with different settings, meshes and colors

An contact color change animation for later use in a game

Contact animation with vertex distortion

About

A Plexus like effect with connection-lines based on the wireframe of the mesh. Implemented with parallel running jobs and burst compile.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages