From a50a807939a6d4150f6770dae22401ca480f8176 Mon Sep 17 00:00:00 2001 From: SpoodyTheOne Date: Sun, 4 Feb 2024 00:48:43 +0100 Subject: [PATCH] Better blood and fixed upgrades --- Assets/Scripts/BloodComputeShader.cs | 6 ++++-- Assets/Scripts/ComputeShaders/BloodCompute.compute | 5 ++++- Assets/Scripts/Upgrader.cs | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/BloodComputeShader.cs b/Assets/Scripts/BloodComputeShader.cs index f7a03b1..73bfad3 100644 --- a/Assets/Scripts/BloodComputeShader.cs +++ b/Assets/Scripts/BloodComputeShader.cs @@ -260,11 +260,13 @@ public class BloodComputeShader : MonoBehaviour // Test for race conditions // yield return new WaitForSeconds(1.0f); - bloodCompute.SetFloat("particleVel", power); + bloodCompute.SetFloat("particleVel", power/4.0f); bloodCompute.SetVector("particleInitPos", loc); bloodCompute.SetInt("particlesToInitialize", found); - bloodCompute.SetVector("initialVelocity",Random.insideUnitCircle * power); + Vector3 pow = Random.insideUnitSphere * power; + pow.z = Mathf.Abs(pow.z); + bloodCompute.SetVector("initialVelocity",pow); ComputeHelper.Dispatch(bloodCompute, amount, 1, 1, InitDustKernel); diff --git a/Assets/Scripts/ComputeShaders/BloodCompute.compute b/Assets/Scripts/ComputeShaders/BloodCompute.compute index 91ef7fc..b6dd556 100644 --- a/Assets/Scripts/ComputeShaders/BloodCompute.compute +++ b/Assets/Scripts/ComputeShaders/BloodCompute.compute @@ -80,8 +80,11 @@ void InitDust (uint3 id : SV_DispatchThreadID) randState = hash(randState); nvel.xy *= scaleToRange01(randState); + + randState = hash(randState); + float3 iv = initialVelocity * scaleToRange01(randState); - particles[i].velocity = initialVelocity + nvel; + particles[i].velocity = iv + nvel; particles[i].position = particleInitPos; particles[i].position.z = 0.01; diff --git a/Assets/Scripts/Upgrader.cs b/Assets/Scripts/Upgrader.cs index d32c783..5d30aad 100644 --- a/Assets/Scripts/Upgrader.cs +++ b/Assets/Scripts/Upgrader.cs @@ -108,6 +108,8 @@ public class Upgrader : MonoBehaviour // Update is called once per frame void Update() { + bool upgrade = canUpgrade(); + if (canUpgrade()) { @@ -205,7 +207,7 @@ public class Upgrader : MonoBehaviour Player1Cursor.localPosition = Player1Input.look.normalized * (125 - 12); Player2Cursor.localPosition = Player2Input.look.normalized * (125 - 12); - prevCouldUpgrade = canUpgrade(); + prevCouldUpgrade = upgrade; } /// Increases mop radius by 10%