Coder Social home page Coder Social logo

akira-cn / glsl-doodle Goto Github PK

View Code? Open in Web Editor NEW
58.0 3.0 9.0 14.04 MB

Drawing patterns with glsl shaders on modern browsers.

Home Page: https://doodle.webgl.group/

License: Other

JavaScript 45.99% GLSL 52.66% HTML 0.73% CSS 0.61%
webgl pattern glsl glsl-shaders

glsl-doodle's Introduction

glsl-doodle

Drawing patterns with glsl shaders on modern browsers.

https://doodle.webgl.group/

Usage

From CDN:

<script src="https://unpkg.com/[email protected]/dist/glsl-doodle.js"></script>
<glsl-doodle for="myShader"></glsl-doodle>
<script id="myShader" type="x-shader/x-fragment">
#ifdef GL_ES
precision mediump float;
#endif

#pragma include <graphics>
#pragma include <color>
#pragma include <pattern>

uniform vec2 dd_resolution;
uniform vec2 dd_randseed0;

void main() {
  vec2 st = gl_FragCoord.xy / dd_resolution;
  // st = polar(st);
  vec2 grid = vec2(10, 10);
  vec2 idx = grid_index(st, grid);
  st = grid_xy(st, grid);

  box2 box = create_box();
  box = scale(box, center(box), vec2(random(idx, 0.1, 0.9)));
  st = box_quad(st, box);

  float pct = sdf_rect(st, vec2(0), 1.0, 1.0);
  color(fill(pct, 0.0), random3(idx + dd_randseed0));
}
</script>

With external resource:

<script src="https://unpkg.com/[email protected]/dist/glsl-doodle.js"></script>
<glsl-doodle src="https://raw.githubusercontent.com/akira-cn/glsl-doodle/master/demos/preview/grids/index.glsl"></glsl-doodle>

From NPM:

npm i glsl-doodle --save
import Doodle from 'glsl-doodle';
(async function () {
  const doodle = new Doodle();
  const program = await doodle.load('https://raw.githubusercontent.com/akira-cn/glsl-doodle/master/demos/preview/grids/index.glsl');
  doodle.useProgram(program);
  doodle.render();
}());

For more information, please visit https://doodle.webgl.group/.

glsl-doodle's People

Contributors

akira-cn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.