public ComputeShaderRenderer(RenderChunk chunk, Material material, Func <ComputeBuffer> getMeshDataStream) { this.material = material; indexBuffer = new ComputeBuffer(chunk.indices.Length, sizeof(int)); indexCountBuffer = new ComputeBuffer(chunk.indexCounts.Length, sizeof(int)); indexBuffer.SetData(chunk.indices); indexCountBuffer.SetData(chunk.indexCounts); this.getMeshDataStream = getMeshDataStream; }
public static ICompute CreateComputeBy(SkinningMethod method, RenderChunk chunk) { switch (method) { case SkinningMethod.Linear: return(new LinearBlendSkinningCompute()); case SkinningMethod.DualQuaternion: return(new DualQuaternionBlendSkinningCompute()); default: return(null); } }
public DualQuaternionBlendSkinningDispatcher(ComputeShader computeShader, RenderChunk chunk, Transform[] bones, Func <ComputeBuffer> getMeshDataBuffer, Func <ComputeBuffer> getMeshDataStream) { this.computeShader = computeShader; kernelIndex = computeShader.FindKernel("DualQuaternionBlendCompute"); computeShader.GetKernelThreadGroupSizes(kernelIndex, out maxThreadSizeX, out maxThreadSizeY, out maxThreadSizeZ); vertexCount = chunk.vertexCount; this.bones = bones; currentPoseDQArray = new DualQuaternion[bones.Length]; boneRestPoseDQBuffer = new ComputeBuffer(bones.Length, Marshal.SizeOf(typeof(DualQuaternion))); boneCurrentPoseDQBuffer = new ComputeBuffer(bones.Length, Marshal.SizeOf(typeof(DualQuaternion))); boneRestPoseDQBuffer.SetData(chunk.inverseRestPoseDQArray); computeShader.SetInt("vertexCount", vertexCount); computeShader.SetBuffer(kernelIndex, "currentPoseDQBuffer", boneCurrentPoseDQBuffer); computeShader.SetBuffer(kernelIndex, "restPoseDQBuffer", boneRestPoseDQBuffer); computeShader.SetBuffer(kernelIndex, "meshBuffer", getMeshDataBuffer()); computeShader.SetBuffer(kernelIndex, "meshStream", getMeshDataStream()); }
public VTFSkinningAdapter(SkinningMethod method, RenderChunk chunk, Material material) { }
public DefaultSkinningAdapter(SkinningMethod method, RenderChunk chunk, Transform[] bones, Material material) { }
public ComputeShaderSkinningAdapter(SkinningMethod method, ComputeShader computeShader, RenderChunk chunk, Transform[] bones, Material material) { this.method = method; meshDataBuffer = new ComputeBuffer(chunk.vertexCount, Marshal.SizeOf(typeof(MeshDataInfo))); meshDataBuffer.SetData(chunk.meshData); meshDataStream = new ComputeBuffer(chunk.vertexCount, Marshal.SizeOf(typeof(RenderData))); meshDataStream.SetData(chunk.meshData); sourceDispatcher = new DataToDataDispatcher(computeShader, () => { return(meshDataBuffer); }, () => { return(meshDataStream); }); dispatchcer = ComputeShaderSkinningDispatcherFactory.CreateComputeBy(method, computeShader, chunk, bones, () => { return(meshDataBuffer); }, () => { return(meshDataStream); }); renderer = new ComputeShaderRenderer(chunk, material, () => { return(meshDataStream); }); }
public OptimizedCenterOfRotationSkinningDispatcher(ComputeShader computeShader, RenderChunk chunk, Transform[] bones, Func <ComputeBuffer> getMeshDataBuffer, Func <ComputeBuffer> getMeshDataStream) { this.computeShader = computeShader; kernelIndex = computeShader.FindKernel("OpimizedCenterOfRoationCompute"); computeShader.GetKernelThreadGroupSizes(kernelIndex, out maxThreadSizeX, out maxThreadSizeY, out maxThreadSizeZ); vertexCount = chunk.vertexCount; this.bones = bones; computeShader.SetInt("vertexCount", vertexCount); computeShader.SetBuffer(kernelIndex, "meshBuffer", getMeshDataBuffer()); computeShader.SetBuffer(kernelIndex, "meshStream", getMeshDataStream()); }
public static IDisposableDispatch CreateComputeBy(SkinningMethod method, ComputeShader computeShader, RenderChunk chunk, Transform[] bones, Func <ComputeBuffer> getMeshDataBuffer, Func <ComputeBuffer> getMeshDataStream) { switch (method) { case SkinningMethod.Linear: return(new LinearBlendSkinningDispatcher(computeShader, chunk, bones, getMeshDataBuffer, getMeshDataStream)); case SkinningMethod.DualQuaternion: return(new DualQuaternionBlendSkinningDispatcher(computeShader, chunk, bones, getMeshDataBuffer, getMeshDataStream)); case SkinningMethod.OpimizedCenterOfRoation: return(new OptimizedCenterOfRotationSkinningDispatcher(computeShader, chunk, bones, getMeshDataBuffer, getMeshDataStream)); default: return(null); } }