Streamline brush settings
This commit is contained in:
parent
a95a5f83a3
commit
8eaee2fa65
7 changed files with 94 additions and 34 deletions
|
|
@ -14,13 +14,6 @@ export const setUpSettingsPage = (
|
|||
rounding: Math.round,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'moveSpeed', {
|
||||
min: 10,
|
||||
max: 500,
|
||||
scaling: ValueScaling.Quadratic,
|
||||
rounding: Math.round,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'currentGenerationAggression', {
|
||||
min: -20,
|
||||
max: 20,
|
||||
|
|
@ -31,8 +24,81 @@ export const setUpSettingsPage = (
|
|||
max: 20,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'moveSpeed', {
|
||||
min: 10,
|
||||
max: 500,
|
||||
scaling: ValueScaling.Quadratic,
|
||||
rounding: Math.round,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'turnSpeed', {
|
||||
min: 10,
|
||||
max: 1000,
|
||||
scaling: ValueScaling.Quadratic,
|
||||
rounding: Math.round,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'sensorOffsetAngle', {
|
||||
min: 0,
|
||||
max: 90,
|
||||
step: 1,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'sensorOffsetDistance', {
|
||||
min: 0,
|
||||
max: 200,
|
||||
scaling: ValueScaling.Quadratic,
|
||||
rounding: Math.round,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'turnWhenLost', {
|
||||
min: 0,
|
||||
max: 1,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'turnWhenGoingInTheRightDirection', {
|
||||
min: 0,
|
||||
max: 1,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'deinfectionProbability', {
|
||||
min: 0,
|
||||
max: 1,
|
||||
scaling: ValueScaling.Quadratic,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'brushTrailWeight', {
|
||||
min: 0,
|
||||
max: 10,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'individualTrailWeight', {
|
||||
min: 0,
|
||||
max: 1,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'diffusionRateTrails', {
|
||||
min: 0,
|
||||
max: 10,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'decayRateTrails', {
|
||||
min: 0,
|
||||
max: 10,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'diffusionRateBrush', {
|
||||
min: 0,
|
||||
max: 10,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'decayRateBrush', {
|
||||
min: 0,
|
||||
max: 10,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'spawnRadius', {
|
||||
min: 1,
|
||||
min: 0,
|
||||
max: 1000,
|
||||
}),
|
||||
|
||||
|
|
@ -47,15 +113,10 @@ export const setUpSettingsPage = (
|
|||
step: 0.1,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'brushWidth', {
|
||||
new SettingsSlider(settings, 'brushSize', {
|
||||
min: 1,
|
||||
max: 60,
|
||||
}),
|
||||
|
||||
new SettingsSlider(settings, 'brushWidthVariation', {
|
||||
min: 0,
|
||||
max: 1,
|
||||
}),
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ fn main(
|
|||
let direction = position - center;
|
||||
|
||||
agents[id] = Agent(
|
||||
position,
|
||||
state.size / 2.0,
|
||||
atan2(direction.y, direction.x),
|
||||
0,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -119,11 +119,11 @@ export class BrushPipeline {
|
|||
this.linePoints.length = 0;
|
||||
}
|
||||
|
||||
public setParameters({ brushWidth, brushWidthVariation }: BrushSettings) {
|
||||
public setParameters({ brushSize, brushSizeVariation }: BrushSettings) {
|
||||
this.device.queue.writeBuffer(
|
||||
this.uniforms,
|
||||
0,
|
||||
new Float32Array([brushWidth / 2, (brushWidth / 2) * brushWidthVariation])
|
||||
new Float32Array([brushSize / 2, Math.floor((brushSize / 2) * brushSizeVariation)])
|
||||
);
|
||||
|
||||
this.actualPoints = this.linePoints.slice();
|
||||
|
|
@ -148,7 +148,7 @@ export class BrushPipeline {
|
|||
new Array(this.lineCount).fill(0).flatMap((_, i) => {
|
||||
const from = this.actualPoints[i];
|
||||
const to = this.actualPoints[i + 1];
|
||||
const [a, b, c, d] = this.getSegmentBoundingBox(from, to, brushWidth / 2);
|
||||
const [a, b, c, d] = this.getSegmentBoundingBox(from, to, brushSize / 2);
|
||||
return [a, b, c, b, c, d].flatMap((v) => [...v, ...from, ...to]);
|
||||
})
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export interface BrushSettings {
|
||||
brushWidth: number;
|
||||
brushWidthVariation: number;
|
||||
brushSize: number;
|
||||
brushSizeVariation: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
struct Settings {
|
||||
brushWidth: f32,
|
||||
brushWidthVariation: f32
|
||||
brushSize: f32,
|
||||
brushSizeVariation: f32
|
||||
};
|
||||
|
||||
@group(1) @binding(0) var<uniform> settings: Settings;
|
||||
|
|
@ -31,9 +31,9 @@ fn fragment(
|
|||
) -> @location(0) vec4<f32> {
|
||||
var distance = distanceFromLine(screenPosition, start, end);
|
||||
let noise = textureSample(noise, noiseSampler, screenPosition / state.size / 50);
|
||||
distance += noise.r * settings.brushWidthVariation;
|
||||
distance += noise.r * settings.brushSizeVariation;
|
||||
|
||||
if(distance > settings.brushWidth) {
|
||||
if(distance > settings.brushSize) {
|
||||
discard;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ export const settings: { [key: string]: number } & GameLoopSettings &
|
|||
currentGenerationAggression: 0.1,
|
||||
nextGenerationAggression: 10,
|
||||
|
||||
moveSpeed: 80,
|
||||
turnSpeed: 550,
|
||||
sensorOffsetAngle: 30,
|
||||
sensorOffsetDistance: 30,
|
||||
turnWhenGoingInTheRightDirection: 0.05,
|
||||
moveSpeed: 70,
|
||||
turnSpeed: 345,
|
||||
sensorOffsetAngle: 32,
|
||||
sensorOffsetDistance: 23,
|
||||
turnWhenGoingInTheRightDirection: 0,
|
||||
turnWhenLost: 0.2,
|
||||
deinfectionProbability: 0.001,
|
||||
|
||||
|
|
@ -34,8 +34,8 @@ export const settings: { [key: string]: number } & GameLoopSettings &
|
|||
spawnInterval: 600,
|
||||
|
||||
clarity: 2,
|
||||
brushWidth: 12,
|
||||
brushWidthVariation: 0.5,
|
||||
brushSize: 12,
|
||||
brushSizeVariation: 0.5,
|
||||
|
||||
startColorHue: 200,
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
export const persist = <T extends Record<string, number>>(wrapee: T): T => {
|
||||
const keys = Object.keys(wrapee);
|
||||
keys.sort();
|
||||
|
||||
const keysToShortKeys = Object.fromEntries(
|
||||
keys.map((key, i) => [key, String.fromCharCode(97 + i)])
|
||||
);
|
||||
const keysToShortKeys = Object.fromEntries(keys.map((key, i) => [key, key]));
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const newParams = new URLSearchParams();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue