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

Remove inverse matrix and precalculate impulse

parent 67cdbde2
No related branches found
No related tags found
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
......@@ -28,16 +28,21 @@ void main() {
if (localOffset < particles.length()) {
shared_particles[gl_LocalInvocationIndex] = particles[localOffset].minimal;
vec3 distance = (position - shared_particles[gl_LocalInvocationIndex].position);
shared_particles[gl_LocalInvocationIndex].velocity += (
mat3(particles[localOffset].mls) * distance
shared_particles[gl_LocalInvocationIndex].pad = (
mat3(particles[localOffset].mls) *
(position - shared_particles[gl_LocalInvocationIndex].position)
) + (
shared_particles[gl_LocalInvocationIndex].velocity *
shared_particles[gl_LocalInvocationIndex].mass
);
} else {
shared_particles[gl_LocalInvocationIndex].position = vec3(0.0f);
shared_particles[gl_LocalInvocationIndex].size = 0.0f;
shared_particles[gl_LocalInvocationIndex].velocity = vec3(0.0f);
shared_particles[gl_LocalInvocationIndex].mass = 0.0f;
shared_particles[gl_LocalInvocationIndex].pad = vec3(0.0f);
shared_particles[gl_LocalInvocationIndex].weight_sum = 1.0f;
}
barrier();
......@@ -45,11 +50,10 @@ void main() {
for (uint i = 0; i < SHARED_PARTICLES_BATCH_SIZE; i++) {
float weight = voxel_particle_weight(position, shared_particles[i]);
float mass = shared_particles[i].mass * weight;
gridValue += vec4(
shared_particles[i].velocity * mass,
mass
shared_particles[i].pad * weight,
shared_particles[i].mass * weight
);
}
......
......@@ -81,15 +81,14 @@ void main() {
if ((J > 0.0f) && (mass > 0.0f)) {
mat3 F_T = transpose(F);
mat3 F_invT = inverse(F_T);
mat3 delta = lame2 * (F - F_invT) + lame1 * log(J) * F_invT;
mat3 delta = lame2 * (F * F_T - mat3(1.0f)) + lame1 * log(J);
//mls_Q += beta * dt * volume * particle.minimal.weight_sum * delta * F_T * D_inv / mass;
mls_Q += beta * dt * volume * delta * D_inv;
}
affine_C = affine_B * D_inv;
mls_Q += beta * affine_C;
mls_Q += beta * affine_C * mass;
}
F = (mat3(1.0f) + dt * affine_C) * F;
......
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