simplify more
This commit is contained in:
parent
f03da42b5e
commit
2fe3c69963
40 changed files with 689 additions and 872 deletions
|
|
@ -7,9 +7,19 @@ import {
|
|||
} from '../../utils/graphics/cached-buffer-write';
|
||||
import { smartCompile } from '../../utils/graphics/smart-compile';
|
||||
import { CommonState } from '../common-state/common-state';
|
||||
import { BrushSettings } from './brush-settings';
|
||||
import shader from './brush.wgsl?raw';
|
||||
|
||||
export interface BrushSettings {
|
||||
brushSize: number;
|
||||
brushAlpha: number;
|
||||
brushDiscardThreshold: number;
|
||||
brushGrainNoiseScale: number;
|
||||
brushGrainNoiseOffsetX: number;
|
||||
brushGrainNoiseOffsetY: number;
|
||||
brushGrainMinStrength: number;
|
||||
brushGrainMaxStrength: number;
|
||||
}
|
||||
|
||||
interface LineSegment {
|
||||
from: vec2;
|
||||
to: vec2;
|
||||
|
|
@ -29,10 +39,8 @@ const setBrushUniformValues = (
|
|||
target: Float32Array,
|
||||
{
|
||||
brushSize,
|
||||
brushSizeVariation,
|
||||
brushAlpha,
|
||||
brushDiscardThreshold,
|
||||
brushCoarseNoiseScale,
|
||||
brushGrainNoiseScale,
|
||||
brushGrainNoiseOffsetX,
|
||||
brushGrainNoiseOffsetY,
|
||||
|
|
@ -44,25 +52,21 @@ const setBrushUniformValues = (
|
|||
): void => {
|
||||
const safePixelRatio = getSafePixelRatio(pixelRatio);
|
||||
const brushRadius = (brushSize * safePixelRatio) / 2;
|
||||
const brushRadiusVariation = Math.floor(brushRadius * brushSizeVariation);
|
||||
const brushGeometryRadius = brushRadius + Math.max(0, brushRadiusVariation);
|
||||
|
||||
target[0] = brushRadius;
|
||||
target[1] = brushRadiusVariation * 2;
|
||||
target[2] = brushGeometryRadius * brushGeometryRadius;
|
||||
target[3] = brushGeometryRadius;
|
||||
target[1] = brushRadius * brushRadius;
|
||||
target[2] = 0;
|
||||
target[3] = 0;
|
||||
target[4] = selectedColorIndex === 0 ? 1 : 0;
|
||||
target[5] = selectedColorIndex === 1 ? 1 : 0;
|
||||
target[6] = selectedColorIndex === 2 ? 1 : 0;
|
||||
target[7] = brushAlpha;
|
||||
target[8] = 1 / Math.max(Number.EPSILON, brushCoarseNoiseScale * safePixelRatio);
|
||||
target[9] = 1 / Math.max(Number.EPSILON, brushGrainNoiseScale * safePixelRatio);
|
||||
target[10] = brushGrainNoiseOffsetX;
|
||||
target[11] = brushGrainNoiseOffsetY;
|
||||
target[12] = brushDiscardThreshold;
|
||||
target[13] = brushGrainMinStrength;
|
||||
target[14] = brushGrainMaxStrength;
|
||||
target[15] = 0;
|
||||
target[8] = 1 / Math.max(Number.EPSILON, brushGrainNoiseScale * safePixelRatio);
|
||||
target[9] = brushGrainNoiseOffsetX;
|
||||
target[10] = brushGrainNoiseOffsetY;
|
||||
target[11] = brushDiscardThreshold;
|
||||
target[12] = brushGrainMinStrength;
|
||||
target[13] = brushGrainMaxStrength;
|
||||
};
|
||||
|
||||
export class BrushPipeline {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue