This commit is contained in:
parent
2347ecd201
commit
10a81ba474
45 changed files with 1974 additions and 490 deletions
|
|
@ -106,6 +106,10 @@ export class AgentPipeline {
|
|||
trailMapOut: GPUTextureView,
|
||||
sourceMap: GPUTextureView
|
||||
) {
|
||||
if (this.agentCount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bindGroup = this.getBindGroup(trailMapIn, trailMapOut, sourceMap);
|
||||
|
||||
const passEncoder = commandEncoder.beginComputePass();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export class BrushPipeline {
|
|||
private static readonly MAX_LINE_COUNT = appConfig.pipelines.brush.maxLineCount;
|
||||
private static readonly VERTICES_PER_LINE_SEGMENT = 6;
|
||||
private static readonly ATTRIBUTES_PER_LINE_SEGMENT = 6;
|
||||
private static readonly FEATHER_RADIUS_RATIO = 0.22;
|
||||
|
||||
private readonly bindGroupLayout: GPUBindGroupLayout;
|
||||
private readonly bindGroup: GPUBindGroup;
|
||||
|
|
@ -92,6 +93,18 @@ export class BrushPipeline {
|
|||
targets: [
|
||||
{
|
||||
format: 'rgba16float',
|
||||
blend: {
|
||||
color: {
|
||||
operation: 'max',
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one',
|
||||
},
|
||||
alpha: {
|
||||
operation: 'max',
|
||||
srcFactor: 'one',
|
||||
dstFactor: 'one',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -143,8 +156,14 @@ export class BrushPipeline {
|
|||
selectedColorIndex,
|
||||
isErasing,
|
||||
}: BrushSettings & { selectedColorIndex: number; isErasing: boolean }) {
|
||||
this.uniformValues[0] = brushSize / 2;
|
||||
this.uniformValues[1] = Math.floor((brushSize / 2) * brushSizeVariation);
|
||||
const brushRadius = brushSize / 2;
|
||||
const brushRadiusVariation = Math.floor(brushRadius * brushSizeVariation);
|
||||
const brushFeather = Math.max(1, brushRadius * BrushPipeline.FEATHER_RADIUS_RATIO);
|
||||
const brushGeometryRadius =
|
||||
brushRadius + Math.max(0, brushRadiusVariation) + brushFeather;
|
||||
|
||||
this.uniformValues[0] = brushRadius;
|
||||
this.uniformValues[1] = brushRadiusVariation;
|
||||
this.uniformValues[2] = 0;
|
||||
this.uniformValues[3] = 0;
|
||||
this.uniformValues[4] = !isErasing && selectedColorIndex === 0 ? 1 : 0;
|
||||
|
|
@ -178,7 +197,7 @@ export class BrushPipeline {
|
|||
floatOffset,
|
||||
segment.from,
|
||||
segment.to,
|
||||
brushSize / 2
|
||||
brushGeometryRadius
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,12 +39,13 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|||
strengths.r * settings.colorA
|
||||
+ strengths.g * settings.colorB
|
||||
+ strengths.b * settings.colorC;
|
||||
let normalizedTraceColor = traceColor / max(1.0, strengths.r + strengths.g + strengths.b);
|
||||
let brushColor =
|
||||
sourceStrengths.r * settings.colorA
|
||||
+ sourceStrengths.g * settings.colorB
|
||||
+ sourceStrengths.b * settings.colorC;
|
||||
let brushStrength = clamp(max(max(sourceStrengths.r, sourceStrengths.g), sourceStrengths.b), 0, 1);
|
||||
let color = max(traceColor, brushColor * (1.2 + brushStrength * 1.6));
|
||||
let color = max(normalizedTraceColor, brushColor * (1.2 + brushStrength * 1.6));
|
||||
|
||||
let strength = clamp(max(max(max(strengths.r, strengths.g), strengths.b), brushStrength), 0, 1);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue