This commit is contained in:
parent
6bc125be1c
commit
ed5a4379db
76 changed files with 1418 additions and 988 deletions
|
|
@ -2,8 +2,8 @@ import { vec2 } from 'gl-matrix';
|
|||
|
||||
import { appConfig } from '../../config';
|
||||
import {
|
||||
createCachedFloat32BufferWrite,
|
||||
writeFloat32BufferIfChanged,
|
||||
createCachedBufferWrite,
|
||||
writeBufferIfChanged,
|
||||
} from '../../utils/graphics/cached-buffer-write';
|
||||
import { smartCompile } from '../../utils/graphics/smart-compile';
|
||||
import { CommonState } from '../common-state/common-state';
|
||||
|
|
@ -13,6 +13,7 @@ import {
|
|||
LineSegmentBuffer,
|
||||
} from '../common/line-segment-buffer';
|
||||
import lineSegmentShader from '../common/line-segment.wgsl?raw';
|
||||
import { TRAIL_SOURCE_TEXTURE_FORMAT } from '../texture-formats';
|
||||
import shader from './brush.wgsl?raw';
|
||||
|
||||
export interface BrushSettings {
|
||||
|
|
@ -77,7 +78,9 @@ export class BrushPipeline {
|
|||
private readonly renderPipeline: GPURenderPipeline;
|
||||
private readonly uniforms: GPUBuffer;
|
||||
private readonly uniformValues = new Float32Array(UNIFORM_COUNT);
|
||||
private readonly uniformCache = createCachedFloat32BufferWrite(UNIFORM_COUNT);
|
||||
private readonly uniformCache = createCachedBufferWrite(
|
||||
UNIFORM_COUNT * Float32Array.BYTES_PER_ELEMENT
|
||||
);
|
||||
private readonly segments: LineSegmentBuffer;
|
||||
|
||||
public constructor(
|
||||
|
|
@ -116,7 +119,7 @@ export class BrushPipeline {
|
|||
entryPoint: 'fragmentMrt',
|
||||
targets: [
|
||||
{
|
||||
format: 'rgba16float',
|
||||
format: TRAIL_SOURCE_TEXTURE_FORMAT,
|
||||
blend: {
|
||||
color: { operation: 'max', srcFactor: 'one', dstFactor: 'one' },
|
||||
alpha: { operation: 'max', srcFactor: 'one', dstFactor: 'one' },
|
||||
|
|
@ -148,7 +151,7 @@ export class BrushPipeline {
|
|||
|
||||
public setParameters(parameters: BrushParameters): void {
|
||||
setBrushUniformValues(this.uniformValues, parameters);
|
||||
writeFloat32BufferIfChanged(
|
||||
writeBufferIfChanged(
|
||||
this.device,
|
||||
this.uniforms,
|
||||
this.uniformValues,
|
||||
|
|
|
|||
Loading…
Reference in a new issue