Skip to content

Commit c524c69

Browse files
added support for other sampler types
1 parent 2e112a4 commit c524c69

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/webgl/p5.Shader.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,39 @@ p5.Shader = class {
13521352
}
13531353
}
13541354
break;
1355+
case gl.SAMPLER_2D:
1356+
case gl.SAMPLER_CUBE:
1357+
case gl.SAMPLER_3D:
1358+
case gl.SAMPLER_2D_SHADOW:
1359+
case gl.SAMPLER_2D_ARRAY:
1360+
case gl.SAMPLER_2D_ARRAY_SHADOW:
1361+
case gl.SAMPLER_CUBE_SHADOW:
1362+
case gl.INT_SAMPLER_2D:
1363+
case gl.INT_SAMPLER_3D:
1364+
case gl.INT_SAMPLER_CUBE:
1365+
case gl.INT_SAMPLER_2D_ARRAY:
1366+
case gl.UNSIGNED_INT_SAMPLER_2D:
1367+
case gl.UNSIGNED_INT_SAMPLER_3D:
1368+
case gl.UNSIGNED_INT_SAMPLER_CUBE:
1369+
case gl.UNSIGNED_INT_SAMPLER_2D_ARRAY:
1370+
if (typeof data !== 'number') {
1371+
break;
1372+
}
1373+
if (
1374+
data < gl.TEXTURE0 ||
1375+
data > gl.TEXTURE31 ||
1376+
data !== Math.ceil(data)
1377+
) {
1378+
console.log(
1379+
'🌸 p5.js says: ' +
1380+
'You\'re trying to use a number as the data for a texture.' +
1381+
'Please use a texture.'
1382+
);
1383+
break;
1384+
}
1385+
gl.activeTexture(data);
1386+
gl.uniform1i(location, data);
1387+
break;
13551388
//@todo complete all types
13561389
}
13571390
return this;

0 commit comments

Comments
 (0)