Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sprite rendering system for preview 30

Discussion in 'Graphics for ECS' started by Skyblade, Apr 23, 2019.

  1. Skyblade

    Skyblade

    Joined:
    Nov 19, 2013
    Posts:
    77
    Anyone has working sprite rendering system for the latest API version? I used to use this one, but it's way outdated.
     
    Last edited: Apr 23, 2019
    foxnne likes this.
  2. kg-admin

    kg-admin

    Joined:
    Mar 27, 2019
    Posts:
    3
    We've used ECS for a while at preview 24, but after upgrade to preview 30, lots of API changed and our sprite animation rendering system can not ported. is there any plan to support MaterialPropertyBlock in RenderMeshSystem? Or have a callback after culling and batching, like:

    // T is used to select entities has a custom component of type T, and Action is used to fill the MaterialPropertyBlock according to NativeArray<T>, maybe a trunk or a batch
    RenderMeshSystemV2<T, Action<MaterialPropertyBlock, NativeArray<T>>> where T : struct, IComponentData
    {

    m_DynamicGroup = GetEntityQuery(..., ComponentType.ReadOnly<T>();
    //...
    // pass the callback to InstancedRenderMeshBatchGroup, and call it before matrix data is filled.
    m_InstancedRenderMeshBatchGroup.AddBatch(tag, rendererSharedComponentIndex, instanceCount, chunks, sortedChunkIndices, startSortedIndex, batchChunkCount, flippedWinding, editorRenderData, callback);
    }

    I have try this impl but two problems:
    1.
    after I copy RenderMeshSystemV2.cs and rename to CustomRenderMeshSystemV2.cs and modified all the name inside accordingly, unity editor will crash after hit play. (how can i debug it or what should i do?)

    2.
    doest ComponentSystem support template? like I wrote before.
     
  3. vitautart

    vitautart

    Joined:
    May 3, 2018
    Posts:
    29
    Old method, with DrawMeshInstanced must works very well. I managed to create two rendering systems fully independent to Hybrid Renderer with DrawMeshInstanced in last ECS version on 2019.1. So I think custom sprite renderer with DrawMeshInstanced also posible.
    Also I managed to inject MaterialPropertyBlock to BatchRendererGroup in HybridRenderer, but it doesn't work properly, because of complexity of HybridRenderer. It is more complicated than just inject MaterialPropertyBlock to AddBatch, internaly maybe there are some reversing, or something like that, so all instanced array data must be reversed by chunk. Also there are some sort of caching, that breaks all straightforward injection of instanced data. And important for me negative factor is limitation of map size and camera movement speed.