Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

              
                <script type="x-shader/x-vertex" id="vertexShader">
  uniform float time;
    varying vec2 vUv;
    varying vec3 vNormal;
    varying vec3 vPos;

    void main() {
    vPos = position;
    vec3 newPos = position;
    vUv = uv;
    vNormal = normal;
    gl_Position = projectionMatrix * modelViewMatrix * vec4( newPos, 1.0 );
    }
</script>
<script type="x-shader/x-fragment" id="fragmentShader">
  uniform float time;
    varying vec2 vUv;
    
    float random (in vec2 _st) {
        return fract(sin(dot(_st.xy, vec2(12.9898,78.233))) * 43758.5453123);
    }
    
    float noise (in vec2 _st) {
        vec2 i = floor(_st);
        vec2 f = fract(_st);
        float a = random(i);
        float b = random(i + vec2(1.0, 0.0));
        float c = random(i + vec2(0.0, 1.0));
        float d = random(i + vec2(1.0, 1.0));
    
        vec2 u = f * f * (3.0 - 2.0 * f);
    
        return mix(a, b, u.x) +
                (c - a)* u.y * (1.0 - u.x) +
                (d - b) * u.x * u.y;
    }
    
    #define NUM_OCTAVES 4
    
    float fbm ( in vec2 _st) {
        float v = 0.0;
        float a = 0.5;
        vec2 shift = vec2(100.0);
        mat2 rot = mat2(cos(0.5), sin(0.5),
                        -sin(0.5), cos(0.50));
        for (int i = 0; i < NUM_OCTAVES; ++i) {
            v += a * noise(_st);
            _st = rot * _st * 2.0 + shift;
            a *= 0.5;
        }
        return v;
    }
    
    void main() {
        vec2 st = 20.0 * vUv;
        vec3 color = vec3(0.0);
        vec2 q = vec2(0.);
        q.x = fbm( st + 0.00*time);
        q.y = fbm( st + vec2(1.0));
        vec2 r = vec2(0.);
        r.x = fbm( st + q*3.1261 + vec2(6.4890,3.9225)+ 0.5771*time );
        r.y = fbm( st + q*0.5899 + vec2(3.4505,0.3149)+ 0.5978*time);
        float f = fbm(st+r);
        color = mix(vec3(0.0837, 0.5855, 0.7247),
                    vec3(0.8151,0.3307,0.5294),
                    clamp((f*f)*6.7746,0.0,1.0));
        color = mix(color,
                    vec3(0.1103,0.8393,0.2308),
                    clamp(length(q),0.0,1.0));
        color = mix(color,
                    vec3(0.5105,0.3042,0.7610),
                    clamp(length(r.x),0.0,1.0));
    
        gl_FragColor = vec4((f*f*f*0.9483+0.9943*f*f+0.7139*f)*color,1.);
    }
</script>
<canvas id="canvas"></canvas>
              
            
!

CSS

              
                body {
  margin: 0;
  display: flex;
  overflow: hidden;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

              
            
!

JS

              
                let renderer, scene, camera;
const { max } = Math;
const { innerHeight, innerWidth, devicePixelRatio } = window;
const canvas = document.querySelector("#canvas");
const s = max(innerHeight, innerWidth) * devicePixelRatio;
canvas.width = s;
canvas.height = s;
renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
const fov = 75;
const aspect = 1;
const near = 0.1;
const far = 20;
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
camera.position.set(
  0.018642919740713196,
  0.062166257361373406,
  1.8988912022517688
);
camera.rotation.x = -0.032726499473191346;
camera.rotation.y = 0.00981222047356264;
camera.rotation.z = 0.00032122915379875284;

scene = new THREE.Scene();
const uniforms = {
  time: { type: "f", value: 1.0 }
};

const material = new THREE.ShaderMaterial({
  fragmentShader: document.getElementById("fragmentShader").textContent,
  vertexShader: document.getElementById("vertexShader").textContent,
  uniforms
});
const geometry = new THREE.PlaneGeometry(3, 3, 32);
const plane = new THREE.Mesh(geometry, material);
scene.add(plane);
function resizeRendererToDisplaySize(renderer) {
  const canvas = renderer.domElement;
  const { innerHeight, innerWidth, devicePixelRatio } = window;
  const s = max(innerHeight, innerWidth) * devicePixelRatio;
  const needResize = canvas.width !== s || canvas.height !== s;
  if (needResize) {
    renderer.setSize(s, s, false);
  }
  return needResize;
}

function render(time) {
  time *= 0.001;
  uniforms.time.value = time;
  if (resizeRendererToDisplaySize(renderer)) {
    camera.aspect = 1;
    camera.updateProjectionMatrix();
  }

  renderer.render(scene, camera);

  requestAnimationFrame(render);
}

requestAnimationFrame(render);

              
            
!
999px

Console