Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

LineRenderer on Pure ECS

Discussion in 'Graphics for ECS' started by JorMed, Oct 8, 2018.

  1. JorMed

    JorMed

    Joined:
    Mar 7, 2018
    Posts:
    3
    Hello, there is the dilemma:
    Is it possible to somehow extract Mesh Insatance or what ever doing the rendering from Unity LineRenderer Component to use it as Pure ECS? Or stick to Hybrid ECS model until LineRenderer component will be implemented in Entities world?
    Maybe there is alternative way to generate line spline without GameObjects ?
    In advance thank you for your thoughts.
     
  2. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    451
    In pure you will not be able to use it. So you have two options stick to hybrid or implement your own line generating solution. Basically, you need to generate a mesh and set it in MeshInstancedRenderer.
     
    JorMed likes this.
  3. JorMed

    JorMed

    Joined:
    Mar 7, 2018
    Posts:
    3
    Thanks for answer.
    I'd also find solution to work with GL directly or use both Pure + Hybrid ECS, just with system which sync or transfers data between some GameObjectsEntities & Entities (It might be useful not only for line renderer).
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,824
    Once you start using Hybrid, you are loosing best benefits of of Pure ECS. But you can combine of course pure and Hybrid in your project. I would follow as @Micz84 suggested.
     
  5. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    785
    Has anyone figured out an easy way to do this yet? The original line renderer component always faces the camera and is great for things like laser beams. It would be really nice to have that functionality again.
     
  6. cultureulterior

    cultureulterior

    Joined:
    Mar 15, 2015
    Posts:
    68
    I have a shader graph that integrates with DOTS and does this.
     
  7. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,721
    That’s cool ,Do you have an example screenshot
     
  8. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    @lclemens You can try this Segments package (inspired by older ECSLineRenderer). It's rather simple to use and line-plotting can be burst+jobified which is good.

    Single biggest downside so far: I'm not sure how to get rid of HybridRenderer's overhead it adds (it's becoming noticeable above about 10k segments).
     
    lclemens likes this.
  9. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,824
    You probably could use shader graph, to improve on rendering.
     
  10. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    how do you do that? could you share a source to learn about?
     
  11. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,824
    I would bite problem from two angles.
    But this vid may be good starting point

    Code (CSharp):
    1. https://youtu.be/9aOtie1DKCc?t=1745
    Jump to 29 min, where video describes shapes nodes of the shader graph. Could be also useful.



    If just dealing with cubes, I just need common shader for each cube, with own texture, and properties.
    Basically you got material, which represents wired mesh of the cube. And switch transparency / texture in shader.

    You will need to look for MaterialProperty keyword. There are some good post in the forum, explaining it well.
    Something like that.
    Code (CSharp):
    1. [MaterialProperty("_Alpha", MaterialPropertyFormat.Float4)]
    2.     public struct ShaderAlphaComponent : IComponentData
    3.     {
    4.         public float f ;
    5.     }
    I did something like that with both cubes and 3D hexes.

     
    Last edited: Feb 26, 2021
  12. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    WOW Thanks a lot!
     
    Antypodish likes this.
  13. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    785
    That segments package looks pretty neat, however, it looks to me like it's just for doing a simple segment. The old linerenderer could do things like this:

    upload_2021-2-27_11-49-35.png

    Where the "line" is actually a plane that always faces the camera and that plane can have a material applied to it and animated.
     
  14. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,824
    Looks like very nice effects.

    You could apply / modify shader, to animate similar effect.
    Regarding facing to camera, you would need rotate segment along its own axis toward the camera.
    I am sure @andrew-lukasik could apply such, if wanted / had time / etc.
     
    lclemens likes this.
  15. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    785
    I wish I could take credit for those laser-beam effects, but I just screenshotted them. There are a bunch off effects assets on the asset store that use them and there are a few youtube tutorials about how to make them using a LineRenderer.

    I attempted to make a half-ass one that uses two perpendicular intersecting transparent planes:

    upload_2021-2-27_12-12-52.png

    But it doesn't look nearly as good because DOTS doesn't have anything like the old LineRenderer.

    plasma.gif
     
    koonm likes this.
  16. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,824
    Unfortunately with dots, we are left to do plenty of our own solutions.
    At least for time being.
     
  17. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    785
    Just wanted to ping this thread - has anyone found a good solution for an ECS line-renderer that can be animated yet?
     
  18. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,349
    It's on my backlog of things to implement, but as with all things I do, there's lots of competing priorities. However, if animating a general mesh is sufficient for your use case, I have this: https://github.com/Dreaming381/Lati...ion Animation and Rendering/Dynamic Meshes.md