public override void Dispatch(GPUParticleSystem system) { shader.SetFloat("_Time", ticker); shader.SetFloat("_Scale", scale); shader.SetFloat("_Intensity", intensity); base.Dispatch(system); }
public override void Render(GPUParticleSystem system) { material.SetFloat("_Count", system.Count); float side = Mathf.Sqrt(system.Count); material.SetFloat("_Side", side); material.SetFloat("_Unit", 1f / side); material.SetFloat("_Size", system.Size); var offset = offsets[current % offsets.Count]; material.SetVector("_Center", new Vector3(0f, offset, Camera.main.transform.position.z + distance)); var position = system.GetProp("_Position"); var rotation = system.GetProp("_Rotation"); if (position != null && rotation != null) { material.SetTexture(position.Key, position.FBO.ReadTex); Blit(position.FBO, material, 0); material.SetTexture(rotation.Key, rotation.FBO.ReadTex); Blit(rotation.FBO, material, 1); } }
public override void Render(GPUParticleSystem system) { var d = data[index % data.Count]; texture = d.texture; material.SetTexture("_MainTex", texture); var ratio = 1f * texture.width / texture.height; var scale = 1f / d.scale; material.SetFloat("_Ratio", ratio); material.SetFloat("_Scale", scale); material.SetVector("_Offset", new Vector2((1f - scale) * 0.5f, (1f - scale * ratio) * 0.5f)); material.SetFloat("_Count", system.Count); material.SetFloat("_Side", Mathf.Sqrt(system.Count)); material.SetFloat("_Size", system.Size); material.SetFloat("_Depth", Camera.main.transform.position.z + distance); var position = system.GetProp("_Position"); var rotation = system.GetProp("_Rotation"); var color = system.GetProp("_Color"); material.SetTexture(position.Key, position.FBO.ReadTex); Blit(position.FBO, material, 0); material.SetTexture(rotation.Key, rotation.FBO.ReadTex); Blit(rotation.FBO, material, 1); material.SetTexture(color.Key, color.FBO.ReadTex); Blit(color.FBO, material, 2); }
void Setup(GPUParticleSystem system) { var buffer = system.ParticleBuffer; GPUParticle[] particles = new GPUParticle[buffer.count]; buffer.GetData(particles); var count = particles.Length; bounds = new List <GPUBound>(); Bintree(Vector3.zero, Vector3.one, depth); boundsBuffer = new ComputeBuffer(bounds.Count, Marshal.SizeOf(typeof(GPUBound_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 Render(GPUParticleSystem system) { material.SetFloat("_Speed", speed); material.SetFloat("_Count", system.Count); if (side < 0f) { side = Mathf.Pow(system.Count, 1f / 3f); material.SetVector("_Side", new Vector2(side, 1f / side)); // offset = Vector3.one * (side * 0.5f); offset = Vector3.one * (side * 0.5f) + new Vector3(Random.Range(-0.25f, 0.25f) * side, Random.Range(-0.25f, 0.25f) * side, Random.Range(-0.25f, 0.25f) * side); int len = Mathf.FloorToInt(side); flags = new bool[len, len, len]; SetFlag(offset, true); } material.SetFloat("_Size", system.Size); material.SetVector("_Offset", -(offset + new Vector3(0f, 0f, depth + side * 0.25f))); var position = system.GetProp("_Position"); var rotation = system.GetProp("_Rotation"); material.SetTexture(position.Key, position.FBO.ReadTex); material.SetTexture(rotation.Key, rotation.FBO.ReadTex); Blit(position.FBO, material, 0); Blit(rotation.FBO, material, 1); }
public override void Render(GPUParticleSystem system) { var velocity = system.GetProp("_Velocity"); material.SetTexture(velocity.Key, velocity.FBO.ReadTex); material.SetFloat("_T", t); Blit(velocity.FBO, material); }
public override void Render(GPUParticleSystem system) { var buffer = system.GetProp("_Color"); material.SetTexture(buffer.Key, buffer.FBO.ReadTex); material.SetColor("_Color", color); Blit(buffer.FBO, material, 0); }
public override void Dispatch(GPUParticleSystem system) { shader.SetVector("_Force", force); shader.SetVector("_Seed", seed); shader.SetFloat("_DT", Time.deltaTime); shader.SetFloat("_LifetimeSpeed", lifetimeSpeed); shader.SetVector("_EmissionCenter", emissionArea.center); shader.SetVector("_EmissionSize", emissionArea.size * 0.5f); base.Dispatch(system); }
public override void Dispatch(GPUParticleSystem system) { if (stateBuffer == null) { Setup(system.ParticleBuffer); } shader.SetFloat("_DT", Time.deltaTime * speed); shader.SetFloat("_Scale", scale); base.Dispatch(system); }
public override void Render(GPUParticleSystem system) { var velocity = system.GetProp("_Velocity"); var position = system.GetProp("_Position"); if (velocity != null && position != null) { material.SetTexture(velocity.Key, velocity.FBO.ReadTex); material.SetTexture(position.Key, position.FBO.ReadTex); Blit(position.FBO, material); } }
public override void Dispatch(GPUParticleSystem 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(GPUParticleSystem system) { if (boundsBuffer == null) { Setup(system); } UpdateBounds(); shader.SetBuffer(dispatchID, "_Bounds", boundsBuffer); shader.SetFloat("_T", (mode == ExtrusionMode.Physics) ? 1f : t); base.Dispatch(system); }
public override void Dispatch(GPUParticleSystem system) { if (fromBuffer == null) { Setup(system.ParticleBuffer); Animate(); } if (fromBuffer != null) { shader.SetFloat("_T", t); base.Dispatch(system); } }
public override void Dispatch(GPUParticleSystem 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(); } }
public override void Render(GPUParticleSystem system) { material.SetFloat("_Count", system.Count); material.SetFloat("_Side", Mathf.Sqrt(system.Count)); material.SetFloat("_Size", system.Size); material.SetVector("_Offset", offset); material.SetFloat("_Depth", Camera.main.transform.position.z + distance); var position = system.GetProp("_Position"); var rotation = system.GetProp("_Rotation"); material.SetTexture(position.Key, position.FBO.ReadTex); material.SetTexture(rotation.Key, rotation.FBO.ReadTex); Blit(position.FBO, material, 0); Blit(rotation.FBO, material, 1); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GPUParticleSystem system = target as GPUParticleSystem; EditorGUILayout.LabelField("Sort GPUParticleUpdaters"); 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(); } }
public override void Render(GPUParticleSystem system) { int side = Mathf.FloorToInt(Mathf.Sqrt(system.Count)); CheckInit(side, side); var position = system.GetProp("_Position"); var velocity = system.GetProp("_Velocity"); var color = system.GetProp("_Color"); material.SetTexture(position.Key, position.FBO.ReadTex); material.SetTexture(velocity.Key, velocity.FBO.ReadTex); material.SetTexture(color.Key, color.FBO.ReadTex); var matrix = transform.localToWorldMatrix; material.SetMatrix("_Matrix", matrix); Blit(velocity.FBO, material, 0); Blit(color.FBO, material, 1); }
public override void Init(GPUParticleSystem system) { var position = system.GetProp("_Position"); if (position != null) { Blit(position.FBO, material, 0); } var velocity = system.GetProp("_Velocity"); if (velocity != null) { Blit(velocity.FBO, material, 1); } var color = system.GetProp("_Color"); if (color != null) { Blit(color.FBO, material, 2); } }
protected void Dispatch(int id, GPUParticleSystem system) { shader.SetBuffer(id, _BufferKey, system.ParticleBuffer); shader.Dispatch(id, system.ParticleBuffer.count / _Thread + 1, 1, 1); }
public virtual void Dispatch(GPUParticleSystem system) { Dispatch(dispatchID, system); }
public override void Dispatch(GPUParticleSystem system) { shader.SetFloat("_Time", ticker); base.Dispatch(system); }
public virtual void Init(GPUParticleSystem system) { }
public virtual void Render(GPUParticleSystem system) { }
public override void Dispatch(GPUParticleSystem system) { shader.SetVector("_GravityDirection", system.transform.InverseTransformDirection(direction)); shader.SetFloat("_Gravity", gravity); base.Dispatch(system); }