//called from SimBuffer
        public void Blit(ref CommandBuffer cBuffer, ref RenderTexture sourcePosRT, ref RenderTexture destPosRT)
        {
            //get temp RT
            for (int i = 0; i < tempRT.Length; i++)
            {
                tempRT[i] = SimBuffer.GetTempRT(destPosRT);
            }

            //init mpb positionRT;
            for (int i = 0; i < sim.maxSpringConvergenceID; i++)
            {
                if (i == 0)
                {
                    mpb[i].SetTexture(ID_PositionRT, sourcePosRT);
                }
                else
                {
                    mpb[i].SetTexture(ID_PositionRT, tempRT[i - 1]);
                }
            }

            for (int i = 0; i < sim.maxSpringConvergenceID; i++)
            {
                if (i == sim.maxSpringConvergenceID - 1)
                {
                    cBuffer.SetRenderTarget(destPosRT);                                                 //if it is the last step, blit into the final dest rt
                }
                else
                {
                    cBuffer.SetRenderTarget(tempRT[i]);
                }
                cBuffer.DrawMesh(SimBuffer.quadMesh, Matrix4x4.identity, GPUVerletIntegrator.springMtl, 0, -1, mpb[i]);
            }
        }
Exemple #2
0
        //called from SimBuffer
        public void Blit(ref CommandBuffer cBuffer, ref RenderTexture sourcePosRT, ref RenderTexture destPosRT)
        {
            //get temp RT
            for (int i = 0; i < tempRT.Length; i++)
            {
                tempRT[i] = SimBuffer.GetTempRT(destPosRT);
            }
            for (int i = 0; i < tempDeltaRT.Length; i++)
            {
                tempDeltaRT[i] = SimBuffer.GetTempRT(deltaRTWidth, deltaRTHeight, RTFormat.R);
            }

            //init mpb positionRT;
            for (int i = 0; i < sim.maxAngleConvergenceID; i++)
            {
                if (i == 0)
                {
                    mpb[i].SetTexture(ID_PositionRT, sourcePosRT);
                }
                else
                {
                    mpb[i].SetTexture(ID_PositionRT, tempRT[i - 1]);
                }
                mpb[i].SetTexture(ID_AngleDeltaRT, tempDeltaRT[i]);
            }

            for (int i = 0; i < sim.maxAngleConvergenceID; i++)
            {
                //get the delta
                cBuffer.SetRenderTarget(tempDeltaRT[i]);
                cBuffer.DrawMesh(deltaMesh[i], Matrix4x4.identity, GPUVerletIntegrator.angleDeltaMtl, 0, -1, mpb[i]);
                //apply delta
                if (i == sim.maxAngleConvergenceID - 1)
                {
                    cBuffer.SetRenderTarget(destPosRT);                                                //if it is the last step, blit into the final dest rt
                }
                else
                {
                    cBuffer.SetRenderTarget(tempRT[i]);
                }
                cBuffer.DrawMesh(SimBuffer.quadMesh, Matrix4x4.identity, GPUVerletIntegrator.angleMtl, 0, -1, mpb[i]);
            }
        }