diff --git a/src/math/noise.js b/src/math/noise.js index b1383efdd0..cdca03e858 100644 --- a/src/math/noise.js +++ b/src/math/noise.js @@ -402,6 +402,22 @@ p5.prototype.noiseDetail = function(lod, falloff) { } }; +/** + * @private + * Returns the current number of octaves used by noise(). + */ +p5.prototype._getNoiseOctaves = function() { + return perlin_octaves; +}; + +/** + * @private + * Returns the current falloff factor used by noise(). + */ +p5.prototype._getNoiseAmpFalloff = function() { + return perlin_amp_falloff; +}; + /** * Sets the seed value for the noise() function. * diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js index fa67acc34d..a54404b82b 100644 --- a/src/webgl/p5.RendererGL.js +++ b/src/webgl/p5.RendererGL.js @@ -1819,6 +1819,10 @@ p5.RendererGL = class RendererGL extends p5.Renderer { this._webGL2CompatibilityPrefix('frag', 'highp') + defaultShaders.phongFrag, { + uniforms: { + 'int uNoiseOctaves': () => this._pInst._getNoiseOctaves(), + 'float uNoiseAmpFalloff': () => this._pInst._getNoiseAmpFalloff() + }, vertex: { 'void beforeVertex': '() {}', 'vec3 getLocalPosition': '(vec3 position) { return position; }', @@ -1887,6 +1891,10 @@ p5.RendererGL = class RendererGL extends p5.Renderer { this._webGL2CompatibilityPrefix('frag', 'mediump') + defaultShaders.normalFrag, { + uniforms: { + 'int uNoiseOctaves': () => this._pInst._getNoiseOctaves(), + 'float uNoiseAmpFalloff': () => this._pInst._getNoiseAmpFalloff() + }, vertex: { 'void beforeVertex': '() {}', 'vec3 getLocalPosition': '(vec3 position) { return position; }', @@ -1922,6 +1930,10 @@ p5.RendererGL = class RendererGL extends p5.Renderer { this._webGL2CompatibilityPrefix('frag', 'mediump') + defaultShaders.basicFrag, { + uniforms: { + 'int uNoiseOctaves': () => this._pInst._getNoiseOctaves(), + 'float uNoiseAmpFalloff': () => this._pInst._getNoiseAmpFalloff() + }, vertex: { 'void beforeVertex': '() {}', 'vec3 getLocalPosition': '(vec3 position) { return position; }', @@ -1981,6 +1993,10 @@ p5.RendererGL = class RendererGL extends p5.Renderer { this._webGL2CompatibilityPrefix('frag', 'mediump') + defaultShaders.pointFrag, { + uniforms: { + 'int uNoiseOctaves': () => this._pInst._getNoiseOctaves(), + 'float uNoiseAmpFalloff': () => this._pInst._getNoiseAmpFalloff() + }, vertex: { 'void beforeVertex': '() {}', 'vec3 getLocalPosition': '(vec3 position) { return position; }', @@ -2013,6 +2029,10 @@ p5.RendererGL = class RendererGL extends p5.Renderer { this._webGL2CompatibilityPrefix('frag', 'mediump') + defaultShaders.lineFrag, { + uniforms: { + 'int uNoiseOctaves': () => this._pInst._getNoiseOctaves(), + 'float uNoiseAmpFalloff': () => this._pInst._getNoiseAmpFalloff() + }, vertex: { 'void beforeVertex': '() {}', 'vec3 getLocalPosition': '(vec3 position) { return position; }',