title: Errors on Github project- "Value cannot be null", "Property (particleBuffer) at kernel index (1) is not set"
body: <p>I'm trying to learn about compute shaders, and this project is really awesome. It is <a href="https://github.com/TheAllenChou/unity-cj-lib" rel="nofollow noreferrer">https://github.com/TheAllenChou/unity-cj-lib</a></p>
  <p>But when I run it, there are errors I can't figure out how to get rid of:</p>
  <blockquote>
  <p><strong>ArgumentNullException: Value cannot be null. Parameter name: shader</strong></p>
  <p><strong>ArgumentNullException: Value cannot be null. Parameter name: material</strong></p>
  <p><strong>Compute shader (ParticleLogic): Property (particleBuffer) at kernel index (1) is not set</strong></p>
  </blockquote>
  <p>Any idea on how to fix? I'm using <code>Unity 2019.3.0a7</code></p>
  <p>It's only happening for the code for the &quot;<strong>Turbulent Rainbow GPU Particles</strong>&quot; example, so I've been going to the files and changing filepaths, and trying to feed it a material manually.</p>
  <p>I just don't think I understand what's happening enough to ever fix it on my own, so I am reaching out for assistance. Appreciate any help.</p>
  <p>Relevant code...</p>
  <pre><code>using UnityEngine;
  
  using CjLib;
  
  namespace TurbulentRainbowGpuParticles
  {
    public class Main : MonoBehaviour
    {
      public ComputeShader m_shader;
  
      private const int kNumParticles = 10000;
  
      /*
      private struct Particle
      {
        // 4 floats
        Vector3 m_position;
        float m_damping;
  
        // 4 floats
        Quaternion m_rotation;
  
        // 4 floats
        Vector3 m_linearVelocity;
        float m_scale;
  
        // 4 floats
        Quaternion m_angularVelocity;
  
        // 4 floats
        Vector4 m_lifetime;
  
        // 4 floats
        Color m_color;
      };
      */
  
      private ComputeBuffer m_computeBuffer;
      private ComputeBuffer m_instanceArgsBuffer;
      //private Particle[] m_debugBuffer;
  
      private Mesh m_mesh;
      private Material m_material;
      private MaterialPropertyBlock m_materialProperties;
  
      private int m_csInitKernelId;
      private int m_csStepKernelId;
  
      private int m_csParticleBufferId;
      private int m_csScaleId;
      private int m_csDampingId;
      private int m_csSpeedId;
      private int m_csLifetimeId;
      private int m_csNumParticlesId;
      private int m_csTimeId;
  
      void OnEnable()
      {
        m_mesh = new Mesh();
        m_mesh = PrimitiveMeshFactory.BoxFlatShaded();
  
        int particleStride = sizeof(float) * 24;
        m_computeBuffer = new ComputeBuffer(kNumParticles, particleStride);
  
        uint[] instanceArgs = new uint[] { 0, 0, 0, 0, 0 };
        m_instanceArgsBuffer = new ComputeBuffer(1, instanceArgs.Length * sizeof(uint), ComputeBufferType.IndirectArguments);
        instanceArgs[0] = (uint) m_mesh.GetIndexCount(0);
        instanceArgs[1] = (uint) kNumParticles;
        instanceArgs[2] = (uint) m_mesh.GetIndexStart(0);
        instanceArgs[3] = (uint) m_mesh.GetBaseVertex(0);
        m_instanceArgsBuffer.SetData(instanceArgs);
  
        //m_debugBuffer = new Particle[kNumParticles];
  
        m_csInitKernelId = m_shader.FindKernel(&quot;Init&quot;);
        m_csStepKernelId = m_shader.FindKernel(&quot;Step&quot;);
  
        m_csParticleBufferId = Shader.PropertyToID(&quot;particleBuffer&quot;);
        m_csScaleId = Shader.PropertyToID(&quot;scale&quot;);
        m_csDampingId = Shader.PropertyToID(&quot;damping&quot;);
        m_csSpeedId = Shader.PropertyToID(&quot;speed&quot;);
        m_csLifetimeId = Shader.PropertyToID(&quot;lifetime&quot;);
        m_csNumParticlesId = Shader.PropertyToID(&quot;numParticles&quot;);
        m_csTimeId = Shader.PropertyToID(&quot;time&quot;);
  
        m_material = new Material(Shader.Find(&quot;CjLib/Example/TurbulentRainbowGpuParticles&quot;));
        m_material.enableInstancing = true;
        m_material.SetBuffer(m_csParticleBufferId, m_computeBuffer);
        m_materialProperties = new MaterialPropertyBlock();
  
        m_shader.SetFloats(m_csScaleId, new float[] { 0.15f, 0.3f });
        m_shader.SetFloat(m_csDampingId, 6.0f);
        m_shader.SetFloats(m_csSpeedId, new float[] { 3.0f, 4.0f, 1.0f, 6.0f });
        m_shader.SetFloats(m_csLifetimeId, new float[] { 0.1f, 0.5f, 0.5f, 0.1f });
        m_shader.SetInt(m_csNumParticlesId, kNumParticles);
  
        m_shader.SetBuffer(m_csInitKernelId, m_csParticleBufferId, m_computeBuffer);
        m_shader.SetBuffer(m_csStepKernelId, m_csParticleBufferId, m_computeBuffer);
  
        m_shader.Dispatch(m_csInitKernelId, kNumParticles, 1, 1);
  
        //m_computeBuffer.GetData(m_debugBuffer);
      }
  
      void Update()
      {
        m_shader.SetFloats(m_csTimeId, new float[] { Time.time, Time.fixedDeltaTime });
        m_shader.Dispatch(m_csStepKernelId, kNumParticles, 1, 1);
  
        //m_computeBuffer.GetData(m_debugBuffer);
  
        Graphics.DrawMeshInstancedIndirect(m_mesh, 0, m_material, new Bounds(Vector3.zero, 20.0f * Vector3.one), m_instanceArgsBuffer, 0, m_materialProperties, UnityEngine.Rendering.ShadowCastingMode.On);
      }
  
      void OnDisable()
      {
        if (m_computeBuffer != null)
        {
          m_computeBuffer.Dispose();
          m_computeBuffer = null;
        }
  
        if (m_instanceArgsBuffer != null)
        {
          m_instanceArgsBuffer.Dispose();
          m_instanceArgsBuffer = null;
        }
      }
    }
  }
  </code></pre>