Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <script id="vertexShader" type="x-shader/x-vertex">
varying vec2 vUv;
void main()
    vUv = uv;
    gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
<script id="fragmentShader" type="x-shader/x-fragment">
#ifdef GL_ES
precision highp float;

uniform float time;
uniform sampler2D texture;
varying vec2 vUv;

void main( void ) {
  gl_FragColor = vec4(
    texture2D(texture, vec2(vUv.x, 0.5 + vUv.y/2.)).rgb,
    texture2D(texture, vec2(vUv.x, vUv.y/2.)).r
<video id="video" autoplay muted loop playsinline crossorigin="anonymous">
  <source src="" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
<div id="demo-wrapper">
  <div id="container"></div>
  <p class="editable-text text-behind" contenteditable="true">the video is an MP4, but is transparent thanks to WebGL</p>
  <p class="editable-text text-front" contenteditable="true"><strong>Update:</strong> Autoplay may no longer work; click "play" in the bar below</p>
<div id="info">Transparent Video GLSL shader - with <a href="" target="_blank">three.js</a>
<div id="controls">
  <label for="resolution">resolution: </label>
  <select id="resolution" value="2">
    <option value="0.5">0.5x</option>
    <option value="1" selected>1x</option>
    <option value="2">2x</option>
    <option value="4">4x</option>
    <option value="8">8x</option>
  <label for="play-button">video controls: </label>
  <button id="play-button">Play</button>
  <button id="stop-button">Stop</button>


                body {
  width: 100%;
  height: 100vh;
  color: #ffffff;
  font-family: Monospace;
  font-size: 13px;
  text-align: center;
  font-weight: bold;
  margin: 0px;
  overflow: hidden;
  background: url( center center no-repeat;
  background-size: cover;
#video {
  display: none;
  // position: absolute;
  // right: 0;
  // top: 0;
  // transform-origin: 100% 0%;
  // transform: scale(0.2);
#container {
  pointer-events: none;
  z-index: 5;
  position: absolute;
  left: 50%;
  top: 0;
  width: 100vh;
  height: 100vh;
  transform: translateX(-50%);
#demo-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100vh;
.editable-text {
  position: relative;
  padding: 0.5em 1em;
  margin: 0;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 8vh;
  font-weight: 300;
  letter-spacing: 0.07em;
  color: #fff;
  text-align: center;
  text-shadow: 2px 5px 20px rgba(#000000, 0.6);
  &.text-behind {
    z-index: 1;
  &.text-front {
    z-index: 10;
#info, #controls {
  z-index: 100;
  position: absolute;
  width: 100%;
  padding: 5px;
  background: rgba(#000,0.4);
#info { top: 0; }
#controls { bottom: 0; }
a {
  color: #ffffff;
  transition: 150ms all;
  &:hover, &:focus {
    color: #ffc107;



                var lastUpdate;
var container;
var camera, scene, renderer;
var uniforms;

function init(showStats) {
  // stats
  if (showStats) {
    var stats = new Stats(); = '200'; = 'absolute'; = '0'; = '0';
    requestAnimationFrame(function updateStats(){
  // basic setup
  container = document.getElementById( 'container' );
  camera = new THREE.Camera();
  camera.position.z = 1;
  scene = new THREE.Scene();
  // load video
  var video = document.getElementById( 'video' );
  videoTexture = new THREE.VideoTexture( video );
  videoTexture.minFilter = THREE.LinearFilter;
  videoTexture.magFilter = THREE.LinearFilter;
  videoTexture.format = THREE.RGBAFormat;

  // shader stuff
  uniforms = {
    time: { type: "f", value: 1.0 },
    texture: { type: "sampler2D", value: videoTexture }
  var material = new THREE.ShaderMaterial( {
    uniforms: uniforms,
    vertexShader: document.getElementById( 'vertexShader' ).textContent,
    fragmentShader: document.getElementById( 'fragmentShader' ).textContent,
    transparent: true
  } );
  lastUpdate = new Date().getTime();

  // put it together for rendering
  var geometry = new THREE.PlaneBufferGeometry( 2, 2 );
  var mesh = new THREE.Mesh( geometry, material );
  scene.add( mesh );
  renderer = new THREE.WebGLRenderer({ alpha: true });
  renderer.setPixelRatio( window.devicePixelRatio / parseFloat(document.getElementById('resolution').value) );
  container.appendChild( renderer.domElement );
  // event listeners
  document.getElementById('play-button').addEventListener('click', e => {; });
  document.getElementById('stop-button').addEventListener('click', e => { video.pause(); });
  window.addEventListener( 'resize', onWindowResize, false);
  document.getElementById('resolution').addEventListener('change', onResolutionChange, false);

// events
function onWindowResize(evt) {
  renderer.setSize( window.innerHeight, window.innerHeight );
function onResolutionChange(evt) {
  var newResolutionScale = parseFloat(;
  renderer.setPixelRatio( window.devicePixelRatio / newResolutionScale );
function animate() {
  var currentTime = new Date().getTime()
  var timeSinceLastUpdate = currentTime - lastUpdate;
  lastUpdate = currentTime;
  requestAnimationFrame( animate );
function render(timeDelta) {
  uniforms.time.value += (timeDelta ? timeDelta / 1000 : 0.05);
  renderer.render( scene, camera );

// boot