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

Question How do I enable DOTS Instancing on a material/shadergraph

Discussion in 'Entity Component System' started by DizzyTornado, Jun 30, 2021.

  1. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    I cannot find this option anywhere. I found the GPU instancing option but there is nothing next to it for DOTS. I am using Unity 2020.3
     
  2. vectorized-runner

    vectorized-runner

    Joined:
    Jan 22, 2018
    Posts:
    396
    Are you using URP? You can tick the Hybrid Instanced option by Node Settings -> Override Property Declaration then select Hybrid Per Instance
     
  3. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    I am utilizing HDRP, in the following thread it says it appears in HDRP.
    https://forum.unity.com/threads/dots-render-pipeline.752198/
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    Just tick the GPU instantiation on the material, in the inapector. That it.
     
  5. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    There is only an option for this on the material not the ShaderGraph, I ticked the one on the material in the inspector however that did not make a difference.
     
  6. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    ShaderGraph shaders automatically produce DOTS variants once
    ENABLE_HYBRID_RENDERER_V2
    is defined in the project. You don't have to set anything on the material either, the keyword will automatically get set when rendered by the HybridRenderer.
    You have to use HybridRendererV2.
     
    DizzyTornado and Antypodish like this.
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    Depending on Unity version this may look slightly different.
    Earlier there was single line of text, and keywords need be separated by semi colon ;

    upload_2021-7-1_13-15-23.png
     
    DizzyTornado likes this.
  8. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    @julian-moschuering

    Hm I did this too, my entities are still all sharing the same properties however. Here is what I am doing codewise:

    Code (CSharp):
    1. Entity newNodeEntity = entityManager.Instantiate(nodeEntityPrefab);
    2.  
    3. Translation translation = new Translation()
    4. {
    5.       Value = coord
    6. };
    7.  
    8. entityManager.AddComponentData(newNodeEntity, translation);
    9.  
    10. Color evaluatedColor = nodeValueGradient.Evaluate( (float)value);
    11. float4 colorF = new float4(evaluatedColor.r, evaluatedColor.g, evaluatedColor.b, evaluatedColor.a);
    12. MaterialColor mcc = new MaterialColor { Value = colorF };
    13. entityManager.AddComponentData<MaterialColor>(newNodeEntity, mcc);
    14.      
    15. entityManager.SetComponentData(newNodeEntity, new NodeData { nodeName = id, nodeValue = value });
    Also, I Debug.Log and the colorF is being given a valid color so I know the issue is with applying the color to the material/shader.
     
    Last edited: Jul 2, 2021
  9. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134