@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
52 lines (47 loc) • 1.24 kB
JavaScript
import { FullscreenPass } from "./FullscreenPass.js";
//#region src/lib/passes/BlitPass.ts
var FULLSCREEN_BLIT_SHADER = `
struct MotionGPUVertexOut {
position: vec4f,
uv: vec2f,
};
var motiongpuBlitSampler: sampler;
var motiongpuBlitTexture: texture_2d<f32>;
fn motiongpuBlitVertex( index: u32) -> MotionGPUVertexOut {
var positions = array<vec2f, 3>(
vec2f(-1.0, -3.0),
vec2f(-1.0, 1.0),
vec2f(3.0, 1.0)
);
let position = positions[index];
var out: MotionGPUVertexOut;
out.position = vec4f(position, 0.0, 1.0);
out.uv = (position + vec2f(1.0, 1.0)) * 0.5;
return out;
}
fn motiongpuBlitFragment(in: MotionGPUVertexOut) -> vec4f {
return textureSample(motiongpuBlitTexture, motiongpuBlitSampler, in.uv);
}
`;
/**
* Fullscreen texture blit pass.
*/
var BlitPass = class extends FullscreenPass {
getProgram() {
return FULLSCREEN_BLIT_SHADER;
}
constructor(options = {}) {
super(options);
}
getVertexEntryPoint() {
return "motiongpuBlitVertex";
}
getFragmentEntryPoint() {
return "motiongpuBlitFragment";
}
};
//#endregion
export { BlitPass };
//# sourceMappingURL=BlitPass.js.map