Refactoring start
This commit is contained in:
parent
6588930911
commit
b1acdff594
19 changed files with 528 additions and 97 deletions
|
|
@ -1,3 +1,7 @@
|
|||
import {
|
||||
createCachedFloat32BufferWrite,
|
||||
writeFloat32BufferIfChanged,
|
||||
} from '../../utils/graphics/cached-buffer-write';
|
||||
import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad';
|
||||
import { smartCompile } from '../../utils/graphics/smart-compile';
|
||||
import { CommonState } from '../common-state/common-state';
|
||||
|
|
@ -5,11 +9,15 @@ import shader from './diffuse.wgsl?raw';
|
|||
import { DiffusionSettings } from './diffusion-settings';
|
||||
|
||||
export class DiffusionPipeline {
|
||||
private static readonly UNIFORM_COUNT = 4;
|
||||
private static readonly UNIFORM_COUNT = 5;
|
||||
|
||||
private readonly bindGroupLayout: GPUBindGroupLayout;
|
||||
private readonly pipeline: GPURenderPipeline;
|
||||
private readonly uniforms: GPUBuffer;
|
||||
private readonly uniformValues = new Float32Array(DiffusionPipeline.UNIFORM_COUNT);
|
||||
private readonly uniformCache = createCachedFloat32BufferWrite(
|
||||
DiffusionPipeline.UNIFORM_COUNT
|
||||
);
|
||||
private readonly vertexBuffer: GPUBuffer;
|
||||
|
||||
private bindGroup?: GPUBindGroup;
|
||||
|
|
@ -56,16 +64,18 @@ export class DiffusionPipeline {
|
|||
decayRateTrails,
|
||||
diffusionRateBrush,
|
||||
decayRateBrush,
|
||||
anisotropy,
|
||||
}: DiffusionSettings) {
|
||||
this.device.queue.writeBuffer(
|
||||
this.uniformValues[0] = 1 / diffusionRateTrails;
|
||||
this.uniformValues[1] = decayRateTrails / 1000;
|
||||
this.uniformValues[2] = 1 / diffusionRateBrush;
|
||||
this.uniformValues[3] = decayRateBrush / 1000;
|
||||
this.uniformValues[4] = anisotropy;
|
||||
writeFloat32BufferIfChanged(
|
||||
this.device,
|
||||
this.uniforms,
|
||||
0,
|
||||
new Float32Array([
|
||||
1 / diffusionRateTrails,
|
||||
decayRateTrails / 1000,
|
||||
1 / diffusionRateBrush,
|
||||
decayRateBrush / 1000,
|
||||
])
|
||||
this.uniformValues,
|
||||
this.uniformCache
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue