@@ -104,6 +104,20 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
104104 }
105105 // Add GLSL noise. TODO: Replace this with a backend-agnostic implementation
106106 const originalNoise = fn . noise ;
107+ const originalNoiseDetail = fn . noiseDetail ;
108+
109+ strandsContext . _noiseOctaves = null ;
110+ strandsContext . _noiseAmpFalloff = null ;
111+
112+ fn . noiseDetail = function ( lod , falloff ) {
113+ if ( ! strandsContext . active ) {
114+ return originalNoiseDetail . apply ( this , arguments ) ;
115+ }
116+
117+ strandsContext . _noiseOctaves = lod ;
118+ strandsContext . _noiseAmpFalloff = falloff ;
119+ } ;
120+
107121 fn . noise = function ( ...args ) {
108122 if ( ! strandsContext . active ) {
109123 return originalNoise . apply ( this , args ) ; // fallback to regular p5.js noise
@@ -131,9 +145,20 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
131145 `It looks like you've called noise() with ${ args . length } arguments. It only supports 1D to 3D input.`
132146 ) ;
133147 }
148+
149+ const octaves = strandsContext . _noiseOctaves !== null
150+ ? strandsContext . _noiseOctaves
151+ : fn . _getNoiseOctaves ( ) ;
152+ const falloff = strandsContext . _noiseAmpFalloff !== null
153+ ? strandsContext . _noiseAmpFalloff
154+ : fn . _getNoiseAmpFalloff ( ) ;
155+
156+ nodeArgs . push ( octaves ) ;
157+ nodeArgs . push ( falloff ) ;
158+
134159 const { id, dimension } = build . functionCallNode ( strandsContext , 'noise' , nodeArgs , {
135160 overloads : [ {
136- params : [ DataType . float3 ] ,
161+ params : [ DataType . float3 , DataType . int1 , DataType . float1 ] ,
137162 returnType : DataType . float1 ,
138163 } ]
139164 } ) ;
0 commit comments