Add tiny UI
This commit is contained in:
parent
e3d0af56e2
commit
6a752a57e9
30 changed files with 627 additions and 210 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { smartCompile } from '../../utils/smart-compile';
|
||||
import { smartCompile } from '../../utils/webgpu/smart-compile';
|
||||
import { CommonParameters } from '../common-parameters';
|
||||
import { AGENT_SIZE_IN_BYTES, Agent } from './agent';
|
||||
import { AgentSettings } from './agent-settings';
|
||||
|
|
@ -133,4 +133,9 @@ export class AgentPipeline {
|
|||
this.previousTrailMapOut = trailMapOut;
|
||||
}
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.uniforms.destroy();
|
||||
this.agentsBuffer.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { generateNoise } from '../../utils/graphics/noise/noise';
|
||||
import { smartCompile } from '../../utils/smart-compile';
|
||||
import { smartCompile } from '../../utils/webgpu/smart-compile';
|
||||
import { CommonParameters } from '../common-parameters';
|
||||
import { BrushSettings } from './brush-settings';
|
||||
import shader from './brush.wgsl';
|
||||
|
|
@ -15,7 +15,7 @@ export class BrushPipeline {
|
|||
private readonly pipeline: GPURenderPipeline;
|
||||
private readonly uniforms: GPUBuffer;
|
||||
private readonly vertexBuffer: GPUBuffer;
|
||||
private readonly noise: GPUTexture;
|
||||
private readonly noise: GPUTextureView;
|
||||
private linePoints: Array<vec2> = [];
|
||||
private previousPoints: Array<vec2> = [];
|
||||
private nextPoint: vec2 | null = null;
|
||||
|
|
@ -116,7 +116,7 @@ export class BrushPipeline {
|
|||
},
|
||||
{
|
||||
binding: 2,
|
||||
resource: this.noise.createView(),
|
||||
resource: this.noise,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
@ -234,6 +234,11 @@ export class BrushPipeline {
|
|||
|
||||
this.linePoints.splice(0, this.linePoints.length - 1);
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.vertexBuffer.destroy();
|
||||
this.uniforms.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
const catmullRomInterpolation = (
|
||||
|
|
|
|||
|
|
@ -29,15 +29,14 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|||
let mixedTrails = mix(
|
||||
current.rgb,
|
||||
neighbours.rgb,
|
||||
settings.diffusionRateTrails + (noise.rgb - vec3(0.5)) * 0.1
|
||||
settings.diffusionRateTrails
|
||||
) * (1.0 - settings.decayRateTrails);
|
||||
|
||||
let mixedBrush = mix(
|
||||
current.a,
|
||||
neighbours.a,
|
||||
settings.diffusionRateBrush + (noise.a - 0.5) * 0.5
|
||||
) * (1.0 - settings.decayRateBrush - (noise.a - 0.5) * 0.1);
|
||||
|
||||
current.a + (noise.a - 0.5) * 0.1,
|
||||
neighbours.a ,
|
||||
settings.diffusionRateBrush
|
||||
) * (1.0 - settings.decayRateBrush);
|
||||
|
||||
return clamp(vec4(mixedTrails, mixedBrush), vec4(0), vec4(1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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 { smartCompile } from '../../utils/webgpu/smart-compile';
|
||||
import { CommonParameters } from '../common-parameters';
|
||||
import shader from './diffuse.wgsl';
|
||||
import { DiffusionSettings } from './diffusion-settings';
|
||||
|
|
@ -11,7 +11,7 @@ export class DiffusionPipeline {
|
|||
private readonly pipeline: GPURenderPipeline;
|
||||
private readonly uniforms: GPUBuffer;
|
||||
private readonly quadVertexBuffer: GPUBuffer;
|
||||
private readonly noise: GPUTexture;
|
||||
private readonly noise: GPUTextureView;
|
||||
|
||||
private bindGroup?: GPUBindGroup;
|
||||
private previousTrailMapIn?: GPUTexture;
|
||||
|
|
@ -128,7 +128,7 @@ export class DiffusionPipeline {
|
|||
},
|
||||
{
|
||||
binding: 3,
|
||||
resource: this.noise.createView(),
|
||||
resource: this.noise,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
@ -136,4 +136,9 @@ export class DiffusionPipeline {
|
|||
this.previousTrailMapIn = trailMapIn;
|
||||
}
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.quadVertexBuffer.destroy();
|
||||
this.uniforms.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad/full-screen-quad';
|
||||
import { smartCompile } from '../../utils/smart-compile';
|
||||
import { smartCompile } from '../../utils/webgpu/smart-compile';
|
||||
import { CommonParameters } from '../common-parameters';
|
||||
import { RenderSettings } from './render-settings';
|
||||
import shader from './render.wgsl';
|
||||
|
|
@ -118,4 +118,9 @@ export class RenderPipeline {
|
|||
this.previousColorTexture = colorTexture;
|
||||
}
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.quadVertexBuffer.destroy();
|
||||
this.uniforms.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue