Files
WebGPU-FFT-Ocean-Demo/passes/ColFFTPass.js
2025-12-31 14:33:18 +01:00

53 lines
1.1 KiB
JavaScript

import { RenderPass } from "../framework/RenderPass.js";
import Shader from "../framework/WebGpu.js";
export class ColFFTPass extends RenderPass {
async create( ) {
this.shader = new Shader( this.device );
await this.shader.setup( "shaders/fft_col.wgsl" );
const oceanBlock = this.pipeline.getBlockByName( "ocean" );
const rowPass = oceanBlock.getPass( "RowFFT" );
const rowReal = rowPass.shader.getBuffer( "outputReal" );
const rowImag = rowPass.shader.getBuffer( "outputImag" );
await this.shader.setBuffer( "inputReal", rowReal );
await this.shader.setBuffer( "inputImag", rowImag );
this.shader.setVariable( "outputReal", this.pipeline.memory.colReal );
this.shader.setVariable( "outputImag", this.pipeline.memory.colImag );
this.shader.setVariable( "heightField", this.pipeline.memory.heightField );
this.shader.setVariable( "params", this.pipeline.memory.computeParams );
}
bindBuffers( ) {
this.shader.setVariable( "params", this.pipeline.memory.computeParams );
}
async execute( ) {
const groups = this.pipeline.gridSize;
await this.shader.execute( groups, 1, 1 );
}
}