|
107 | 107 |
|
108 | 108 | const float SPEED_LIMIT = 9.0; |
109 | 109 |
|
110 | | - float rand(vec2 co){ |
111 | | - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); |
| 110 | + float rand( vec2 co ){ |
| 111 | + return fract( sin( dot( co.xy, vec2(12.9898,78.233) ) ) * 43758.5453 ); |
112 | 112 | } |
113 | 113 |
|
114 | 114 | void main() { |
|
150 | 150 |
|
151 | 151 |
|
152 | 152 | // move birds away from predator |
153 | | - if (dist < preyRadius) { |
| 153 | + if ( dist < preyRadius ) { |
154 | 154 |
|
155 | 155 | f = ( distSquared / preyRadiusSq - 1.0 ) * delta * 100.; |
156 | 156 | velocity += normalize( dir ) * f; |
|
170 | 170 | dir.y *= 2.5; |
171 | 171 | velocity -= normalize( dir ) * delta * 5.; |
172 | 172 |
|
173 | | - for (float y=0.0;y<height;y++) { |
174 | | - for (float x=0.0;x<width;x++) { |
| 173 | + for ( float y = 0.0; y < height; y++ ) { |
| 174 | + for ( float x = 0.0; x < width; x++ ) { |
175 | 175 |
|
176 | 176 | vec2 ref = vec2( x + 0.5, y + 0.5 ) / resolution.xy; |
177 | 177 | birdPosition = texture2D( texturePosition, ref ).xyz; |
178 | 178 |
|
179 | 179 | dir = birdPosition - selfPosition; |
180 | | - dist = length(dir); |
| 180 | + dist = length( dir ); |
181 | 181 |
|
182 | | - if (dist < 0.0001) continue; |
| 182 | + if ( dist < 0.0001 ) continue; |
183 | 183 |
|
184 | 184 | distSquared = dist * dist; |
185 | 185 |
|
186 | | - if (distSquared > zoneRadiusSquared ) continue; |
| 186 | + if ( distSquared > zoneRadiusSquared ) continue; |
187 | 187 |
|
188 | 188 | percent = distSquared / zoneRadiusSquared; |
189 | 189 |
|
190 | 190 | if ( percent < separationThresh ) { // low |
191 | 191 |
|
192 | 192 | // Separation - Move apart for comfort |
193 | | - f = (separationThresh / percent - 1.0) * delta; |
194 | | - velocity -= normalize(dir) * f; |
| 193 | + f = ( separationThresh / percent - 1.0 ) * delta; |
| 194 | + velocity -= normalize( dir ) * f; |
195 | 195 |
|
196 | 196 | } else if ( percent < alignmentThresh ) { // high |
197 | 197 |
|
|
202 | 202 | birdVelocity = texture2D( textureVelocity, ref ).xyz; |
203 | 203 |
|
204 | 204 | f = ( 0.5 - cos( adjustedPercent * PI_2 ) * 0.5 + 0.5 ) * delta; |
205 | | - velocity += normalize(birdVelocity) * f; |
| 205 | + velocity += normalize( birdVelocity ) * f; |
206 | 206 |
|
207 | 207 | } else { |
208 | 208 |
|
|
212 | 212 |
|
213 | 213 | f = ( 0.5 - ( cos( adjustedPercent * PI_2 ) * -0.5 + 0.5 ) ) * delta; |
214 | 214 |
|
215 | | - velocity += normalize(dir) * f; |
| 215 | + velocity += normalize( dir ) * f; |
216 | 216 |
|
217 | 217 | } |
218 | 218 |
|
|
0 commit comments