Last active
February 2, 2022 08:12
-
-
Save pexavc/4ca60bd507907f04b23f976a73a3b261 to your computer and use it in GitHub Desktop.
Test webGL shaders from a single html file using GLSL Canvas. Enter the raw shader code into the text box and click submit. A super light-weight alternative to shader toy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta property="og:image" content="https://gateway.ipfs.io/ipfs/QmQt9J74g3daLLG12nTH4VpUMst3Y51uCcSYCgkWbyppSA" /><meta name="description" content="Lightweight shader toy."><title>Marble Shader Toy</title> | |
<meta name="viewport" content="width=device-width"> | |
<meta name="keywords" content="shader, generator"> | |
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |
<meta content="utf-8" http-equiv="encoding"> | |
<style> | |
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400&display=swap'); | |
@import url('https://fonts.googleapis.com/css?family=Playfair+Display:400,400i,700,700i,900,900i'); | |
.container { | |
display: flex; | |
flex-wrap: wrap; | |
justify-content: flex-start; | |
} | |
.containerData { | |
display: flex; | |
justify-content: center; | |
width: 100%; | |
height: 100vh; | |
position: absolute; | |
top: 0; | |
left: 0; | |
z-index: 0; | |
} | |
.codeContainer { | |
display: flex; | |
justify-content: center; | |
width: 100%; | |
height: 100vh; | |
position: absolute; | |
top: 0; | |
left: 0; | |
z-index: 2; | |
overflow: hidden; | |
} | |
#canvas2 { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100vw; | |
height: 100vh; | |
} | |
.slideAnim { | |
animation-name: slide; | |
animation-duration: 2s; | |
animation-fill-mode: forwards; | |
/*New content */ | |
-webkit-animation-fill-mode: forwards; | |
} | |
@keyframes slide { | |
from { | |
opacity: 1.0; | |
} | |
to { | |
opacity: 0.0; | |
} | |
} | |
html, | |
body { | |
margin: 0; | |
padding: 0; | |
width: 100%; | |
height: 100%; | |
overflow: hidden; | |
} | |
</style> | |
<script type="text/javascript"> | |
function compile() { | |
localStorage.clear(); | |
let t = document.getElementById('shaderCode').value; | |
var name = localStorage.getItem("name"); | |
if (name !== null) t = name; | |
let oCT = document.getElementById("canvas2"); | |
oCT.parentNode.removeChild(oCT); | |
let cT = document.getElementById("canvasContainer"); | |
cT.innerHTML = "<canvas id='canvas2' class='glslCanvas' data-fragment='"+t+"' width='631px' height='631px'></canvas>"; | |
localStorage.setItem("name", t); | |
return true; | |
} | |
var index = 0; | |
function refreshScript (src) { | |
console.log(index); | |
var scriptElement = document.createElement('script'); | |
scriptElement.type = 'text/javascript'; | |
scriptElement.src = src + '?' + index++; | |
document.getElementsByTagName('body')[0].prepend(scriptElement); | |
} | |
window.onload = function() { | |
var t = localStorage.getItem("name"); | |
if (t !== null) { | |
let oCT = document.getElementById("canvas2"); | |
oCT.parentNode.removeChild(oCT); | |
let cT = document.getElementById("canvasContainer"); | |
cT.innerHTML = "<canvas id='canvas2' class='glslCanvas' data-fragment='"+t+"' width='631px' height='631px'></canvas>"; | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<script type="text/javascript" src="https://rawgit.com/patriciogonzalezvivo/glslCanvas/master/dist/GlslCanvas.js"> | |
</script> | |
<div class="containerToTHEContainerheh"> | |
<div id="canvasContainer" class="containerData"> | |
<canvas id="canvas2" class="glslCanvas" data-fragment="" width="631px" height="631px"></canvas> | |
</div> | |
<div class="codeContainer"> | |
<form onsubmit="return compile()"> | |
<textarea id="shaderCode" rows="5" cols="60" name="text" placeholder="Enter text"></textarea> | |
<br/> | |
<input type="submit" value="compile"/> | |
</form> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example shader: