Add resizing
This commit is contained in:
parent
9c7b91000f
commit
058d6014b7
18 changed files with 254 additions and 138 deletions
|
|
@ -11,7 +11,7 @@ export class RenderPipeline {
|
|||
private readonly bindGroupLayout: GPUBindGroupLayout;
|
||||
private readonly pipeline: GPURenderPipeline;
|
||||
private readonly uniforms: GPUBuffer;
|
||||
private readonly quadVertexBuffer: GPUBuffer;
|
||||
private readonly vertexBuffer: GPUBuffer;
|
||||
|
||||
private bindGroup?: GPUBindGroup;
|
||||
private previousColorTexture?: GPUTextureView;
|
||||
|
|
@ -24,7 +24,7 @@ export class RenderPipeline {
|
|||
this.bindGroupLayout = device.createBindGroupLayout(RenderPipeline.bindGroupLayout);
|
||||
|
||||
const { buffer, vertex } = setUpFullScreenQuad(device);
|
||||
this.quadVertexBuffer = buffer;
|
||||
this.vertexBuffer = buffer;
|
||||
|
||||
this.pipeline = device.createRenderPipeline({
|
||||
layout: device.createPipelineLayout({
|
||||
|
|
@ -82,7 +82,7 @@ export class RenderPipeline {
|
|||
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
|
||||
passEncoder.setPipeline(this.pipeline);
|
||||
this.commonState.execute(passEncoder);
|
||||
passEncoder.setVertexBuffer(0, this.quadVertexBuffer);
|
||||
passEncoder.setVertexBuffer(0, this.vertexBuffer);
|
||||
passEncoder.setBindGroup(1, this.bindGroup);
|
||||
passEncoder.draw(4, 1);
|
||||
passEncoder.end();
|
||||
|
|
@ -118,7 +118,7 @@ export class RenderPipeline {
|
|||
}
|
||||
|
||||
public destroy() {
|
||||
this.quadVertexBuffer.destroy();
|
||||
this.vertexBuffer.destroy();
|
||||
this.uniforms.destroy();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|||
let brushStrength = traces.a;
|
||||
|
||||
let rgbColor = sqrt(vec3(
|
||||
settings.speciesColorA * speciesAStrength +
|
||||
settings.speciesColorB * speciesBStrength +
|
||||
settings.speciesColorA * clamp(speciesAStrength, 0, 1) +
|
||||
settings.speciesColorB * clamp(speciesBStrength, 0, 1) +
|
||||
settings.brushColor * brushStrength
|
||||
));
|
||||
|
||||
|
||||
let bg = vec3(0.9) + 0.05 * (random.r - 0.5);
|
||||
let bg = vec3(0.9) + 0.075 * random.r;
|
||||
|
||||
|
||||
return vec4(bg - rgbColor, 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue