Skip to content

Commit cae7687

Browse files
Simplify wind handling
1 parent 353f98b commit cae7687

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

project01/shader/cloth_cs.glsl

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ uniform float RestLengthVert;
1111
uniform float RestLengthDiag;
1212
uniform float DeltaT = 0.000005;
1313
uniform float DampingConst = 0.1;
14-
uniform bool HasWind = true;
15-
uniform float WindStrength = 2;
16-
uniform vec3 WindDir = vec3(4, 0, 2);
14+
uniform float HasWind = 1.0;
15+
uniform float WindStrength = 3;
16+
uniform vec3 WindDir = vec3(0.6, 0, 0.3);
1717

1818
layout(std430, binding=0) buffer PosIn {
1919
vec4 PositionIn[];
@@ -27,9 +27,6 @@ layout(std430, binding=2) buffer VelIn {
2727
layout(std430, binding=3) buffer VelOut {
2828
vec4 VelocityOut[];
2929
};
30-
layout(std430, binding=4) buffer NormIn {
31-
vec4 Normal[];
32-
};
3330

3431
void main() {
3532
uvec3 nParticles = gl_NumWorkGroups * gl_WorkGroupSize;
@@ -86,18 +83,7 @@ void main() {
8683
}
8784

8885
force += -DampingConst * v;
89-
90-
if (HasWind)
91-
{
92-
vec3 normalized_wind_dir;
93-
if (WindDir == vec3(0.0f, 0.0f, 0.0f))
94-
normalized_wind_dir = glm::vec3(0.0f, 0.0f, 0.0f);
95-
else
96-
normalized_wind_dir = normalize(WindDir);
97-
98-
vec3 f_wind = WindStrength * dot(Normal[idx].xyz, normalized_wind_dir) * Normal[idx].xyz;
99-
force += f_wind;
100-
}
86+
force += WindStrength * WindDir * HasWind;
10187

10288
// Apply simple Euler integrator
10389
vec3 a = force * ParticleInvMass;

0 commit comments

Comments
 (0)