This commit is contained in:
parent
05c8a39bd8
commit
c40c5d97db
74 changed files with 864 additions and 670 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
|
||||
import { appConfig } from '../config';
|
||||
import { appConfig, type GardenRuntimeSettings } from '../config';
|
||||
import { AgentGenerationPipeline } from '../pipelines/agents/agent-generation/agent-generation-pipeline';
|
||||
import { AgentPipeline } from '../pipelines/agents/agent-pipeline';
|
||||
import { BrushPipeline } from '../pipelines/brush/brush-pipeline';
|
||||
|
|
@ -9,7 +9,6 @@ import { DiffusionPipeline } from '../pipelines/diffusion/diffusion-pipeline';
|
|||
import { EraserAgentPipeline } from '../pipelines/eraser/eraser-agent-pipeline';
|
||||
import { EraserTexturePipeline } from '../pipelines/eraser/eraser-texture-pipeline';
|
||||
import { RenderPipeline } from '../pipelines/render/render-pipeline';
|
||||
import { settings } from '../settings';
|
||||
import { initializeContext } from '../utils/graphics/initialize-context';
|
||||
import { CanvasReadbackRequest, RenderInputs } from './game-loop-types';
|
||||
import { GpuProfiler } from './gpu-profiler';
|
||||
|
|
@ -25,6 +24,7 @@ interface FrameParameters extends RenderInputs {
|
|||
introProgress: number;
|
||||
selectedColorIndex: number;
|
||||
eraserPixelSize: number;
|
||||
runtimeSettings: GardenRuntimeSettings;
|
||||
}
|
||||
|
||||
export class GameLoopResources {
|
||||
|
|
@ -46,7 +46,8 @@ export class GameLoopResources {
|
|||
private readonly device: GPUDevice,
|
||||
private readonly canvasFormat: GPUTextureFormat,
|
||||
canvasSize: vec2,
|
||||
initialAgentCapacity: number
|
||||
initialAgentCapacity: number,
|
||||
initialMaxAgentCount: number
|
||||
) {
|
||||
const context = initializeContext({ device, canvas, format: canvasFormat });
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ export class GameLoopResources {
|
|||
|
||||
this.agentGenerationPipeline = new AgentGenerationPipeline(
|
||||
this.device,
|
||||
Math.min(settings.maxAgentCount, initialAgentCapacity)
|
||||
Math.min(initialMaxAgentCount, initialAgentCapacity)
|
||||
);
|
||||
|
||||
this.agentPipeline = new AgentPipeline(
|
||||
|
|
@ -74,12 +75,7 @@ export class GameLoopResources {
|
|||
);
|
||||
this.eraserTexturePipeline = new EraserTexturePipeline(this.device, this.commonState);
|
||||
this.diffusionPipeline = new DiffusionPipeline(this.device);
|
||||
this.renderPipeline = new RenderPipeline(
|
||||
context,
|
||||
this.device,
|
||||
this.commonState,
|
||||
this.canvasFormat
|
||||
);
|
||||
this.renderPipeline = new RenderPipeline(context, this.device, this.canvasFormat);
|
||||
this.gpuProfiler = GpuProfiler.create(
|
||||
this.device,
|
||||
() => appConfig.tuningPane.showFpsOverlay
|
||||
|
|
@ -128,43 +124,43 @@ export class GameLoopResources {
|
|||
channelColors,
|
||||
backgroundColor,
|
||||
eraserPixelSize,
|
||||
runtimeSettings,
|
||||
}: FrameParameters): void {
|
||||
this.commonState.setParameters({
|
||||
canvasSize,
|
||||
});
|
||||
this.agentPipeline.setParameters({
|
||||
...settings,
|
||||
...runtimeSettings,
|
||||
deltaTime,
|
||||
time,
|
||||
agentCount: activeAgentCount,
|
||||
moveSpeed: settings.moveSpeed,
|
||||
introMoveSpeed: appConfig.simulation.introMoveSpeed,
|
||||
introProgress,
|
||||
});
|
||||
this.brushPipeline.setParameters({
|
||||
...settings,
|
||||
...runtimeSettings,
|
||||
pixelRatio: canvasPixelRatio,
|
||||
selectedColorIndex,
|
||||
});
|
||||
this.diffusionPipeline.setParameters(settings);
|
||||
this.diffusionPipeline.setParameters(runtimeSettings);
|
||||
this.renderPipeline.setParameters({
|
||||
...settings,
|
||||
...runtimeSettings,
|
||||
channelColors,
|
||||
backgroundColor,
|
||||
});
|
||||
this.eraserAgentPipeline.setParameters({
|
||||
agentCount: activeAgentCount,
|
||||
eraserSize: eraserPixelSize,
|
||||
eraserMaskAlphaThreshold: settings.eraserMaskAlphaThreshold,
|
||||
eraserMaskAlphaThreshold: runtimeSettings.eraserMaskAlphaThreshold,
|
||||
maskSize: canvasSize,
|
||||
});
|
||||
this.eraserTexturePipeline.setParameters({
|
||||
eraserSize: eraserPixelSize,
|
||||
eraserLineDistanceEpsilon: settings.eraserLineDistanceEpsilon,
|
||||
eraserClearRed: settings.eraserClearRed,
|
||||
eraserClearGreen: settings.eraserClearGreen,
|
||||
eraserClearBlue: settings.eraserClearBlue,
|
||||
eraserClearAlpha: settings.eraserClearAlpha,
|
||||
eraserLineDistanceEpsilon: runtimeSettings.eraserLineDistanceEpsilon,
|
||||
eraserClearRed: runtimeSettings.eraserClearRed,
|
||||
eraserClearGreen: runtimeSettings.eraserClearGreen,
|
||||
eraserClearBlue: runtimeSettings.eraserClearBlue,
|
||||
eraserClearAlpha: runtimeSettings.eraserClearAlpha,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue