Files
WebGPU-FFT-Ocean-Demo/passes/SpectrumPass.js
2025-12-31 14:22:45 +01:00

45 lines
927 B
JavaScript

import { RenderPass } from "/framework/RenderPass.js";
import Shader from "/framework/WebGpu.js";
export class SpectrumPass extends RenderPass {
async create( ) {
this.shader = new Shader( this.device );
await this.shader.setup( "shaders/ocean_spectrum_new.wgsl" );
this.shader.setVariable( "h0Real", this.pipeline.memory.h0Real );
this.shader.setVariable( "h0Imag", this.pipeline.memory.h0Imag );
this.shader.setVariable( "spectrumReal", this.pipeline.memory.spectrumReal );
this.shader.setVariable( "spectrumImag", this.pipeline.memory.spectrumImag );
this.shader.setVariable( "params", this.pipeline.memory.computeParams );
}
bindBuffers( ) {
const memory = this.pipeline.memory;
this.shader.setVariable( "params", memory.computeParams );
}
async execute( ) {
const groups = Math.ceil( this.pipeline.gridSize / 8 );
await this.shader.execute( groups, groups, 1 );
}
}