From d660754a59f60449af5747f8fc9dddc2ef3ff169 Mon Sep 17 00:00:00 2001
From: Tobias Frisch <tfrisch@uni-koblenz.de>
Date: Fri, 4 Feb 2022 20:00:21 +0100
Subject: [PATCH] Simplified calculations

Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de>
---
 .../wobble_bobble/shaders/update_particle_velocities.comp | 8 +++-----
 projects/wobble_bobble/src/main.cpp                       | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/projects/wobble_bobble/shaders/update_particle_velocities.comp b/projects/wobble_bobble/shaders/update_particle_velocities.comp
index 65cb6f7f..1dcf9045 100644
--- a/projects/wobble_bobble/shaders/update_particle_velocities.comp
+++ b/projects/wobble_bobble/shaders/update_particle_velocities.comp
@@ -77,15 +77,13 @@ void main()	{
             float J = determinant(F);
 
             if (J > 0.0f) {
-                float volume = sphere_volume(size) * J;
+                float volume = sphere_volume(size);
 
                 mat3 F_T = transpose(F);
-                mat3 F_T_inv = inverse(F_T);
 
-                mat3 delta = lame2 * (F - F_T_inv) + lame1 * log(J) * F_T_inv;
-                mat3 stress = (1.0f / J) * delta * F_T;
+                mat3 stress = lame2 * (F * F_T - mat3(1.0f)) + lame1 * log(J);
 
-                mls_Q -= dts * volume * D_inv * stress;
+                mls_Q -= dts * volume * stress * D_inv;
             }
 
             affine_C = affine_B * D_inv;
diff --git a/projects/wobble_bobble/src/main.cpp b/projects/wobble_bobble/src/main.cpp
index 492b75cf..557f4dbd 100644
--- a/projects/wobble_bobble/src/main.cpp
+++ b/projects/wobble_bobble/src/main.cpp
@@ -555,7 +555,7 @@ int main(int argc, const char **argv) {
 
 		auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
 		
-		const uint32_t dispatchSizeGrid [3] = { 16, 16, 16 };
+		const uint32_t dispatchSizeGrid [3] = { grid.getWidth() / 4, grid.getHeight() / 4, grid.getDepth() / 4 };
 		const uint32_t dispatchSizeParticles [3] = { static_cast<uint32_t>(particles.getCount() + 63) / 64, 1, 1 };
 		
 		core.recordBeginDebugLabel(cmdStream, "INIT PARTICLE WEIGHTS", { 0.78f, 0.89f, 0.94f, 1.0f });
-- 
GitLab