From c524c6973ad356391d9d71e4b3aa6f469487a6b5 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Fri, 6 Dec 2024 05:52:07 -0500 Subject: [PATCH 1/3] added support for other sampler types --- src/webgl/p5.Shader.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/webgl/p5.Shader.js b/src/webgl/p5.Shader.js index daa13b3899..d557a265ad 100644 --- a/src/webgl/p5.Shader.js +++ b/src/webgl/p5.Shader.js @@ -1352,6 +1352,39 @@ p5.Shader = class { } } break; + case gl.SAMPLER_2D: + case gl.SAMPLER_CUBE: + case gl.SAMPLER_3D: + case gl.SAMPLER_2D_SHADOW: + case gl.SAMPLER_2D_ARRAY: + case gl.SAMPLER_2D_ARRAY_SHADOW: + case gl.SAMPLER_CUBE_SHADOW: + case gl.INT_SAMPLER_2D: + case gl.INT_SAMPLER_3D: + case gl.INT_SAMPLER_CUBE: + case gl.INT_SAMPLER_2D_ARRAY: + case gl.UNSIGNED_INT_SAMPLER_2D: + case gl.UNSIGNED_INT_SAMPLER_3D: + case gl.UNSIGNED_INT_SAMPLER_CUBE: + case gl.UNSIGNED_INT_SAMPLER_2D_ARRAY: + if (typeof data !== 'number') { + break; + } + if ( + data < gl.TEXTURE0 || + data > gl.TEXTURE31 || + data !== Math.ceil(data) + ) { + console.log( + '🌸 p5.js says: ' + + 'You\'re trying to use a number as the data for a texture.' + + 'Please use a texture.' + ); + break; + } + gl.activeTexture(data); + gl.uniform1i(location, data); + break; //@todo complete all types } return this; From 14b318370cad9b7377780b3fbec8ec8e54ff59c2 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Fri, 6 Dec 2024 06:06:21 -0500 Subject: [PATCH 2/3] removed forgotten double pasted label --- src/webgl/p5.Shader.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/webgl/p5.Shader.js b/src/webgl/p5.Shader.js index d557a265ad..8c84821d4f 100644 --- a/src/webgl/p5.Shader.js +++ b/src/webgl/p5.Shader.js @@ -1352,7 +1352,6 @@ p5.Shader = class { } } break; - case gl.SAMPLER_2D: case gl.SAMPLER_CUBE: case gl.SAMPLER_3D: case gl.SAMPLER_2D_SHADOW: From 360fc04f27493b9c98d1def70441213d52d42c74 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Fri, 6 Dec 2024 06:08:11 -0500 Subject: [PATCH 3/3] removed trailing space --- src/webgl/p5.Shader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webgl/p5.Shader.js b/src/webgl/p5.Shader.js index 8c84821d4f..b620e84bb4 100644 --- a/src/webgl/p5.Shader.js +++ b/src/webgl/p5.Shader.js @@ -1352,7 +1352,7 @@ p5.Shader = class { } } break; - case gl.SAMPLER_CUBE: + case gl.SAMPLER_CUBE: case gl.SAMPLER_3D: case gl.SAMPLER_2D_SHADOW: case gl.SAMPLER_2D_ARRAY: