Refactor and improve brush
This commit is contained in:
parent
9e582110ea
commit
d8a3ae7528
19 changed files with 367 additions and 92 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { setUpFullScreenQuad } from '../../utils/full-screen-quad';
|
||||
import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad/full-screen-quad';
|
||||
import { smartCompile } from '../../utils/smart-compile';
|
||||
import { CommonParameters } from '../common-parameters';
|
||||
import { RenderSettings } from './render-settings';
|
||||
import shader from './render.wgsl';
|
||||
|
|
@ -15,8 +16,7 @@ export class RenderPipeline {
|
|||
|
||||
public constructor(
|
||||
private readonly context: GPUCanvasContext,
|
||||
private readonly device: GPUDevice,
|
||||
preferredCanvasFormat: GPUTextureFormat
|
||||
private readonly device: GPUDevice
|
||||
) {
|
||||
const { buffer, vertex } = setUpFullScreenQuad(device);
|
||||
this.quadVertexBuffer = buffer;
|
||||
|
|
@ -25,13 +25,11 @@ export class RenderPipeline {
|
|||
layout: 'auto',
|
||||
vertex,
|
||||
fragment: {
|
||||
module: device.createShaderModule({
|
||||
code: shader,
|
||||
}),
|
||||
module: smartCompile(device, shader),
|
||||
entryPoint: 'fragment',
|
||||
targets: [
|
||||
{
|
||||
format: preferredCanvasFormat,
|
||||
format: navigator.gpu.getPreferredCanvasFormat(),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -54,7 +52,7 @@ export class RenderPipeline {
|
|||
this.device.queue.writeBuffer(
|
||||
this.uniforms,
|
||||
0,
|
||||
new Float32Array([canvasSize[0], canvasSize[1], deltaTime, time])
|
||||
new Float32Array([...canvasSize, deltaTime, time])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,5 +10,6 @@ struct Settings {
|
|||
|
||||
@fragment
|
||||
fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
||||
return vec4(textureSample(TargetTexture, mySampler, uv).r * 1.0, settings.deltaTime * 0.0, 0.0, 1.0);
|
||||
return vec4(textureSample(TargetTexture, mySampler, uv).rgb, 1.0);
|
||||
return vec4(0, settings.deltaTime * 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue