/// <summary> /// Perform fourier tranform on three textures. /// </summary> public int PeformFFT(RenderTexture[] data0, RenderTexture[] data1, RenderTexture[] data2) { RenderTexture[] pass0 = new RenderTexture[] { data0[0], data1[0], data2[0] }; RenderTexture[] pass1 = new RenderTexture[] { data0[1], data1[1], data2[1] }; int i; int idx = 0; int idx1; int j = 0; for (i = 0; i < m_passes; i++, j++) { idx = j % 2; idx1 = (j + 1) % 2; m_fourier.SetTexture("_ButterFlyLookUp", m_butterflyLookupTable[i]); m_fourier.SetTexture("_ReadBuffer0", data0[idx1]); m_fourier.SetTexture("_ReadBuffer1", data1[idx1]); m_fourier.SetTexture("_ReadBuffer2", data2[idx1]); if (idx == 0) { RTUtility.MultiTargetBlit(pass0, m_fourier, PASS_X_3); } else { RTUtility.MultiTargetBlit(pass1, m_fourier, PASS_X_3); } } for (i = 0; i < m_passes; i++, j++) { idx = j % 2; idx1 = (j + 1) % 2; m_fourier.SetTexture("_ButterFlyLookUp", m_butterflyLookupTable[i]); m_fourier.SetTexture("_ReadBuffer0", data0[idx1]); m_fourier.SetTexture("_ReadBuffer1", data1[idx1]); m_fourier.SetTexture("_ReadBuffer2", data2[idx1]); if (idx == 0) { RTUtility.MultiTargetBlit(pass0, m_fourier, PASS_Y_3); } else { RTUtility.MultiTargetBlit(pass1, m_fourier, PASS_Y_3); } } return(idx); }
/// <summary> /// Initilize the spectrum for a time period. /// </summary> void InitWaveSpectrum(float t) { RenderTexture[] buffers = new RenderTexture[] { m_fourierBuffer0[1], m_fourierBuffer1[1], m_fourierBuffer2[1] }; m_initSpectrumMaterial.SetFloat("_T", t); RTUtility.MultiTargetBlit(buffers, m_initSpectrumMaterial); RenderTexture[] buffers34 = new RenderTexture[] { m_fourierBuffer3[1], m_fourierBuffer4[1] }; m_initDisplacementMat.SetTexture("_Buffer1", m_fourierBuffer1[1]); m_initDisplacementMat.SetTexture("_Buffer2", m_fourierBuffer2[1]); RTUtility.MultiTargetBlit(buffers34, m_initDisplacementMat); }