static void Main(string[] args) { // Setup var form = SlimDXHelper.InitD3D(out _device, out _swapChain, out _renderView); var temp = form.ClientRectangle; _finalRender = new FSQ(_device, _renderView, "SimpleFSQ.fx"); /*_simulation = * new HybridFluidSim( * _finalRender, * _device);*/ _simulation = new SemiGridSPHSimulation(_device, _finalRender.UAV); //_simulation = new MovingGridFluid.MovingGridFluid(_device, _finalRender.UAV); // Main loop MessagePump.Run(form, SimMain); // Tear down _finalRender.Dispose(); _swapChain.Dispose(); _renderView.Dispose(); _simulation.Dispose(); _device.Dispose(); }
/// <summary> /// A fluid simulation using a hybrid SPH and grid /// based method. Each SPH particle is calculated /// against a fixed number of other particles, with /// the results scaled to account for the particles /// which are not tested against /// </summary> public HybridFluidSim(FSQ finalRender, Device device) { _finalRender = finalRender ?? throw new ArgumentNullException(nameof(finalRender)); _device = device ?? throw new ArgumentNullException(nameof(device)); var generatedFilename = GenerateTempFile( "HybridFluid/HybridFluidComputeShaders2.hlsl", ParticleOutputShader.MarkupList. Concat(ParticleUpdateShader.MarkupList). Concat(WriteParticlesToSubspaceShader.MarkupList)); const float fieldHalfSize = 500.0f; const int particleCount = 10000; _particleBuffers = new ParticleBuffers( _device, new Vector3(fieldHalfSize / 3.0f, fieldHalfSize, 0.0f), new Vector3(fieldHalfSize * 1.6f, fieldHalfSize, fieldHalfSize), //new Vector3(fieldHalfSize, fieldHalfSize, 0.0f), //new Vector3(fieldHalfSize, fieldHalfSize, fieldHalfSize), particleCount); _particleUpdateShader = new ParticleUpdateShader( generatedFilename, _device, _particleBuffers, particleCount); _particleOutputShader = new ParticleOutputShader( generatedFilename, _device, _particleBuffers.ReadBuffer, _finalRender.UAV, particleCount); _subspaceBuffers = new SubspaceBuffers( _device, 32, 32, 32); _writeParticlesToSubspaceShader = new WriteParticlesToSubspaceShader( generatedFilename, device, _subspaceBuffers, _particleBuffers, ParticleUpdateShader.ParticleReadSlot); }