void RunSimulation() { var speciesSettings = settings.speciesSettings; ComputeHelper.CreateStructuredBuffer(ref settingsBuffer, speciesSettings); compute.SetBuffer(0, "speciesSettings", settingsBuffer); // Assign textures compute.SetTexture(updateKernel, "TrailMap", trailMap); compute.SetTexture(diffuseMapKernel, "TrailMap", trailMap); compute.SetTexture(diffuseMapKernel, "DiffusedTrailMap", diffusedTrailMap); // Assign settings compute.SetFloat("deltaTime", Time.fixedDeltaTime); compute.SetFloat("time", Time.fixedTime); compute.SetFloat("trailWeight", settings.trailWeight); compute.SetFloat("decayRate", settings.decayRate); compute.SetFloat("diffuseRate", settings.diffuseRate); ComputeHelper.Dispatch(compute, settings.numAgents, 1, 1, kernelIndex: updateKernel); ComputeHelper.Dispatch(compute, settings.width, settings.height, 1, kernelIndex: diffuseMapKernel); ComputeHelper.CopyRenderTexture(diffusedTrailMap, trailMap); }
// void LateUpdate() // { // ComputeHelper.CopyRenderTexture(trailMap, renderTexture); // } void RunSimulation() { compute.SetTexture(simulationKernel, "renderTexture", renderTexture); // Assign settings compute.SetFloat("deltaTime", Time.fixedDeltaTime); compute.SetFloat("time", Time.fixedTime); // ComputeHelper.Dispatch(compute, settings.width, settings.height, 1, kernelIndex: simulationKernel); ComputeHelper.Dispatch(compute, settings.numAgents, 1, 1, kernelIndex: simulationKernel); }
void LateUpdate() { if (showAgentsOnly) { ComputeHelper.ClearRenderTexture(displayTexture); drawAgentsCS.SetTexture(0, "TargetTexture", displayTexture); ComputeHelper.Dispatch(drawAgentsCS, settings.numAgents, 1, 1, 0); } else { ComputeHelper.CopyRenderTexture(trailMap, displayTexture); } }