Minor fixes
This commit is contained in:
parent
68b24effde
commit
ebabaf6ee5
6 changed files with 21 additions and 21 deletions
|
|
@ -9,10 +9,14 @@ fn main(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let position = vec2(
|
let random = textureSampleLevel(
|
||||||
hash(id) * state.size.x,
|
noise,
|
||||||
hash(id * id) * state.size.y,
|
noiseSampler,
|
||||||
|
vec2(f32(id % 1999) / 2000, f32(id) / 1999 / 2000),
|
||||||
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let position = random.xy * state.size;
|
||||||
let center = state.size / 2.0;
|
let center = state.size / 2.0;
|
||||||
let direction = position - center;
|
let direction = position - center;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { getWorkgroupCounts } from '../../../utils/graphics/get-workgroup-counts';
|
import { getWorkgroupCounts } from '../../../utils/graphics/get-workgroup-counts';
|
||||||
import random from '../../../utils/graphics/random.wgsl';
|
|
||||||
import { smartCompile } from '../../../utils/graphics/smart-compile';
|
import { smartCompile } from '../../../utils/graphics/smart-compile';
|
||||||
import { CommonState } from '../../common-state/common-state';
|
import { CommonState } from '../../common-state/common-state';
|
||||||
import { AGENT_SIZE_IN_BYTES } from './agent';
|
import { AGENT_SIZE_IN_BYTES } from './agent';
|
||||||
|
|
@ -107,7 +106,6 @@ export class AgentGenerationPipeline {
|
||||||
module: smartCompile(
|
module: smartCompile(
|
||||||
device,
|
device,
|
||||||
CommonState.shaderCode,
|
CommonState.shaderCode,
|
||||||
random,
|
|
||||||
agentSchema,
|
agentSchema,
|
||||||
firstGenerationShader
|
firstGenerationShader
|
||||||
),
|
),
|
||||||
|
|
@ -120,13 +118,7 @@ export class AgentGenerationPipeline {
|
||||||
bindGroupLayouts: [commonState.bindGroupLayout, this.bindGroupLayout],
|
bindGroupLayouts: [commonState.bindGroupLayout, this.bindGroupLayout],
|
||||||
}),
|
}),
|
||||||
compute: {
|
compute: {
|
||||||
module: smartCompile(
|
module: smartCompile(device, CommonState.shaderCode, agentSchema, countingShader),
|
||||||
device,
|
|
||||||
CommonState.shaderCode,
|
|
||||||
random,
|
|
||||||
agentSchema,
|
|
||||||
countingShader
|
|
||||||
),
|
|
||||||
entryPoint: 'main',
|
entryPoint: 'main',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -135,7 +127,7 @@ export class AgentGenerationPipeline {
|
||||||
public get maxAgentCount(): number {
|
public get maxAgentCount(): number {
|
||||||
return Math.min(
|
return Math.min(
|
||||||
this.maxAgentCountUpperLimit,
|
this.maxAgentCountUpperLimit,
|
||||||
Math.floor(this.device.limits.maxBufferSize / AGENT_SIZE_IN_BYTES),
|
Math.floor(this.device.limits.maxBufferSize / AGENT_SIZE_IN_BYTES) - 1,
|
||||||
this.device.limits.maxComputeWorkgroupsPerDimension ** 3
|
this.device.limits.maxComputeWorkgroupsPerDimension ** 3
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { getWorkgroupCounts } from '../../utils/graphics/get-workgroup-counts';
|
import { getWorkgroupCounts } from '../../utils/graphics/get-workgroup-counts';
|
||||||
import random from '../../utils/graphics/random.wgsl';
|
|
||||||
import { smartCompile } from '../../utils/graphics/smart-compile';
|
import { smartCompile } from '../../utils/graphics/smart-compile';
|
||||||
import { CommonState } from '../common-state/common-state';
|
import { CommonState } from '../common-state/common-state';
|
||||||
import agentSchme from './agent-generation/agent-schema.wgsl';
|
import agentSchme from './agent-generation/agent-schema.wgsl';
|
||||||
|
|
@ -33,7 +32,7 @@ export class AgentPipeline {
|
||||||
bindGroupLayouts: [commonState.bindGroupLayout, this.bindGroupLayout],
|
bindGroupLayouts: [commonState.bindGroupLayout, this.bindGroupLayout],
|
||||||
}),
|
}),
|
||||||
compute: {
|
compute: {
|
||||||
module: smartCompile(device, CommonState.shaderCode, random, agentSchme, shader),
|
module: smartCompile(device, CommonState.shaderCode, agentSchme, shader),
|
||||||
entryPoint: 'main',
|
entryPoint: 'main',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
struct Settings {
|
struct Settings {
|
||||||
brushTrailWeight: f32,
|
brushTrailWeight: f32,
|
||||||
moveRate: f32,
|
moveRate: f32,
|
||||||
|
|
||||||
turnRate: f32,
|
turnRate: f32,
|
||||||
|
|
||||||
sensorAngle: f32,
|
sensorAngle: f32,
|
||||||
|
|
||||||
sensorOffset: f32,
|
sensorOffset: f32,
|
||||||
evenGenerationAggression: f32,
|
|
||||||
|
|
||||||
|
evenGenerationAggression: f32,
|
||||||
oddGenerationAggression: f32,
|
oddGenerationAggression: f32,
|
||||||
nextGenerationId: f32,
|
nextGenerationId: f32,
|
||||||
|
|
||||||
|
|
@ -62,7 +61,13 @@ fn main(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let random = hash(id + u32(state.time % 107 * 1673.7));
|
let random = textureSampleLevel(
|
||||||
|
noise,
|
||||||
|
noiseSampler,
|
||||||
|
vec2(f32(id) % 23647 / 2000,
|
||||||
|
state.time % 6294 / 2000),
|
||||||
|
0
|
||||||
|
).a;
|
||||||
|
|
||||||
let isFromEvenGeneration = agent.generation % 2 == 0;
|
let isFromEvenGeneration = agent.generation % 2 == 0;
|
||||||
let isFromNextGeneration = agent.generation == settings.nextGenerationId;
|
let isFromNextGeneration = agent.generation == settings.nextGenerationId;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { generateNoise } from '../../utils/graphics/noise/noise';
|
import { generateNoise } from '../../utils/graphics/noise';
|
||||||
|
|
||||||
import { vec2 } from 'gl-matrix';
|
import { vec2 } from 'gl-matrix';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { clamp } from './clamp';
|
||||||
import { exponentialDecay } from './exponential-decay';
|
import { exponentialDecay } from './exponential-decay';
|
||||||
|
|
||||||
export class DeltaTimeCalculator {
|
export class DeltaTimeCalculator {
|
||||||
private static FPS_EXPONENTIAL_DECAY_STRENGTH = 0.1;
|
private static FPS_EXPONENTIAL_DECAY_STRENGTH = 0.01;
|
||||||
|
|
||||||
private previousTime: DOMHighResTimeStamp | null = null;
|
private previousTime: DOMHighResTimeStamp | null = null;
|
||||||
private deltaTimeAccumulator: number | null = null;
|
private deltaTimeAccumulator: number | null = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue