M Physarum.xcodeproj/project.xcworkspace/xcuserdata/connorbell.xcuserdatad/UserInterfaceState.xcuserstate => Physarum.xcodeproj/project.xcworkspace/xcuserdata/connorbell.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
M Physarum/Metal/Includes/noise.h => Physarum/Metal/Includes/noise.h +1 -0
@@ 9,5 9,6 @@
#define noise_h
float3 curl(float3 pos);
+float random(float n);
#endif /* noise_h */
M Physarum/Metal/Includes/noise.metal => Physarum/Metal/Includes/noise.metal +4 -0
@@ 10,6 10,10 @@
using namespace metal;
+float random(float n) {
+ return fract(sin(n) * 43758.5453123);
+}
+
float4 permute(float4 x){return mod(((x*34.0)+1.0)*x, 289.0);}
float4 taylorInvSqrt(float4 r){return 1.79284291400159 - 0.85373472095314 * r;}
M Physarum/Metal/Shaders.metal => Physarum/Metal/Shaders.metal +3 -6
@@ 9,13 9,10 @@
#include "Includes/Particle.h"
#include "Includes/SimParameters.h"
#include "Includes/TexturePassParameters.h"
+#include "Includes/noise.h"
using namespace metal;
-float randomOk(float n) {
- return fract(sin(n) * 43758.5453123);
-}
-
float3 hueShift(float3 color, float hue) {
const float3 k = float3(0.57735, 0.57735, 0.57735);
float cosAngle = cos(hue);
@@ 32,7 29,7 @@ kernel void setupParticles(device Particle *particles [[buffer(0)]],
p.active = 0;
p.position = float2(width/2.0,height/2.0) + (float2(cos(id*0.00235), sin(id*0.0059022))*(250+100));
- p.sensorHeading = randomOk(id*0.034) * 6.28318;
+ p.sensorHeading = random(id*0.034) * 6.28318;
particles[id] = p;
}
@@ 58,7 55,7 @@ kernel void addParticles(device Particle *particles [[buffer(0)]],
}
particle.position = pos;
- particle.sensorHeading = -1.5 + 3.14159 + startupProgress*3.14159*3.5 + randomOk(id*0.104) ;
+ particle.sensorHeading = -1.5 + 3.14159 + startupProgress*3.14159*3.5 + random(id*0.104) ;
particles[index] = particle;
}
M Physarum/Metal/SimulationKernel.metal => Physarum/Metal/SimulationKernel.metal +1 -4
@@ 10,13 10,10 @@
#include "Includes/Particle.h"
#include "Includes/SimParameters.h"
#include "Includes/mod.h"
+#include "Includes/noise.h"
using namespace metal;
-float random(float n) {
- return fract(sin(n) * 3629135.423193);
-}
-
// Write a 9x9 pixel area around the grid id with color, blended with the previous color
void writePixelWithBlendedColor(float4 color,
uint2 gid,