protected virtual void Initialize() { kernelMap = Enum.GetValues(typeof(ComputeKernels)).Cast <ComputeKernels>().ToDictionary(k => k, k => computeShader.FindKernel(k.ToString())); uint threadX, threadY, threadZ; computeShader.GetKernelThreadGroupSizes(kernelMap[ComputeKernels.Draw], out threadX, out threadY, out threadZ); gpuThreads = new GPUThreads(threadX, threadY, threadZ); InitialCheck(); solverId = Shader.PropertyToID(solverProp); densityId = Shader.PropertyToID(densityProp); velocityId = Shader.PropertyToID(velocityProp); prevId = Shader.PropertyToID(prevProp); sourceId = Shader.PropertyToID(sourceProp); diffId = Shader.PropertyToID(diffProp); viscId = Shader.PropertyToID(viscProp); dtId = Shader.PropertyToID(dtProp); velocityCoefId = Shader.PropertyToID(velocityCoefProp); densityCoefId = Shader.PropertyToID(densityCoefProp); solverTexId = Shader.PropertyToID(solverTexProp); InitializeComputeShader(); }
protected virtual void Initialize() { uint threadX, threadY, threadZ; InitialCheck(); kernelMap = System.Enum.GetValues(typeof(ComputeKernels)) .Cast <ComputeKernels>() .ToDictionary(t => t, t => computeShader.FindKernel(t.ToString())); computeShader.GetKernelThreadGroupSizes(kernelMap[ComputeKernels.Draw], out threadX, out threadY, out threadZ); gpuThreads = new GPUThreads(threadX, threadY, threadZ); solverTexId = Shader.PropertyToID(solverTexProp); solverId = Shader.PropertyToID(solverProp); densityId = Shader.PropertyToID(densityProp); velocityId = Shader.PropertyToID(velocityProp); prevId = Shader.PropertyToID(prevProp); sourceId = Shader.PropertyToID(sourceProp); diffId = Shader.PropertyToID(diffProp); viscId = Shader.PropertyToID(viscProp); dtId = Shader.PropertyToID(dtProp); velocityCoefId = Shader.PropertyToID(velocityCoefProp); densityCoefId = Shader.PropertyToID(densityCoefProp); InitializeComputeShader(); if (debug) { if (debugMat == null) { return; } debugMat.mainTexture = solverTex; } }