Skip to content
Snippets Groups Projects
Verified Commit a17cba00 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Corrected update of deformation with dt

parent a12a9899
No related branches found
No related tags found
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
......@@ -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();
......
......@@ -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,
......
......@@ -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);
}
......
......@@ -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());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment