UNPKG

p5

Version:

[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)

24 lines (21 loc) • 684 B
//#region src/webgpu/shaders/functions/randomVertWGSL.js var randomVertWGSL_default = ` var<private> _p5_randomCallIndex: i32 = 0; fn _p5_hash(p: vec3<f32>) -> f32 { var p3 = fract(p * vec3<f32>(0.1031, 0.1030, 0.0973)); p3 = p3 + dot(p3, p3.yxz + 33.33); return fract((p3.x + p3.y) * p3.z); } fn random(seed: f32, vertexId: f32) -> f32 { let callIndex = f32(_p5_randomCallIndex); _p5_randomCallIndex = _p5_randomCallIndex + 1; let s = fract(seed * 0.7548776662); return _p5_hash(vec3<f32>( vertexId + s, vertexId * 0.5698402910 + callIndex * 0.6180339887, s + callIndex * 0.7548776662 )); } `; //#endregion export { randomVertWGSL_default as default };