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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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.


		<title>GLSL shaders</title>


                body { margin: 0; }
canvas { width: 100%; height: 100% }


                const vshader = `
varying vec2 vUv;

void main() {
  vUv = uv;

  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
const fshader = `
varying vec2 vUv;

uniform sampler2D u_tex;
uniform vec2 u_adjust_uv;

void main()
  vec2 uv = vec2(0.5) + vUv * u_adjust_uv - u_adjust_uv*0.5;
  vec3 color = vec3(0.3);
  if (uv.x>=0.0 && uv.y>=0.0 && uv.x<1.0 && uv.y<1.0) color = texture2D(u_tex, uv).rgb;
  gl_FragColor = vec4(color, 1.0);

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
    window.innerWidth / window.innerHeight,
camera.position.z = 10;

const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

const clock = new THREE.Clock();

const geometry = new THREE.PlaneGeometry( 5, 5 );
const uniforms = {
  u_tex: { value: new THREE.TextureLoader().load("")},
  u_adjust_uv: { value: new THREE.Vector2(1, 16/9)}
const material = new THREE.ShaderMaterial( {
  uniforms: uniforms,
  vertexShader: vshader,
  fragmentShader: fshader
} );

const plane = new THREE.Mesh( geometry, material );
scene.add( plane );

const controls = new THREE.OrbitControls(camera, renderer.domElement);

if (!('ontouchstart' in window)) window.addEventListener( 'resize', onWindowResize, false );


function onWindowResize( event ) {
  camera.aspect = window.innerWidth/window.innerHeight;
  renderer.setSize( window.innerWidth, window.innerHeight );

function animate() {
  requestAnimationFrame( animate );
  renderer.render( scene, camera );