void OnEnable() { m_pw = GetComponent <GPUParticleWorld>(); if (m_camera == null || m_camera.Length == 0) { m_camera = new Camera[1] { Camera.main }; } m_tmp_params = new CSTrailParams[1]; m_max_entities = m_pw.GetNumMaxParticles() * 2; m_buf_trail_params = new ComputeBuffer(1, CSTrailParams.size); m_buf_trail_entities = new ComputeBuffer(m_max_entities, CSTrailEntity.size); m_buf_trail_history = new ComputeBuffer(m_max_entities * m_trail_max_history, CSTrailHistory.size); m_buf_trail_vertices = new ComputeBuffer(m_max_entities * m_trail_max_history * 2, CSTrailVertex.size); if (m_act_render == null) { m_act_render = Render; foreach (var c in m_camera) { if (c == null) { continue; } DSRenderer dsr = c.GetComponent <DSRenderer>(); dsr.AddCallbackTransparent(m_act_render); } } }
void Render() { if (!enabled || !m_pw.enabled || m_mat_trail == null) { return; } m_mat_trail.SetBuffer("particles", m_pw.GetParticleBuffer()); m_mat_trail.SetBuffer("params", m_buf_trail_params); m_mat_trail.SetBuffer("vertices", m_buf_trail_vertices); m_mat_trail.SetPass(0); Graphics.DrawProcedural(MeshTopology.Triangles, (m_trail_max_history - 1) * 6, m_pw.GetNumMaxParticles()); }
void OnEnable() { m_pw = GetComponent<GPUParticleWorld>(); if (m_camera == null || m_camera.Length == 0) { m_camera = new Camera[1] { Camera.main }; } m_tmp_params = new CSTrailParams[1]; m_max_entities = m_pw.GetNumMaxParticles() * 2; m_buf_trail_params = new ComputeBuffer(1, CSTrailParams.size); m_buf_trail_entities = new ComputeBuffer(m_max_entities, CSTrailEntity.size); m_buf_trail_history = new ComputeBuffer(m_max_entities * m_trail_max_history, CSTrailHistory.size); m_buf_trail_vertices = new ComputeBuffer(m_max_entities * m_trail_max_history * 2, CSTrailVertex.size); if (m_act_render==null) { m_act_render = Render; foreach (var c in m_camera) { if (c == null) continue; DSRenderer dsr = c.GetComponent<DSRenderer>(); dsr.AddCallbackTransparent(m_act_render); } } }