Closed
Description
Documentation request:
What documentation needs to change?
In the compute shader example there is the following code:
vec2 diff = p.xy - In.balls[i].pos.xyzw.xy;
// We should normalize this I think, but it doesn't work.
// diff = normalize(diff);
vec2 delta_v = diff * force;
v.xy += delta_v;
What is wrong with it? How can it be improved?
The formula is incorrect and therefore so is the simulation, as noted in the comments the normalize function doesn't work. This is because the minimum distance isn't being considered in the normalization of the vector. A simple solution would be to replace the normalization with something like the following:
vec2 diff = p.xy - In.balls[i].pos.xyzw.xy;
vec2 direction = diff / (dist + minDistance);
vec2 delta_v = direction * force;
v.xy += delta_v;
This should fix the issue with normalize and also allow the simulation to run using the correct gravity formula.
Metadata
Metadata
Assignees
Labels
No labels