Skip to content

Commit 69580cf

Browse files
authored
Merge pull request #7411 from RandomGamingDev/additional-sampler-type-support
Added support for other WebGL sampler types
2 parents a722f0e + 360fc04 commit 69580cf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/webgl/p5.Shader.js

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

0 commit comments

Comments
 (0)