Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
 public VTFSkinningAdapter(SkinningMethod method, RenderChunk chunk, Material material)
 {
 }
Esempio n. 5
0
 public DefaultSkinningAdapter(SkinningMethod method, RenderChunk chunk, Transform[] bones, Material material)
 {
 }
Esempio n. 6
0
        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); });
        }
Esempio n. 7
0
        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());
        }
Esempio n. 8
0
        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);
            }
        }