This commit is contained in:
Andras Schmelczer 2023-04-29 22:42:52 +01:00
commit e3d0af56e2
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
2 changed files with 23 additions and 4 deletions

View file

@ -1,4 +1,5 @@
import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad/full-screen-quad';
import { generateNoise } from '../../utils/graphics/noise/noise';
import { smartCompile } from '../../utils/smart-compile';
import { CommonParameters } from '../common-parameters';
import shader from './diffuse.wgsl';
@ -10,11 +11,22 @@ export class DiffusionPipeline {
private readonly pipeline: GPURenderPipeline;
private readonly uniforms: GPUBuffer;
private readonly quadVertexBuffer: GPUBuffer;
private readonly noise: GPUTexture;
private bindGroup?: GPUBindGroup;
private previousTrailMapIn?: GPUTexture;
public constructor(private readonly device: GPUDevice) {
this.noise = generateNoise({
device,
width: 256,
height: 256,
octaves: 8,
amplitude: 0.12,
gain: 0.7,
lacunarity: 80,
});
const { buffer, vertex } = setUpFullScreenQuad(device);
this.quadVertexBuffer = buffer;
@ -114,6 +126,10 @@ export class DiffusionPipeline {
binding: 2,
resource: trailMapIn.createView(),
},
{
binding: 3,
resource: this.noise.createView(),
},
],
});