Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float px;
- float py;
- float r;
- float a;
- float sbaIndex;
- float aaIndex;
- float diff;
- float sval;
- float springForce;
- //params
- float dampingFactor = 1-Parameters[6]*Parameters[6];
- float sampleSize = sqrt(Parameters[8]);
- float attackThreshold = Parameters[7]*Parameters[7]*Parameters[7];
- currentModel.colorThreshold = Parameters[12]*3;
- for(float x=0; x<64; x++){ //For every particle
- for(float y=0; y<64; y++){
- if(Particles[x, y, 3] > 0 && Particles[x, y, 0] + Particles[x, y, 1] + Particles[x, y, 2] >= currentModel.colorThreshold){
- //Read Particle props
- px = Particles[x,y,4];
- py = Particles[x,y,5];
- r = Particles[x,y,10];
- a = Particles[x,y,13];
- //get index of for SprecBandAray depending on radius
- sbaIndex = Parameters[2] + r*(Parameters[3] - Parameters[2])*2;
- sbaIndex = floor(sbaIndex*SpecBandArray.SizeDim1);
- sbaIndex = clamp(sbaIndex, 0, SpecBandArray.SizeDim1-1);
- //get index of wave array depending on angle and sample size param
- aaIndex = a*AudioArray.SizeDim1*sampleSize;
- aaIndex = clamp(aaIndex ,0,AudioArray.SizeDim1-1);
- //Derive spectral movement (current - previous)
- diff = clamp(SpecBandArray[sbaIndex],0,1) - clamp(SpecBandArray_Prev[sbaIndex],0,1);
- //radial force
- sval = AudioArray[aaIndex]*Parameters[1];
- //apply to velocity
- if(diff > attackThreshold){
- Particles[x,y,9] += diff*Parameters[0]*3;
- }
- Particles[x,y,7] += sval*px;
- Particles[x,y,8] += sval*py;
- //spring force
- springForce = (Parameters[4] + r*(Parameters[5] - Parameters[4])*2)*4;
- Particles[x,y,7] -= (Particles[x,y,4] - Particles[x,y,11])*springForce;
- Particles[x,y,8] -= (Particles[x,y,5] - Particles[x,y,12])*springForce;
- Particles[x,y,9] -= Particles[x,y,6]*springForce;
- //Damping
- Particles[x,y,7] *= dampingFactor;
- Particles[x,y,8] *= dampingFactor;
- Particles[x,y,9] *= dampingFactor;
- //Update Position (integrate velocity)
- Particles[x,y,4] += Particles[x,y,7];
- Particles[x,y,5] += Particles[x,y,8];
- Particles[x,y,6] += Particles[x,y,9];
- }
- }
- }
- //prepare next derivation cycle
- for(float i=0; i<SpecBandArray.SizeDim1; i++){
- SpecBandArray_Prev[i] = SpecBandArray[i];
- }
- //zoom
- Cam.Position.Z = (1-Parameters[10])*2;
- Cam.Position.Z = Cam.Position.Z*Cam.Position.Z;
- //Illumination
- currentModel.illuminationFactor = 100*Parameters[13]*Parameters[13];
- //Rotate
- ParticlesTransform.Rotate.Z += (Parameters[11]-0.5)*(Parameters[11]-0.5)*0.1;
- //set pixel size
- currentModel.pixelSize = App.ViewportHeight/16*Parameters[15];
- if(currentModel.pixelSize < 1) currentModel.pixelSize = 1;
- //view angle
- currentModel.Rotation.X = 1-Parameters[9];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement