Created
June 3, 2021 13:29
-
-
Save supahfunk/043f0a3b1e76171998f46f0763283ea2 to your computer and use it in GitHub Desktop.
ShaderMaterial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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