-
Notifications
You must be signed in to change notification settings - Fork 0
/
glsl-inline.js
50 lines (39 loc) · 976 Bytes
/
glsl-inline.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import glslify from 'glslify'
/*
// The below will error during compiling with Babel
const vertext = `
void main () {
gl_Position = projectionMatrix *
modelViewMatrix *
vec4(position,1.0);
}
`
const vertexShader = glslify`${vertext}`
*/
const vertexShader = glslify`
void main () {
gl_Position = projectionMatrix *
modelViewMatrix *
vec4(position,1.0);
}
`
const fragmentShader = glslify`
#pragma glslify: snoise2 = require('glsl-noise/simplex/2d')
void main () {
gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
}
`
console.log('Vertex Shader')
console.log(vertexShader)
console.log('Fragment Shader')
console.log(fragmentShader)
const output = `
<h1>Vertex Shader</h1>
<pre><code class="glsl">${vertexShader}</code></pre>
<br />
<h1>Fragment Shader</h1>
<pre><code class="glsl">${fragmentShader}</code></pre>
<br />
`
document.body.innerHTML = output
hljs.initHighlightingOnLoad()