void Setup(GPUComputeParticleSystem system) { var buffer = system.ParticleBuffer; GPUParticle[] particles = new GPUParticle[buffer.count]; buffer.GetData(particles); var count = particles.Length; bounds = new List <CPBound>(); Bintree(Vector3.zero, Vector3.one, depth); boundsBuffer = new ComputeBuffer(bounds.Count, Marshal.SizeOf(typeof(CPBound_t))); boundsBuffer.SetData(bounds.Select(b => b.Structure()).ToArray()); boundsReferencesBuffer = new ComputeBuffer(count, Marshal.SizeOf(typeof(int))); var kernel = shader.FindKernel("Octree"); shader.SetBuffer(kernel, "_Bounds", boundsBuffer); shader.SetInt("_BoundsCount", bounds.Count); shader.SetBuffer(kernel, "_BoundsReferences", boundsReferencesBuffer); Dispatch(kernel, system); shader.SetBuffer(0, "_BoundsReferences", boundsReferencesBuffer); }
public override void Dispatch(GPUComputeParticleSystem system) { shader.SetFloat("_Time", ticker); shader.SetFloat("_Scale", scale); shader.SetFloat("_Intensity", intensity); base.Dispatch(system); }
public void Dispatch(GPUComputeParticleSystem system) { updaters.ForEach(updater => { if (updater.gameObject.activeSelf) { updater.Dispatch(system); } }); }
public void Init(GPUComputeParticleSystem system) { updaters.ForEach(updater => { if (updater.gameObject.activeSelf) { updater.Init(system.ParticleBuffer); } }); }
public override void Dispatch(GPUComputeParticleSystem system) { shader.SetVector("_Force", force); shader.SetVector("_Seed", seed); shader.SetFloat("_DT", Time.deltaTime * lifetimeSpeed); shader.SetVector("_EmissionCenter", emissionArea.center); shader.SetVector("_EmissionSize", emissionArea.size); base.Dispatch(system); }
public override void Dispatch(GPUComputeParticleSystem system) { if (stateBuffer == null) { Init(system.ParticleBuffer); } shader.SetFloat("_DT", Time.deltaTime * speed); shader.SetFloat("_Scale", scale); base.Dispatch(system); }
public override void Dispatch(GPUComputeParticleSystem system) { shader.SetFloat("_T", t); shader.SetFloat("_Time", ticker); shader.SetFloat("_DT", Time.deltaTime * 3f); shader.SetFloat("_Scale", scale); shader.SetFloat("_Intensity", intensity); shader.SetFloat("_Power", power); shader.SetVector("_Seed", seed); base.Dispatch((int)mode, system); }
public override void Dispatch(GPUComputeParticleSystem system) { shader.SetFloat("_Size", size); shader.SetFloat("_Intensity", intensity); shader.SetFloat("_Speed", speed); shader.SetFloat("_R", 1f / system.ParticleBuffer.count); shader.SetFloat("_Time", ticker); shader.SetFloat("_DT", Time.deltaTime * speed); base.Dispatch((int)mode, system); }
public override void Dispatch(GPUComputeParticleSystem system) { // shader.SetVector("_GravityDirection", system.transform.TransformDirection(direction)); // Debug.Log(system.transform.TransformDirection(direction)); // shader.SetFloat("_Gravity", gravity); // shader.SetVector("_GravityDirection", direction); // shader.SetVector("_GravityDirection", system.transform.TransformDirection(direction)); shader.SetVector("_GravityDirection", system.transform.InverseTransformDirection(direction)); shader.SetFloat("_Gravity", gravity); base.Dispatch(system); }
public override void Dispatch(GPUComputeParticleSystem system) { if (boundsBuffer == null) { Setup(system); } UpdateBounds(); shader.SetFloat("_T", t); shader.SetBuffer(dispatchID, "_Bounds", boundsBuffer); base.Dispatch(system); }
public override void Dispatch(GPUComputeParticleSystem system) { if (boundsBuffer == null) { Setup(system); } UpdateBounds(); shader.SetBuffer(dispatchID, "_Bounds", boundsBuffer); shader.SetFloat("_T", (mode == ExtrusionMode.Physics || mode == ExtrusionMode.Explosion) ? 1f : t); base.Dispatch(system); }
public override void Dispatch(GPUComputeParticleSystem system) { if (fromBuffer == null) { Init(system.ParticleBuffer); } if (fromBuffer != null) { shader.SetFloat("_RT", rt); base.Dispatch(system); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GPUComputeParticleSystem system = target as GPUComputeParticleSystem; // system.updaters; EditorGUILayout.LabelField("updaters"); // EditorGUILayout.BeginHorizontal(); EditorGUI.indentLevel++; int n = system.updaters.Count; for (int i = 0; i < n; i++) { var updater = system.updaters[i]; if (updater == null) { system.updaters.RemoveAt(i); return; } GUILayout.BeginHorizontal(); GUILayout.Label(updater.name); if (i != 0 && GUILayout.Button("up", GUILayout.Width(50), GUILayout.Height(20))) { var tmp = system.updaters[i]; system.updaters[i] = system.updaters[i - 1]; system.updaters[i - 1] = tmp; break; } else if (i != n - 1 && GUILayout.Button("down", GUILayout.Width(50), GUILayout.Height(20))) { var tmp = system.updaters[i]; system.updaters[i] = system.updaters[i + 1]; system.updaters[i + 1] = tmp; break; } else if (GUILayout.Button("Remove", GUILayout.Width(50), GUILayout.Height(20))) { system.updaters.RemoveAt(i); break; } GUILayout.EndHorizontal(); } // EditorGUILayout.EndHorizontal(); }
public override void Dispatch(GPUComputeParticleSystem system) { CheckInit(); int count = explosions.Count; if (count > 0) { explosionBuffer.SetData(explosions.ToArray()); shader.SetBuffer(0, "_Explosions", explosionBuffer); shader.SetInt("_ExplosionsCount", count); base.Dispatch(system); explosions.Clear(); } }
protected void Dispatch(int id, GPUComputeParticleSystem system) { shader.SetBuffer(id, _BufferKey, system.ParticleBuffer); shader.Dispatch(id, system.ParticleBuffer.count / _Thread + 1, 1, 1); }
public virtual void Dispatch(GPUComputeParticleSystem system) { Dispatch(dispatchID, system); }