public float CellNoise(float X,float Y,float Jitter){ Float2 P = new Float2(X,Y); Float2 Pi = floor(P,true); Float2 Pf = P.Sub(Pi); Float4 HashX, HashY; FastHash2D(Pi,out HashX,out HashY); HashX = (CellularWeightSamples(HashX).Mul(Jitter)).Add(0,1,0,1); HashY = (CellularWeightSamples(HashY).Mul(Jitter)).Add(0,0,1,1); Float4 dx = Pf.xxxx.Sub(HashX); Float4 dy = Pf.yyyy.Sub(HashY); Float4 d = dx.Square()+dy.Square(); d.xy = min(d.xy,d.zw,false); return min(d.x,d.y,false).Mul(1.0f/1.125f); }
public Float2 frac(Float2 s,bool SpawnNew){ if (SpawnNew) return s-floor(s,true); else return s.Sub(floor(s,true)); }