This site runs best with JavaScript enabled.

Custom textures for shadertoy

Kevin Beck

July 10, 2021


Simply paste this in to the console to upload your own textures to shadertoy.com in your current session only.

for (let i = 0; i < 4; ++i) {
d = document.createElement('div');
d.className = "upload";
d.innerHTML = '<button onclick="document.querySelector(\'#texture' + i + '>div.upload>div>input\').click()" style="width:100%;">Upload</button>' +
'<div style="display:none;"><input type="file" accept="image/*"/>' +
'<p>#</p></div>';
document.querySelector('#texture' + i).append(d);
document.querySelector('#texture' + i + '>div.upload>div>input').addEventListener('change', function () {
if (this.files && this.files[0]) {
let p = document.querySelector('#texture' + i + '>div.upload>div>p');
URL.revokeObjectURL(p.innerText);
p.innerText = URL.createObjectURL(this.files[0]);
gShaderToy.SetTexture(i, { mSrc: p.innerText, mType: 'texture', mID: 1, mSampler: { filter: 'mipmap', wrap: 'repeat', vflip: 'true', srgb: 'false', internal: 'byte' } });
}
});
}

Source