Compare commits
2 Commits
14d7a78ac4
...
ab3bca4395
| Author | SHA1 | Date | |
|---|---|---|---|
| ab3bca4395 | |||
| 12411e58bf |
@@ -3,11 +3,15 @@
|
|||||||
<mat-card-title>{{ 'CLOTH.TITLE' | translate }}</mat-card-title>
|
<mat-card-title>{{ 'CLOTH.TITLE' | translate }}</mat-card-title>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
|
<app-information [algorithmInformation]="algoInformation"/>
|
||||||
<div class="controls-container">
|
<div class="controls-container">
|
||||||
<div class="controls-panel">
|
<div class="controls-panel">
|
||||||
<button mat-raised-button color="primary" (click)="toggleWind()">
|
<button mat-raised-button color="primary" (click)="toggleWind()">
|
||||||
{{ isWindActive ? ('CLOTH.WIND_OFF' | translate) : ('CLOTH.WIND_ON' | translate) }}
|
{{ isWindActive ? ('CLOTH.WIND_OFF' | translate) : ('CLOTH.WIND_ON' | translate) }}
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-raised-button color="primary" (click)="toggleMesh()">
|
||||||
|
{{ isOutlineActive ? ('CLOTH.OUTLINE_OFF' | translate) : ('CLOTH.OUTLINE_ON' | translate) }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<app-babylon-canvas
|
<app-babylon-canvas
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Component } from '@angular/core';
|
|||||||
import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from '@angular/material/card';
|
import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from '@angular/material/card';
|
||||||
import { TranslatePipe } from '@ngx-translate/core';
|
import { TranslatePipe } from '@ngx-translate/core';
|
||||||
import { BabylonCanvas, RenderConfig, SceneEventData } from '../../../shared/components/render-canvas/babylon-canvas.component';
|
import { BabylonCanvas, RenderConfig, SceneEventData } from '../../../shared/components/render-canvas/babylon-canvas.component';
|
||||||
import {ComputeShader, StorageBuffer, MeshBuilder, ShaderMaterial, ShaderLanguage, ArcRotateCamera, GroundMesh} from '@babylonjs/core';
|
import {ComputeShader, StorageBuffer, MeshBuilder, ShaderMaterial, ShaderLanguage, ArcRotateCamera, GroundMesh, WebGPUEngine, Scene} from '@babylonjs/core';
|
||||||
import {
|
import {
|
||||||
CLOTH_FRAGMENT_SHADER_WGSL,
|
CLOTH_FRAGMENT_SHADER_WGSL,
|
||||||
CLOTH_INTEGRATE_COMPUTE_WGSL,
|
CLOTH_INTEGRATE_COMPUTE_WGSL,
|
||||||
@@ -16,6 +16,10 @@ import {
|
|||||||
CLOTH_VERTEX_SHADER_WGSL
|
CLOTH_VERTEX_SHADER_WGSL
|
||||||
} from './cloth.shader';
|
} from './cloth.shader';
|
||||||
import {MatButton} from '@angular/material/button';
|
import {MatButton} from '@angular/material/button';
|
||||||
|
import {ClothBuffers, ClothConfig, ClothData, ClothPipelines} from './cloth.model';
|
||||||
|
import {Information} from '../information/information';
|
||||||
|
import {AlgorithmInformation} from '../information/information.models';
|
||||||
|
import {UrlConstants} from '../../../constants/UrlConstants';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cloth',
|
selector: 'app-cloth',
|
||||||
@@ -26,7 +30,8 @@ import {MatButton} from '@angular/material/button';
|
|||||||
MatCardTitle,
|
MatCardTitle,
|
||||||
TranslatePipe,
|
TranslatePipe,
|
||||||
BabylonCanvas,
|
BabylonCanvas,
|
||||||
MatButton
|
MatButton,
|
||||||
|
Information
|
||||||
],
|
],
|
||||||
templateUrl: './cloth.component.html',
|
templateUrl: './cloth.component.html',
|
||||||
styleUrl: './cloth.component.scss',
|
styleUrl: './cloth.component.scss',
|
||||||
@@ -36,7 +41,7 @@ export class ClothComponent {
|
|||||||
private simulationTime: number = 0;
|
private simulationTime: number = 0;
|
||||||
private clothMesh: GroundMesh | null = null;
|
private clothMesh: GroundMesh | null = null;
|
||||||
public isWindActive: boolean = false;
|
public isWindActive: boolean = false;
|
||||||
|
public isOutlineActive: boolean = false;
|
||||||
|
|
||||||
public renderConfig: RenderConfig = {
|
public renderConfig: RenderConfig = {
|
||||||
mode: '3D',
|
mode: '3D',
|
||||||
@@ -44,6 +49,39 @@ export class ClothComponent {
|
|||||||
shaderLanguage: ShaderLanguage.WGSL
|
shaderLanguage: ShaderLanguage.WGSL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
algoInformation: AlgorithmInformation = {
|
||||||
|
title: 'CLOTH.EXPLANATION.TITLE',
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
name: 'CLOTH.EXPLANATION.CLOTH_SIMULATION_EXPLANATION_TITLE',
|
||||||
|
description: 'CLOTH.EXPLANATION.CLOTH_SIMULATION_EXPLANATION',
|
||||||
|
link: UrlConstants.MANDELBULB_WIKI,
|
||||||
|
translateName: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'CLOTH.EXPLANATION.XPBD_EXPLANATION_TITLE',
|
||||||
|
description: 'CLOTH.EXPLANATION.XPBD_EXPLANATION',
|
||||||
|
link: UrlConstants.MANDELBOX_WIKI,
|
||||||
|
translateName: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'CLOTH.EXPLANATION.GPU_PARALLELIZATION_EXPLANATION_TITLE',
|
||||||
|
description: 'CLOTH.EXPLANATION.GPU_PARALLELIZATION_EXPLANATION',
|
||||||
|
link: UrlConstants.JULIA3D_WIKI,
|
||||||
|
translateName: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'CLOTH.EXPLANATION.DATA_STRUCTURES_EXPLANATION_TITLE',
|
||||||
|
description: 'CLOTH.EXPLANATION.DATA_STRUCTURES_EXPLANATION',
|
||||||
|
link: UrlConstants.JULIA3D_WIKI,
|
||||||
|
translateName: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
disclaimer: 'CLOTH.EXPLANATION.DISCLAIMER',
|
||||||
|
disclaimerBottom: '',
|
||||||
|
disclaimerListEntry: ['CLOTH.EXPLANATION.DISCLAIMER_1', 'CLOTH.EXPLANATION.DISCLAIMER_2', 'CLOTH.EXPLANATION.DISCLAIMER_3', 'CLOTH.EXPLANATION.DISCLAIMER_4']
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the Babylon scene is ready.
|
* Called when the Babylon scene is ready.
|
||||||
* @param event The scene event data.
|
* @param event The scene event data.
|
||||||
@@ -57,49 +95,87 @@ export class ClothComponent {
|
|||||||
this.isWindActive = !this.isWindActive;
|
this.isWindActive = !this.isWindActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public toggleMesh(): void {
|
||||||
|
this.isOutlineActive = !this.isOutlineActive;
|
||||||
|
if (!this.clothMesh?.material) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.clothMesh.material.wireframe = this.isOutlineActive;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes and starts the cloth simulation.
|
* Initializes and starts the cloth simulation.
|
||||||
*/
|
*/
|
||||||
private createSimulation(): void {
|
private createSimulation(): void {
|
||||||
if (!this.currentSceneData) {
|
if (!this.currentSceneData) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { engine, scene } = this.currentSceneData;
|
const { engine, scene } = this.currentSceneData;
|
||||||
|
|
||||||
// --- 1. CONFIGURE CLOTH GRID ---
|
// 1. Define physics parameters
|
||||||
|
const config = this.getClothConfig();
|
||||||
|
|
||||||
|
// 2. Generate initial CPU data (positions, constraints)
|
||||||
|
const clothData = this.generateClothData(config);
|
||||||
|
|
||||||
|
// 3. Upload to GPU
|
||||||
|
const buffers = this.createStorageBuffers(engine, clothData);
|
||||||
|
|
||||||
|
// 4. Create Compute Shaders
|
||||||
|
const pipelines = this.setupComputePipelines(engine, buffers);
|
||||||
|
|
||||||
|
// 5. Setup Rendering (Mesh, Material, Camera)
|
||||||
|
this.setupRenderMesh(scene, config, buffers.positions);
|
||||||
|
|
||||||
|
// 6. Start the physics loop
|
||||||
|
this.startRenderLoop(engine, scene, config, buffers, pipelines);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========================================================================
|
||||||
|
// 1. CONFIGURATION
|
||||||
|
// ========================================================================
|
||||||
|
private getClothConfig(): ClothConfig {
|
||||||
const gridWidth = 100;
|
const gridWidth = 100;
|
||||||
const gridHeight = 100;
|
const gridHeight = 100;
|
||||||
const spacing = 0.05;
|
const spacing = 0.05;
|
||||||
const numVertices = gridWidth * gridHeight;
|
|
||||||
const density = 1.0;
|
const density = 1.0;
|
||||||
const particleArea = spacing * spacing;
|
const particleArea = spacing * spacing;
|
||||||
const particleMass = density * particleArea;
|
const particleMass = density * particleArea;
|
||||||
const particleInvMass = 1.0 / particleMass;
|
|
||||||
|
|
||||||
const positionsData = new Float32Array(numVertices * 4);
|
return {
|
||||||
const prevPositionsData = new Float32Array(numVertices * 4);
|
gridWidth,
|
||||||
const velocitiesData = new Float32Array(numVertices * 4);
|
gridHeight,
|
||||||
|
spacing,
|
||||||
|
density,
|
||||||
|
numVertices: gridWidth * gridHeight,
|
||||||
|
particleInvMass: 1.0 / particleMass
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========================================================================
|
||||||
|
// 2. DATA GENERATION (CPU)
|
||||||
|
// ========================================================================
|
||||||
|
private generateClothData(config: ClothConfig): ClothData {
|
||||||
|
const positionsData = new Float32Array(config.numVertices * 4);
|
||||||
|
const prevPositionsData = new Float32Array(config.numVertices * 4);
|
||||||
|
const velocitiesData = new Float32Array(config.numVertices * 4);
|
||||||
|
|
||||||
// Arrays for our 4 phases (dynamic size as we push)
|
|
||||||
const constraintsP0: number[] = [];
|
const constraintsP0: number[] = [];
|
||||||
const constraintsP1: number[] = [];
|
const constraintsP1: number[] = [];
|
||||||
const constraintsP2: number[] = [];
|
const constraintsP2: number[] = [];
|
||||||
const constraintsP3: number[] = [];
|
const constraintsP3: number[] = [];
|
||||||
|
|
||||||
// Helper function for clean adding (vec4 structure)
|
|
||||||
const addConstraint = (arr: number[], a: number, b: number): void => {
|
const addConstraint = (arr: number[], a: number, b: number): void => {
|
||||||
arr.push(a, b, spacing, 1.0);
|
arr.push(a, b, config.spacing, 1.0);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fill positions and pin the top edge
|
// Fill positions (Pin top row)
|
||||||
for (let y = 0; y < gridHeight; y++) {
|
for (let y = 0; y < config.gridHeight; y++) {
|
||||||
for (let x = 0; x < gridWidth; x++) {
|
for (let x = 0; x < config.gridWidth; x++) {
|
||||||
const idx = (y * gridWidth + x) * 4;
|
const idx = (y * config.gridWidth + x) * 4;
|
||||||
positionsData[idx + 0] = (x - gridWidth / 2) * spacing;
|
positionsData[idx + 0] = (x - config.gridWidth / 2) * config.spacing;
|
||||||
positionsData[idx + 1] = 5.0 - (y * spacing);
|
positionsData[idx + 1] = 5.0 - (y * config.spacing);
|
||||||
positionsData[idx + 2] = 0.0;
|
positionsData[idx + 2] = 0.0;
|
||||||
positionsData[idx + 3] = (y === 0) ? 0.0 : particleInvMass;
|
positionsData[idx + 3] = (y === 0) ? 0.0 : config.particleInvMass;
|
||||||
|
|
||||||
prevPositionsData[idx + 0] = positionsData[idx + 0];
|
prevPositionsData[idx + 0] = positionsData[idx + 0];
|
||||||
prevPositionsData[idx + 1] = positionsData[idx + 1];
|
prevPositionsData[idx + 1] = positionsData[idx + 1];
|
||||||
@@ -108,72 +184,97 @@ export class ClothComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- GRAPH COLORING: Fill constraints in 4 phases ---
|
// Graph Coloring (4 Phases)
|
||||||
// Phase 0: Horizontal Even
|
for (let y = 0; y < config.gridHeight; y++) {
|
||||||
for (let y = 0; y < gridHeight; y++) {
|
for (let x = 0; x < config.gridWidth - 1; x += 2) addConstraint(constraintsP0, y * config.gridWidth + x, y * config.gridWidth + x + 1);
|
||||||
for (let x = 0; x < gridWidth - 1; x += 2) {
|
for (let x = 1; x < config.gridWidth - 1; x += 2) addConstraint(constraintsP1, y * config.gridWidth + x, y * config.gridWidth + x + 1);
|
||||||
addConstraint(constraintsP0, y * gridWidth + x, y * gridWidth + x + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Phase 1: Horizontal Odd
|
for (let y = 0; y < config.gridHeight - 1; y += 2) {
|
||||||
for (let y = 0; y < gridHeight; y++) {
|
for (let x = 0; x < config.gridWidth; x++) addConstraint(constraintsP2, y * config.gridWidth + x, (y + 1) * config.gridWidth + x);
|
||||||
for (let x = 1; x < gridWidth - 1; x += 2) {
|
|
||||||
addConstraint(constraintsP1, y * gridWidth + x, y * gridWidth + x + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Phase 2: Vertical Even
|
for (let y = 1; y < config.gridHeight - 1; y += 2) {
|
||||||
for (let y = 0; y < gridHeight - 1; y += 2) {
|
for (let x = 0; x < config.gridWidth; x++) addConstraint(constraintsP3, y * config.gridWidth + x, (y + 1) * config.gridWidth + x);
|
||||||
for (let x = 0; x < gridWidth; x++) {
|
|
||||||
addConstraint(constraintsP2, y * gridWidth + x, (y + 1) * gridWidth + x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Phase 3: Vertical Odd
|
|
||||||
for (let y = 1; y < gridHeight - 1; y += 2) {
|
const constraintsP4: number[] = [];
|
||||||
for (let x = 0; x < gridWidth; x++) {
|
const constraintsP5: number[] = [];
|
||||||
addConstraint(constraintsP3, y * gridWidth + x, (y + 1) * gridWidth + x);
|
const constraintsP6: number[] = [];
|
||||||
|
const constraintsP7: number[] = [];
|
||||||
|
|
||||||
|
const diagSpacing = config.spacing * Math.SQRT2;
|
||||||
|
const addDiagConstraint = (arr: number[], a: number, b: number): void => {
|
||||||
|
arr.push(a, b, diagSpacing, 1.0);
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let y = 0; y < config.gridHeight - 1; y++) {
|
||||||
|
const arr = (y % 2 === 0) ? constraintsP4 : constraintsP5;
|
||||||
|
for (let x = 0; x < config.gridWidth - 1; x++) {
|
||||||
|
addDiagConstraint(arr, y * config.gridWidth + x, (y + 1) * config.gridWidth + (x + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const paramsData = new Float32Array(8);
|
for (let y = 0; y < config.gridHeight - 1; y++) {
|
||||||
|
const arr = (y % 2 === 0) ? constraintsP6 : constraintsP7;
|
||||||
|
for (let x = 0; x < config.gridWidth - 1; x++) {
|
||||||
|
addDiagConstraint(arr, y * config.gridWidth + (x + 1), (y + 1) * config.gridWidth + x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- 2. CREATE GPU STORAGE BUFFERS ---
|
return {
|
||||||
const positionsBuffer = new StorageBuffer(engine, positionsData.byteLength);
|
positions: positionsData,
|
||||||
positionsBuffer.update(positionsData);
|
prevPositions: prevPositionsData,
|
||||||
|
velocities: velocitiesData,
|
||||||
|
constraints: [
|
||||||
|
constraintsP0, constraintsP1, constraintsP2, constraintsP3,
|
||||||
|
constraintsP4, constraintsP5, constraintsP6, constraintsP7
|
||||||
|
],
|
||||||
|
params: new Float32Array(8)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const prevPositionsBuffer = new StorageBuffer(engine, prevPositionsData.byteLength);
|
// ========================================================================
|
||||||
prevPositionsBuffer.update(prevPositionsData);
|
// 3. BUFFER CREATION (GPU)
|
||||||
|
// ========================================================================
|
||||||
const velocitiesBuffer = new StorageBuffer(engine, velocitiesData.byteLength);
|
private createStorageBuffers(engine: WebGPUEngine, data: ClothData): ClothBuffers {
|
||||||
const paramsBuffer = new StorageBuffer(engine, paramsData.byteLength);
|
const createBuffer = (arrayData: Float32Array | number[]): StorageBuffer => {
|
||||||
|
const buffer = new StorageBuffer(engine, arrayData.length * 4);
|
||||||
// Create 4 separate buffers for the 4 phases
|
buffer.update(arrayData instanceof Float32Array ? arrayData : new Float32Array(arrayData));
|
||||||
const createAndPopulateBuffer = (data: number[]): StorageBuffer => {
|
|
||||||
const buffer = new StorageBuffer(engine, data.length * 4);
|
|
||||||
buffer.update(new Float32Array(data));
|
|
||||||
return buffer;
|
return buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
const cBuffer0 = createAndPopulateBuffer(constraintsP0);
|
return {
|
||||||
const cBuffer1 = createAndPopulateBuffer(constraintsP1);
|
positions: createBuffer(data.positions),
|
||||||
const cBuffer2 = createAndPopulateBuffer(constraintsP2);
|
prevPositions: createBuffer(data.prevPositions),
|
||||||
const cBuffer3 = createAndPopulateBuffer(constraintsP3);
|
velocities: createBuffer(data.velocities),
|
||||||
|
params: createBuffer(data.params),
|
||||||
|
constraints: data.constraints.map(cData => createBuffer(cData))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// --- 3. SETUP COMPUTE SHADERS ---
|
// ========================================================================
|
||||||
const csIntegrate = new ComputeShader("integrate", engine, { computeSource: CLOTH_INTEGRATE_COMPUTE_WGSL }, {
|
// 4. COMPUTE SHADERS
|
||||||
bindingsMapping: {
|
// ========================================================================
|
||||||
"p": { group: 0, binding: 0 },
|
private setupComputePipelines(engine: WebGPUEngine, buffers: ClothBuffers): ClothPipelines {
|
||||||
"positions": { group: 0, binding: 1 },
|
|
||||||
"prev_positions": { group: 0, binding: 2 },
|
|
||||||
"velocities": { group: 0, binding: 3 }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
csIntegrate.setStorageBuffer("p", paramsBuffer);
|
|
||||||
csIntegrate.setStorageBuffer("positions", positionsBuffer);
|
|
||||||
csIntegrate.setStorageBuffer("prev_positions", prevPositionsBuffer);
|
|
||||||
csIntegrate.setStorageBuffer("velocities", velocitiesBuffer);
|
|
||||||
|
|
||||||
// Helper function to create the 4 solve shaders
|
// Helper for integrating & velocity
|
||||||
const createSolver = (name: string, cBuffer: StorageBuffer): ComputeShader => {
|
const createBasicShader = (name: string, source: string) => {
|
||||||
|
const cs = new ComputeShader(name, engine, { computeSource: source }, {
|
||||||
|
bindingsMapping: {
|
||||||
|
"p": { group: 0, binding: 0 },
|
||||||
|
"positions": { group: 0, binding: 1 },
|
||||||
|
"prev_positions": { group: 0, binding: 2 },
|
||||||
|
"velocities": { group: 0, binding: 3 }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cs.setStorageBuffer("p", buffers.params);
|
||||||
|
cs.setStorageBuffer("positions", buffers.positions);
|
||||||
|
cs.setStorageBuffer("prev_positions", buffers.prevPositions);
|
||||||
|
cs.setStorageBuffer("velocities", buffers.velocities);
|
||||||
|
return cs;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper for solvers
|
||||||
|
const createSolverShader = (name: string, constraintBuffer: StorageBuffer) => {
|
||||||
const cs = new ComputeShader(name, engine, { computeSource: CLOTH_SOLVE_COMPUTE_WGSL }, {
|
const cs = new ComputeShader(name, engine, { computeSource: CLOTH_SOLVE_COMPUTE_WGSL }, {
|
||||||
bindingsMapping: {
|
bindingsMapping: {
|
||||||
"p": { group: 0, binding: 0 },
|
"p": { group: 0, binding: 0 },
|
||||||
@@ -181,36 +282,28 @@ export class ClothComponent {
|
|||||||
"constraints": { group: 0, binding: 2 }
|
"constraints": { group: 0, binding: 2 }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cs.setStorageBuffer("p", paramsBuffer);
|
cs.setStorageBuffer("p", buffers.params);
|
||||||
cs.setStorageBuffer("positions", positionsBuffer);
|
cs.setStorageBuffer("positions", buffers.positions);
|
||||||
cs.setStorageBuffer("constraints", cBuffer);
|
cs.setStorageBuffer("constraints", constraintBuffer);
|
||||||
return cs;
|
return cs;
|
||||||
};
|
};
|
||||||
|
|
||||||
const csSolve0 = createSolver("solve0", cBuffer0);
|
return {
|
||||||
const csSolve1 = createSolver("solve1", cBuffer1);
|
integrate: createBasicShader("integrate", CLOTH_INTEGRATE_COMPUTE_WGSL),
|
||||||
const csSolve2 = createSolver("solve2", cBuffer2);
|
solvers: buffers.constraints.map((cBuffer, i) => createSolverShader(`solve${i}`, cBuffer)),
|
||||||
const csSolve3 = createSolver("solve3", cBuffer3);
|
velocity: createBasicShader("velocity", CLOTH_VELOCITY_COMPUTE_WGSL)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const csVelocity = new ComputeShader("velocity", engine, { computeSource: CLOTH_VELOCITY_COMPUTE_WGSL }, {
|
// ========================================================================
|
||||||
bindingsMapping: {
|
// 5. RENDERING SETUP
|
||||||
"p": { group: 0, binding: 0 },
|
// ========================================================================
|
||||||
"positions": { group: 0, binding: 1 },
|
private setupRenderMesh(scene: Scene, config: ClothConfig, positionsBuffer: StorageBuffer): void {
|
||||||
"prev_positions": { group: 0, binding: 2 },
|
if (this.clothMesh) {
|
||||||
"velocities": { group: 0, binding: 3 }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
csVelocity.setStorageBuffer("p", paramsBuffer);
|
|
||||||
csVelocity.setStorageBuffer("positions", positionsBuffer);
|
|
||||||
csVelocity.setStorageBuffer("prev_positions", prevPositionsBuffer);
|
|
||||||
csVelocity.setStorageBuffer("velocities", velocitiesBuffer);
|
|
||||||
|
|
||||||
// --- 4. SETUP RENDER MESH ---
|
|
||||||
if (this.clothMesh)
|
|
||||||
{
|
|
||||||
scene.removeMesh(this.clothMesh);
|
scene.removeMesh(this.clothMesh);
|
||||||
}
|
}
|
||||||
this.clothMesh = MeshBuilder.CreateGround("cloth", { width: 10, height: 10, subdivisions: gridWidth - 1 }, scene);
|
|
||||||
|
this.clothMesh = MeshBuilder.CreateGround("cloth", { width: 10, height: 10, subdivisions: config.gridWidth - 1 }, scene);
|
||||||
|
|
||||||
const clothMaterial = new ShaderMaterial("clothMat", scene, {
|
const clothMaterial = new ShaderMaterial("clothMat", scene, {
|
||||||
vertexSource: CLOTH_VERTEX_SHADER_WGSL,
|
vertexSource: CLOTH_VERTEX_SHADER_WGSL,
|
||||||
@@ -232,46 +325,53 @@ export class ClothComponent {
|
|||||||
camera.beta = Math.PI / 2.5;
|
camera.beta = Math.PI / 2.5;
|
||||||
camera.radius = 15;
|
camera.radius = 15;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========================================================================
|
||||||
|
// 6. RENDER LOOP
|
||||||
|
// ========================================================================
|
||||||
|
private startRenderLoop(engine: WebGPUEngine, scene: Scene, config: ClothConfig, buffers: ClothBuffers, pipelines: ClothPipelines): void {
|
||||||
|
const paramsData = new Float32Array(8);
|
||||||
|
|
||||||
|
// Pre-calculate constraint dispatch sizes for the 4 phases
|
||||||
|
const constraintsLength = buffers.constraints.map(b => (b as any)._buffer.capacity / 4 / 4); // Elements / vec4 length
|
||||||
|
const dispatchXConstraints = constraintsLength.map(len => Math.ceil(len / 64));
|
||||||
|
const dispatchXVertices = Math.ceil(config.numVertices / 64);
|
||||||
|
const substeps = 15;
|
||||||
|
|
||||||
// --- 5. RENDER LOOP ---
|
|
||||||
scene.onBeforeRenderObservable.clear();
|
scene.onBeforeRenderObservable.clear();
|
||||||
scene.onBeforeRenderObservable.add(() => {
|
scene.onBeforeRenderObservable.add(() => {
|
||||||
this.simulationTime += engine.getDeltaTime() / 1000.0;
|
this.simulationTime += engine.getDeltaTime() / 1000.0;
|
||||||
|
|
||||||
|
// Update Physics Parameters
|
||||||
const windX = this.isWindActive ? 5.0 : 0.0;
|
const windX = this.isWindActive ? 5.0 : 0.0;
|
||||||
const windY = 0.0;
|
const windY = 0.0;
|
||||||
const windZ = this.isWindActive ? 15.0 : 0.0;
|
const windZ = this.isWindActive ? 15.0 : 0.0;
|
||||||
|
const scaledCompliance = 0.00001 * config.particleInvMass * config.spacing;
|
||||||
|
|
||||||
const baseCompliance = 0.00001;
|
paramsData[0] = 0.016; // dt
|
||||||
const scaledCompliance = baseCompliance * particleInvMass * spacing;
|
paramsData[1] = -9.81; // gravity
|
||||||
|
paramsData[2] = scaledCompliance;
|
||||||
paramsData[0] = 0.016;
|
paramsData[3] = config.numVertices;
|
||||||
paramsData[1] = -9.81;
|
|
||||||
paramsData[2] = scaledCompliance; //scaled stiffness
|
|
||||||
paramsData[3] = numVertices;
|
|
||||||
paramsData[4] = windX;
|
paramsData[4] = windX;
|
||||||
paramsData[5] = windY;
|
paramsData[5] = windY;
|
||||||
paramsData[6] = windZ;
|
paramsData[6] = windZ;
|
||||||
paramsData[7] = this.simulationTime;
|
paramsData[7] = this.simulationTime;
|
||||||
|
|
||||||
paramsBuffer.update(paramsData);
|
buffers.params.update(paramsData);
|
||||||
|
|
||||||
const dispatchXVertices = Math.ceil(numVertices / 64);
|
|
||||||
|
|
||||||
// 1. Predict positions
|
// 1. Predict positions
|
||||||
csIntegrate.dispatch(dispatchXVertices, 1, 1);
|
pipelines.integrate.dispatch(dispatchXVertices, 1, 1);
|
||||||
|
|
||||||
// 2. XPBD Solver (Substeps) - Solve each color individually
|
// 2. XPBD Solver (Substeps) - Graph Coloring Phase
|
||||||
const substeps = 15;
|
|
||||||
for (let i = 0; i < substeps; i++) {
|
for (let i = 0; i < substeps; i++) {
|
||||||
csSolve0.dispatch(Math.ceil((constraintsP0.length / 4) / 64), 1, 1);
|
for (let phase = 0; phase < pipelines.solvers.length; phase++) {
|
||||||
csSolve1.dispatch(Math.ceil((constraintsP1.length / 4) / 64), 1, 1);
|
pipelines.solvers[phase].dispatch(dispatchXConstraints[phase], 1, 1);
|
||||||
csSolve2.dispatch(Math.ceil((constraintsP2.length / 4) / 64), 1, 1);
|
}
|
||||||
csSolve3.dispatch(Math.ceil((constraintsP3.length / 4) / 64), 1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Update velocities
|
// 3. Update velocities
|
||||||
csVelocity.dispatch(dispatchXVertices, 1, 1);
|
pipelines.velocity.dispatch(dispatchXVertices, 1, 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
36
src/app/pages/algorithms/cloth/cloth.model.ts
Normal file
36
src/app/pages/algorithms/cloth/cloth.model.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// --- SIMULATION CONFIGURATION ---
|
||||||
|
import {ComputeShader, StorageBuffer} from '@babylonjs/core';
|
||||||
|
|
||||||
|
export interface ClothConfig {
|
||||||
|
gridWidth: number;
|
||||||
|
gridHeight: number;
|
||||||
|
spacing: number;
|
||||||
|
density: number;
|
||||||
|
numVertices: number;
|
||||||
|
particleInvMass: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- RAW CPU DATA ---
|
||||||
|
export interface ClothData {
|
||||||
|
positions: Float32Array;
|
||||||
|
prevPositions: Float32Array;
|
||||||
|
velocities: Float32Array;
|
||||||
|
constraints: number[][]; // Array containing the 4 phases
|
||||||
|
params: Float32Array;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- WEBGPU BUFFERS ---
|
||||||
|
export interface ClothBuffers {
|
||||||
|
positions: StorageBuffer;
|
||||||
|
prevPositions: StorageBuffer;
|
||||||
|
velocities: StorageBuffer;
|
||||||
|
params: StorageBuffer;
|
||||||
|
constraints: StorageBuffer[]; // 4 phase buffers
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- COMPUTE PIPELINES ---
|
||||||
|
export interface ClothPipelines {
|
||||||
|
integrate: ComputeShader;
|
||||||
|
solvers: ComputeShader[]; // 4 solve shaders
|
||||||
|
velocity: ComputeShader;
|
||||||
|
}
|
||||||
@@ -22,22 +22,23 @@ export const CLOTH_SHARED_STRUCTS = `
|
|||||||
// ==========================================
|
// ==========================================
|
||||||
export const CLOTH_VERTEX_SHADER_WGSL = `
|
export const CLOTH_VERTEX_SHADER_WGSL = `
|
||||||
attribute uv : vec2<f32>;
|
attribute uv : vec2<f32>;
|
||||||
|
|
||||||
// Storage Buffer
|
|
||||||
var<storage, read> positions : array<vec4<f32>>;
|
var<storage, read> positions : array<vec4<f32>>;
|
||||||
|
|
||||||
// Babylon Preprocessor Magic
|
|
||||||
uniform viewProjection : mat4x4<f32>;
|
uniform viewProjection : mat4x4<f32>;
|
||||||
|
|
||||||
|
// Varyings, um Daten an den Fragment-Shader zu senden
|
||||||
varying vUV : vec2<f32>;
|
varying vUV : vec2<f32>;
|
||||||
|
varying vWorldPos : vec3<f32>; // NEU: Wir brauchen die 3D-Position für das Licht!
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn main(input : VertexInputs) -> FragmentInputs {
|
fn main(input : VertexInputs) -> FragmentInputs {
|
||||||
var output : FragmentInputs;
|
var output : FragmentInputs;
|
||||||
|
|
||||||
let worldPos = positions[input.vertexIndex].xyz;
|
let worldPos = positions[input.vertexIndex].xyz;
|
||||||
|
|
||||||
output.position = uniforms.viewProjection * vec4<f32>(worldPos, 1.0);
|
output.position = uniforms.viewProjection * vec4<f32>(worldPos, 1.0);
|
||||||
|
|
||||||
output.vUV = input.uv;
|
output.vUV = input.uv;
|
||||||
|
output.vWorldPos = worldPos; // Position weitergeben
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@@ -48,13 +49,24 @@ export const CLOTH_VERTEX_SHADER_WGSL = `
|
|||||||
// ==========================================
|
// ==========================================
|
||||||
export const CLOTH_FRAGMENT_SHADER_WGSL = `
|
export const CLOTH_FRAGMENT_SHADER_WGSL = `
|
||||||
varying vUV : vec2<f32>;
|
varying vUV : vec2<f32>;
|
||||||
|
varying vWorldPos : vec3<f32>;
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn main(input: FragmentInputs) -> FragmentOutputs {
|
fn main(input: FragmentInputs) -> FragmentOutputs {
|
||||||
var output: FragmentOutputs;
|
var output: FragmentOutputs;
|
||||||
|
|
||||||
let color = vec3<f32>(input.vUV.x * 0.8, input.vUV.y * 0.8, 0.9);
|
let dx = dpdx(input.vWorldPos);
|
||||||
output.color = vec4<f32>(color, 1.0);
|
let dy = dpdy(input.vWorldPos);
|
||||||
|
let normal = normalize(cross(dx, dy));
|
||||||
|
let lightDir = normalize(vec3<f32>(1.0, 1.0, 0.5));
|
||||||
|
let diffuse = max(0.0, abs(dot(normal, lightDir)));
|
||||||
|
let ambient = 0.3;
|
||||||
|
let lightIntensity = ambient + (diffuse * 0.7);
|
||||||
|
let grid = (floor(input.vUV.x * 20.0) + floor(input.vUV.y * 20.0)) % 2.0;
|
||||||
|
let baseColor = mix(vec3<f32>(0.8, 0.4, 0.15), vec3<f32>(0.9, 0.5, 0.2), grid);
|
||||||
|
let finalColor = baseColor * lightIntensity;
|
||||||
|
|
||||||
|
output.color = vec4<f32>(finalColor, 1.0);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,14 @@
|
|||||||
@for (algo of algorithmInformation.entries; track algo)
|
@for (algo of algorithmInformation.entries; track algo)
|
||||||
{
|
{
|
||||||
<p>
|
<p>
|
||||||
<strong>{{ algo.name }}</strong> {{ algo.description | translate }}
|
<strong>
|
||||||
|
@if(algo.translateName){
|
||||||
|
{{ algo.name | translate}}
|
||||||
|
} @else {
|
||||||
|
{{ algo.name }}
|
||||||
|
}
|
||||||
|
</strong>
|
||||||
|
{{ algo.description | translate }}
|
||||||
<a href="{{algo.link}}" target="_blank" rel="noopener noreferrer">Wikipedia</a>
|
<a href="{{algo.link}}" target="_blank" rel="noopener noreferrer">Wikipedia</a>
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ export interface AlgorithmEntry {
|
|||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
link: string;
|
link: string;
|
||||||
|
translateName?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,8 @@
|
|||||||
"K8S": "Kubernetes / k3d",
|
"K8S": "Kubernetes / k3d",
|
||||||
"POSTGRES": "PostgreSQL",
|
"POSTGRES": "PostgreSQL",
|
||||||
"MONGO": "MongoDB",
|
"MONGO": "MongoDB",
|
||||||
"GRAFANA": "Grafana/Prometheus"
|
"GRAFANA": "Grafana/Prometheus",
|
||||||
|
"DOCKER": "Docker"
|
||||||
},
|
},
|
||||||
"XP": {
|
"XP": {
|
||||||
"COMPANY8": {
|
"COMPANY8": {
|
||||||
@@ -472,9 +473,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CLOTH": {
|
"CLOTH": {
|
||||||
"TITLE": "Stoff-Simulation",
|
"TITLE": "Stoffsimulation",
|
||||||
"WIND_ON": "Wind Einschalten",
|
"WIND_ON": "Wind Einschalten",
|
||||||
"WIND_OFF": "Wind Ausschalten"
|
"WIND_OFF": "Wind Ausschalten",
|
||||||
|
"OUTLINE_ON": "Mesh anzeigen",
|
||||||
|
"OUTLINE_OFF": "Mesh ausschalten",
|
||||||
|
"EXPLANATION": {
|
||||||
|
"TITLE": "Echtzeit-Stoffsimulation auf der GPU",
|
||||||
|
"CLOTH_SIMULATION_EXPLANATION_TITLE": "Stoffsimulation",
|
||||||
|
"XPBD_EXPLANATION_TITLE": "XPBD (Extended Position-Based Dynamics)",
|
||||||
|
"GPU_PARALLELIZATION_EXPLANATION_TITLE": "GPU Parallelisierung",
|
||||||
|
"DATA_STRUCTURES_EXPLANATION_TITLE": "Datenstrukturen",
|
||||||
|
"CLOTH_SIMULATION_EXPLANATION": "Stoffsimulationen modellieren Textilien meist als ein Gitter aus Massepunkten (Vertices), die durch unsichtbare Verbindungen zusammengehalten werden. Ziel ist es, physikalische Einflüsse wie Schwerkraft, Wind und Kollisionen in Echtzeit darzustellen, ohne dass das Material zerreißt oder sich unnatürlich wie Gummi dehnt.",
|
||||||
|
"XPBD_EXPLANATION": "XPBD (Extended Position-Based Dynamics) ist ein moderner Algorithmus, der statt Beschleunigungen direkt die Positionen der Punkte manipuliert, um Abstandsbedingungen (Constraints) zu erfüllen. Das 'Extended' bedeutet, dass echte physikalische Steifigkeit unabhängig von der Framerate simuliert wird. Vorteil: Absolut stabil, explodiert nicht und topologische Änderungen (wie das Zerschneiden von Stoff) sind trivial. Nachteil: Es ist ein iteratives Näherungsverfahren und physikalisch minimal weniger akkurat als komplexe Matrix-Löser.",
|
||||||
|
"GPU_PARALLELIZATION_EXPLANATION": "Um zehntausende Punkte parallel auf der Grafikkarte zu berechnen, muss man 'Race Conditions' verhindern – also dass zwei Rechenkerne gleichzeitig denselben Knotenpunkt verschieben. Die Lösung nennt sich 'Independent Sets' (oder Graph Coloring): Die Verbindungen werden in isolierte Gruppen (z. B. 4 Phasen bei einem Gitter) unterteilt, in denen sich kein einziger Punkt überschneidet. So kann die GPU jede Gruppe blind und mit maximaler Geschwindigkeit abarbeiten.",
|
||||||
|
"DATA_STRUCTURES_EXPLANATION": "Für maximale GPU-Performance müssen Daten speicherfreundlich ausgerichtet werden (16-Byte-Alignment). Anstatt viele einzelne Variablen zu nutzen, packt man Informationen clever in 4er-Blöcke (vec4). Ein Vertex speichert so z. B. [X, Y, Z, Inverse_Masse]. Hat ein Punkt die inverse Masse 0.0, wird er vom Algorithmus ignoriert und schwebt unbeweglich in der Luft – ein eleganter Trick für Aufhängungen ohne extra Wenn-Dann-Abfragen.",
|
||||||
|
"DISCLAIMER": "XPBD vs. Masse-Feder-Systeme: In der physikalischen Simulation gibt es grundlegende Architektur-Unterschiede beim Lösen der Gleichungen:",
|
||||||
|
"DISCLAIMER_1": "Klassische Masse-Feder-Systeme: Hier werden Kräfte (Hookesches Gesetz) berechnet, die zu Beschleunigungen und schließlich zu neuen Positionen führen. Es gibt zwei Wege, diese mathematisch in die Zukunft zu rechnen (Integration):",
|
||||||
|
"DISCLAIMER_2": "Explizite Löser (z.B. Forward Euler): Sie berechnen den nächsten Schritt stur aus dem aktuellen Zustand. Sie sind leicht zu programmieren, aber bei steifen Stoffen extrem instabil. Die Kräfte schaukeln sich auf und die Simulation 'explodiert', sofern man keine winzigen, sehr leistungsfressenden Zeitschritte wählt.",
|
||||||
|
"DISCLAIMER_3": "Implizite Löser (z.B. Backward Euler): Sie berechnen den nächsten Schritt basierend auf dem zukünftigen Zustand. Das ist mathematisch enorm stabil, erfordert aber das Lösen riesiger globaler Matrix-Gleichungssysteme in jedem Frame. Dies ist auf der GPU schwerer zu parallelisieren und bricht zusammen, wenn sich die Struktur ändert (z. B. durch Zerschneiden des Stoffs).",
|
||||||
|
"DISCLAIMER_4": "Der XPBD-Kompromiss: XPBD umgeht dieses komplexe Matrix-Problem völlig, indem es als lokaler Löser arbeitet. Es kombiniert die unbedingte Stabilität eines impliziten Lösers mit der enormen Geschwindigkeit, Parallelisierbarkeit und dynamischen Anpassungsfähigkeit eines expliziten Systems."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ALGORITHM": {
|
"ALGORITHM": {
|
||||||
"TITLE": "Algorithmen",
|
"TITLE": "Algorithmen",
|
||||||
@@ -507,9 +526,9 @@
|
|||||||
"DESCRIPTION": "Visualisierung einer chaotischen Doppel-Pendel-Simulation mit WebGPU."
|
"DESCRIPTION": "Visualisierung einer chaotischen Doppel-Pendel-Simulation mit WebGPU."
|
||||||
},
|
},
|
||||||
"CLOTH": {
|
"CLOTH": {
|
||||||
"TITLE": "Stoff-Simulation",
|
"TITLE": "Stoffsimulation",
|
||||||
"DESCRIPTION": "Simulation on Stoff mit WebGPU."
|
"DESCRIPTION": "Simulation on Stoff mit WebGPU."
|
||||||
}
|
},
|
||||||
"NOTE": "HINWEIS",
|
"NOTE": "HINWEIS",
|
||||||
"GRID_HEIGHT": "Höhe",
|
"GRID_HEIGHT": "Höhe",
|
||||||
"GRID_WIDTH": "Beite"
|
"GRID_WIDTH": "Beite"
|
||||||
|
|||||||
@@ -57,7 +57,8 @@
|
|||||||
"K8S": "Kubernetes / k3d",
|
"K8S": "Kubernetes / k3d",
|
||||||
"POSTGRES": "PostgreSQL",
|
"POSTGRES": "PostgreSQL",
|
||||||
"MONGO": "MongoDB",
|
"MONGO": "MongoDB",
|
||||||
"GRAFANA": "Grafana/Prometheus"
|
"GRAFANA": "Grafana/Prometheus",
|
||||||
|
"DOCKER": "Docker"
|
||||||
},
|
},
|
||||||
"XP": {
|
"XP": {
|
||||||
"COMPANY8": {
|
"COMPANY8": {
|
||||||
@@ -473,7 +474,25 @@
|
|||||||
"CLOTH": {
|
"CLOTH": {
|
||||||
"TITLE": "Cloth simulation",
|
"TITLE": "Cloth simulation",
|
||||||
"WIND_ON": "Wind On",
|
"WIND_ON": "Wind On",
|
||||||
"WIND_OFF": "Wind Off"
|
"WIND_OFF": "Wind Off",
|
||||||
|
"OUTLINE_ON": "Show Mesh",
|
||||||
|
"OUTLINE_OFF": "Hide Mesh",
|
||||||
|
"EXPLANATION": {
|
||||||
|
"TITLE": "Real-time Cloth Simulation on the GPU",
|
||||||
|
"CLOTH_SIMULATION_EXPLANATION_TITLE": "Cloth Simulation",
|
||||||
|
"XPBD_EXPLANATION_TITLE": "XPBD (Extended Position-Based Dynamics)",
|
||||||
|
"GPU_PARALLELIZATION_EXPLANATION_TITLE": "GPU Parallelization",
|
||||||
|
"DATA_STRUCTURES_EXPLANATION_TITLE": "Data Structures",
|
||||||
|
"CLOTH_SIMULATION_EXPLANATION": "Cloth simulations usually model textiles as a grid of mass points (vertices) held together by invisible connections. The goal is to represent physical influences like gravity, wind, and collisions in real time without the material tearing or stretching unnaturally like rubber.",
|
||||||
|
"XPBD_EXPLANATION": "XPBD (Extended Position-Based Dynamics) is a modern algorithm that manipulates point positions directly to satisfy distance conditions (constraints) instead of calculating accelerations. The 'Extended' means that true physical stiffness is simulated independently of the framerate. Advantage: Absolutely stable, does not explode, and topological changes (like cutting cloth) are trivial. Disadvantage: It is an iterative approximation method and slightly less physically accurate than complex matrix solvers.",
|
||||||
|
"GPU_PARALLELIZATION_EXPLANATION": "To calculate tens of thousands of points in parallel on the graphics card, one must prevent 'race conditions' – i.e., two processing cores shifting the same node at the exact same time. The solution is called 'Independent Sets' (or Graph Coloring): The connections are divided into isolated groups (e.g., 4 phases for a 2D grid) in which not a single point overlaps. This allows the GPU to process each group blindly and at maximum speed.",
|
||||||
|
"DATA_STRUCTURES_EXPLANATION": "For maximum GPU performance, data must be memory-aligned (16-byte alignment). Instead of using many individual variables, information is cleverly packed into blocks of four (vec4). A vertex stores, for example, [X, Y, Z, Inverse_Mass]. If a point has an inverse mass of 0.0, the algorithm ignores it, and it floats motionlessly in the air – an elegant trick for pinning cloth without extra if/then statements.",
|
||||||
|
"DISCLAIMER": "XPBD vs. Mass-Spring Systems: In physical simulations, there are fundamental architectural differences when solving equations:",
|
||||||
|
"DISCLAIMER_1": "Classical Mass-Spring Systems: Here, forces (Hooke's Law) are calculated, leading to accelerations and ultimately new positions. There are two ways to mathematically project these into the future (integration):",
|
||||||
|
"DISCLAIMER_2": "Explicit Solvers (e.g., Forward Euler): These rigidly calculate the next step solely from the current state. They are easy to program but extremely unstable for stiff cloths. Forces can escalate and the simulation 'explodes' unless tiny, very performance-heavy time steps are chosen.",
|
||||||
|
"DISCLAIMER_3": "Implicit Solvers (e.g., Backward Euler): These calculate the next step based on the future state. This is mathematically highly stable but requires solving massive global matrix equation systems in every frame. This is harder to parallelize on the GPU and breaks down if the structure changes (e.g., when the cloth is cut).",
|
||||||
|
"DISCLAIMER_4": "The XPBD Compromise: XPBD completely bypasses this complex matrix problem by acting as a local solver. It combines the absolute stability of an implicit solver with the enormous speed, parallelizability, and dynamic adaptability of an explicit system."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ALGORITHM": {
|
"ALGORITHM": {
|
||||||
"TITLE": "Algorithms",
|
"TITLE": "Algorithms",
|
||||||
|
|||||||
Reference in New Issue
Block a user