Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPU: Add support for post processes written in WGSL #13937

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/dev/core/src/Engines/webgpuEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import { WebGPUSnapshotRendering } from "./WebGPU/webgpuSnapshotRendering";
import type { WebGPUDataBuffer } from "../Meshes/WebGPU/webgpuDataBuffer";
import type { WebGPURenderTargetWrapper } from "./WebGPU/webgpuRenderTargetWrapper";

import "../ShadersWGSL/postprocess.vertex";

declare function importScripts(...urls: string[]): void;

declare type VideoTexture = import("../Materials/Textures/videoTexture").VideoTexture;
Expand Down
22 changes: 22 additions & 0 deletions packages/dev/core/src/ShadersWGSL/postprocess.vertex.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Attributes
attribute position: vec2<f32>;

uniform scale: vec2<f32>;

// Output
varying vUV: vec2<f32>;

const madd = vec2(0.5, 0.5);

#define CUSTOM_VERTEX_DEFINITIONS

@vertex
fn main(input : VertexInputs) -> FragmentInputs {

#define CUSTOM_VERTEX_MAIN_BEGIN

vertexOutputs.vUV = (vertexInputs.position * madd + madd) * uniforms.scale;
vertexOutputs.position = vec4(vertexInputs.position, 0.0, 1.0);

#define CUSTOM_VERTEX_MAIN_END
}