Skip to content

Instantly share code, notes, and snippets.

@supahfunk
Created June 3, 2021 13:29
Show Gist options
  • Save supahfunk/043f0a3b1e76171998f46f0763283ea2 to your computer and use it in GitHub Desktop.
Save supahfunk/043f0a3b1e76171998f46f0763283ea2 to your computer and use it in GitHub Desktop.
ShaderMaterial
const vertexShader = /* glsl */`
uniform float uTime;
varying vec3 vPos;
varying vec2 vUv;
#define PI 3.14159265
void main() {
vec3 pos = position;
vPos = pos;
vUv = uv;
vec4 mvPos = modelViewMatrix * vec4( pos, 1.0 );
gl_Position = projectionMatrix * mvPos;
}
`
const fragmentShader = /* glsl */`
uniform float uTime;
varying vec3 vPos;
varying vec2 vUv;
#define PI 3.14159265
void main() {
vec2 uv = vUv;
vec3 color = vec3(uv.x, uv.y, 1.);
gl_FragColor = vec4(color, 1.);
}
`
const material = new ShaderMaterial({
uniforms: {
uTime: { value: 0 },
},
vertexShader,
fragmentShader
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment