DiamondCrop.js 487 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
import GL from "gl-react";
import React from "react";

const shaders = GL.Shaders.create({
  DiamondCrop: {
    frag: `
precision highp float;
varying vec2 uv;
uniform sampler2D t;
void main () {
  gl_FragColor = mix(
    texture2D(t, uv),
    vec4(0.0),
    step(0.5, abs(uv.x - 0.5) + abs(uv.y - 0.5))
  );
}
`
  }
});

module.exports = GL.createComponent(
  ({ children: t }) =>
  <GL.Node
    shader={shaders.DiamondCrop}
    uniforms={{ t }}
  />,
{ displayName: "DiamondCrop" }
);