-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoutput.js
44 lines (38 loc) · 987 Bytes
/
output.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
// shaders to render a texture in the viewport
const outputWGSL = `
@group(0) @binding(0) var mySampler : sampler;
@group(0) @binding(1) var myTexture : texture_2d<f32>;
struct VertexOutput {
@builtin(position) Position : vec4<f32>,
@location(0) fragUV : vec2<f32>,
}
@vertex
fn vert_main(@builtin(vertex_index) VertexIndex : u32) -> VertexOutput {
var pos = array(
vec2( 1.0, 1.0),
vec2( 1.0, -1.0),
vec2(-1.0, -1.0),
vec2( 1.0, 1.0),
vec2(-1.0, -1.0),
vec2(-1.0, 1.0),
);
var uv = array(
vec2(1.0, 1.0),
vec2(1.0, 0.0),
vec2(0.0, 0.0),
vec2(1.0, 1.0),
vec2(0.0, 0.0),
vec2(0.0, 1.0),
);
var output : VertexOutput;
output.Position = vec4(pos[VertexIndex], 0.0, 1.0);
output.fragUV = uv[VertexIndex];
return output;
}
@fragment
fn frag_main(@location(0) fragUV : vec2<f32>) -> @location(0) vec4<f32> {
let result = textureSample(myTexture, mySampler, fragUV);
return result;
}
`
export default outputWGSL;