Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <shader-art role="img" aria-label="A cheap noise pattern" autoplay>
  <uniform name="color1" type="color" value="#ff69b4" />
  <uniform name="color2" type="color" value="#ffff00" />
  <uniform name="color3" type="color" value="#552266" />
<!--   <uniform name="color4" type="color" value="#33ff77" /> -->
  <uniform name="mixVal" type="float" min="0" max="1" step="0.01" value=".3"/>
  <uniform name="scale" type="float" min=".5" max="10" step="0.01" value="1."/>
  <uniform name="gridSize" type="float" min="1" max="10" step="1" value="4" />
  <uniform name="rotateSpeed" type="float" min="1" max="10" step="1" value="1"/>
  <script type="buffer" name="position" data-size="2">
    [-1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1]
  </script>
  <script type="vert">
    precision highp float;
    attribute vec4 position;
    varying vec4 vPosition;
    uniform vec3 color;
    const float PI = 3.141592654;
    const float DEG = PI / 180.;
    
    void main() {
      vPosition = position;
      gl_Position = position;
    }
  </script>
  <script type="frag">
    precision highp float;
    varying vec4 vPosition;
    uniform vec3 color1;
    uniform vec3 color2;
    uniform vec3 color3;
    uniform vec3 color4;
    uniform float time;
    uniform float scale;
    uniform float mixVal;
    uniform float gridSize;
    uniform float rotateSpeed;
    
    // rotate something by an angle
    vec2 rotate(vec2 p, float a) {
      return vec2(p.x * cos(a) - p.y * sin(a),
                  p.x * sin(a) + p.y * cos(a));
    }
    
    
    // just a bunch of sin & cos to generate an interesting pattern
    float cheapNoise(vec3 stp) {
      vec3 p = vec3(stp.st * .1, stp.p);
      return mix(sin(p.z + p.x * 20. + cos(p.y * 20. - p.z)) * 
        cos(p.y * 10. + p.z + cos(p.y * 20. + p.z)), 
        sin(2. + p.x * 16. - p.z) * cos(2. + p.y*17. + p.z + cos(p.x * 20. + p.z)), mixVal);
    }
    
    // cosine based palette, 4 vec3 params by IQ
    vec3 palette(float t, vec3 a, vec3 b, vec3 c, vec3 d ) {
      return a + b * cos( 6.28318 * (c * t + d) );
    }

    void main() {
      vec2 uv = rotate(
        (vPosition.xy + 1.) / 2., 
        time * .1 * rotateSpeed
      );
            
      float angle = atan(vPosition.y, vPosition.x);
      float len = length(vPosition.xy);
      
      uv = vec2(cos(angle), sin(angle)) * (.5 / len);
      float n = .5 + .5 * cheapNoise(vec3(uv * scale, time));
      
      vec3 k = fract(
        color1 * vec3(uv.x + sin(uv.y * n + time * 0.3), 
        uv.y + cos(time*0.15), 
        uv.x - sin(time*0.015)
     ) * gridSize);
      
      vec3 e = sin(fract(color2 + uv.x) * n);
      
      uv *= fract(gridSize * uv) + sin(uv.y);
      vec3 color = palette(
        n,
        k,
        e * uv.xyx,
        vec3(color3.x, e.z, k.y) * uv.y,
        mix(
          color2, 
          color3, 
          0.5 + sin(uv.x * 4. + time*.1) * .5)
       );
      
      gl_FragColor = vec4(n * color, 1.);
    }
  </script>
</shader-art>
              
            
!

CSS

              
                body {
  margin: 0;
  background: #222;
  color: #fff;
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

shader-art {
  display: block;
  background: #000;
  width: 100vmin;
  height: 100vmin;
}
              
            
!

JS

              
                import { ShaderArt } from 'https://cdn.skypack.dev/shader-art';
import { UniformPlugin } from 'https://cdn.skypack.dev/@shader-art/plugin-uniform';

ShaderArt.register([() => new UniformPlugin()]);

              
            
!
999px

Console