diff --git a/projects/wobble_bobble/shaders/init_particle_volumes.comp b/projects/wobble_bobble/shaders/init_particle_volumes.comp index 9fde7700cefeb89e880426632e5c0edf01265986..8ab9f05babe183a460610b4171992843927da4be 100644 --- a/projects/wobble_bobble/shaders/init_particle_volumes.comp +++ b/projects/wobble_bobble/shaders/init_particle_volumes.comp @@ -43,10 +43,14 @@ void main() { } if (volume > 0.0f) { + float density = minimal.mass / volume; + //volume = minimal.mass / (mass / volume); + mass = density * volume; } particles[gl_GlobalInvocationID.x].minimal.size = sphere_radius(volume); + particles[gl_GlobalInvocationID.x].minimal.mass = mass; } memoryBarrierBuffer(); diff --git a/projects/wobble_bobble/shaders/particle.inc b/projects/wobble_bobble/shaders/particle.inc index 65580262b5b5afdfb3e10a1f3e250dc1e49b18df..06608c2b35398becf45400201ac9f7c9d7024512 100644 --- a/projects/wobble_bobble/shaders/particle.inc +++ b/projects/wobble_bobble/shaders/particle.inc @@ -113,7 +113,7 @@ vec3 voxel_particle_grad_weight(vec3 voxel, ParticleMinimal particle) { grad_weight_C(delta.x), grad_weight_C(delta.y), grad_weight_C(delta.z) - ) * sign; + ) * sign / particle.size; return vec3( grad_weight.x * weight.y * weight.z, diff --git a/projects/wobble_bobble/shaders/update_particle_deformation.comp b/projects/wobble_bobble/shaders/update_particle_deformation.comp index 8cd2aabe439764d4572502667d3f587d2f8726e5..3cf9d2b9385de55f57f3f37feee3e0fbd8d77844 100644 --- a/projects/wobble_bobble/shaders/update_particle_deformation.comp +++ b/projects/wobble_bobble/shaders/update_particle_deformation.comp @@ -12,6 +12,13 @@ layout(set=0, binding=0, std430) buffer particleBuffer { layout(set=0, binding=1) uniform texture3D gridImage; layout(set=0, binding=2) uniform sampler gridSampler; +layout( push_constant ) uniform constants { + float K; + float E; + float t; + float dt; +}; + void main() { memoryBarrierBuffer(); memoryBarrierImage(); @@ -45,7 +52,11 @@ void main() { } } - mat3 deformation_elastic = (mat3(1.0f) + velocity_gradient) * deformation; + mat3 deformation_elastic = deformation; + + if (dt > 0.0f) { + deformation_elastic = (mat3(1.0f) + dt * velocity_gradient) * deformation; + } particles[gl_GlobalInvocationID.x].deformation = mat4(deformation_elastic); } diff --git a/projects/wobble_bobble/src/main.cpp b/projects/wobble_bobble/src/main.cpp index 8b0a016b0c83d6a3769e2bd068f19f0d4e7da27a..02096dbadb06837dae589f3e504ac8fd52925a22 100644 --- a/projects/wobble_bobble/src/main.cpp +++ b/projects/wobble_bobble/src/main.cpp @@ -688,7 +688,7 @@ int main(int argc, const char **argv) { { vkcv::DescriptorSetUsage( 0, core.getDescriptorSet(updateParticleDeformationSets[0]).vulkanHandle ) }, - vkcv::PushConstants(0) + physicsPushConstants ); core.recordBufferMemoryBarrier(cmdStream, particles.getHandle());