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

Corrected weight to explode less

parent ed3cff98
No related branches found
No related tags found
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
...@@ -41,14 +41,20 @@ float weight_C(float x) { ...@@ -41,14 +41,20 @@ float weight_C(float x) {
} }
} }
vec3 voxel_particle_weight(vec3 voxel, ParticleMinimal particle) { float voxel_particle_weight(vec3 voxel, ParticleMinimal particle) {
if (particle.size <= 0.0f) { if (particle.size <= 0.0f) {
return vec3(0.0f); return 0.0f;
} }
vec3 delta = abs(particle.position - voxel) / particle.size; vec3 delta = abs(particle.position - voxel) / particle.size;
return vec3(weight_C(delta.x), weight_C(delta.y), weight_C(delta.z)); vec3 weight = vec3(
weight_C(delta.x),
weight_C(delta.y),
weight_C(delta.z)
);
return weight.x * weight.y * weight.z;
} }
float grad_weight_A(float x) { float grad_weight_A(float x) {
...@@ -88,12 +94,22 @@ vec3 voxel_particle_grad_weight(vec3 voxel, ParticleMinimal particle) { ...@@ -88,12 +94,22 @@ vec3 voxel_particle_grad_weight(vec3 voxel, ParticleMinimal particle) {
vec3 sign = sign(sign_delta); vec3 sign = sign(sign_delta);
vec3 weight = vec3( vec3 weight = vec3(
weight_C(delta.x),
weight_C(delta.y),
weight_C(delta.z)
);
vec3 grad_weight = vec3(
grad_weight_C(delta.x), grad_weight_C(delta.x),
grad_weight_C(delta.y), grad_weight_C(delta.y),
grad_weight_C(delta.z) grad_weight_C(delta.z)
); ) * sign;
return weight * sign; return vec3(
grad_weight.x * weight.y * weight.z,
grad_weight.y * weight.z * weight.x,
grad_weight.z * weight.x * weight.y
);
} }
#endif // PARTICLE_INC #endif // PARTICLE_INC
\ No newline at end of file
...@@ -39,11 +39,9 @@ void main() { ...@@ -39,11 +39,9 @@ void main() {
memoryBarrierShared(); memoryBarrierShared();
for (uint i = 0; i < SHARED_PARTICLES_BATCH_SIZE; i++) { for (uint i = 0; i < SHARED_PARTICLES_BATCH_SIZE; i++) {
vec3 weight = voxel_particle_weight(position, shared_particles[i]);
gridValue += ( gridValue += (
vec4(shared_particles[i].velocity, shared_particles[i].mass) * vec4(shared_particles[i].velocity, shared_particles[i].mass) *
weight.x * weight.y * weight.z voxel_particle_weight(position, shared_particles[i])
); );
} }
} }
......
...@@ -39,11 +39,10 @@ void main() { ...@@ -39,11 +39,10 @@ void main() {
vec4 gridSample = texture(sampler3D(gridImage, gridSampler), voxel); vec4 gridSample = texture(sampler3D(gridImage, gridSampler), voxel);
vec4 gridOldSample = texture(sampler3D(gridOldImage, gridSampler), voxel); vec4 gridOldSample = texture(sampler3D(gridOldImage, gridSampler), voxel);
vec3 weight = voxel_particle_weight(voxel, minimal); float weight = voxel_particle_weight(voxel, minimal);
float w = (weight.x * weight.y * weight.z);
velocity_pic += gridSample.xyz * w; velocity_pic += gridSample.xyz * weight;
velocity_flip += (gridSample.xyz - gridOldSample.xyz) * w; velocity_flip += (gridSample.xyz - gridOldSample.xyz) * weight;
} }
} }
} }
......
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