コード例 #1
0
        bool CheckInstance(bool force)
        {
            if (instance == null)
            {
                instance = this;
            }
            else if (force)
            {
                instance = this;
            }

            if (!reflection)
            {
                reflection = transform.GetComponent <NeoReflection>();
            }

            {
                if (reflection)
                {
                    reflection.enabled = (instance == this);
                }
            }

            return(instance == this);
        }
コード例 #2
0
        void InitWaveSpectrum(float t)
        {
            float factor = twoPI * m_fftresolution;

            matSpectrum_l.SetTexture("_Spectrum01", m_spectrum01);
            matSpectrum_l.SetVector("_Offset", m_offset * detailWaves.distort);
            matSpectrum_l.SetVector("_InverseGridSizes", m_inverseWorldSizes * factor);
            matSpectrum_l.SetFloat("_T", t);

            NeoOcean.Blit(null, m_fourierBuffer0[1], matSpectrum_l, 0);
        }
コード例 #3
0
        void PeformFFT(RenderTexture[] data0, int c)
        {
            Material fouriermat = matFourier_l;

            RenderTexture pass0 = data0[0];
            RenderTexture pass1 = data0[1];

            if (c == 0)
            {
                pj = 0;

                for (int i = 0; i < m_passes; i++, pj++)
                {
                    int idx  = pj % 2;
                    int idx1 = (pj + 1) % 2;

                    fouriermat.SetTexture("_ButterFlyLookUp", m_butterflyLookupTable[i]);

                    fouriermat.SetTexture("_ReadBuffer0", data0[idx1]);

                    if (idx == 0)
                    {
                        NeoOcean.Blit(null, pass0, fouriermat, 0);
                    }
                    else
                    {
                        NeoOcean.Blit(null, pass1, fouriermat, 0);
                    }
                }
            }
            else
            {
                for (int i = 0; i < m_passes; i++, pj++)
                {
                    int idx  = pj % 2;
                    int idx1 = (pj + 1) % 2;

                    fouriermat.SetTexture("_ButterFlyLookUp", m_butterflyLookupTable[i]);

                    fouriermat.SetTexture("_ReadBuffer0", data0[idx1]);

                    if (idx == 0)
                    {
                        NeoOcean.Blit(null, pass0, fouriermat, 1);
                    }
                    else
                    {
                        NeoOcean.Blit(null, pass1, fouriermat, 1);
                    }
                }
            }
        }
コード例 #4
0
        void OnDisable()
        {
            GerstnerWavesJobs.Cleanup();

            if (reflection)
            {
                reflection.enabled = false;
            }

            if (instance == this)
            {
                instance = null;
            }
        }
コード例 #5
0
ファイル: NeoNormalGrid.cs プロジェクト: hafewa/URPOcean
        void GenerateWavesSpectrum()
        {
            NeoOcean.instance.matIspectrum.SetFloat("Omega", NeoFFTParameters.Omega);
            NeoOcean.instance.matIspectrum.SetFloat("windSpeed", fftParam.windSpeed);
            NeoOcean.instance.matIspectrum.SetFloat("waveDirFlow", uniWaveDirFlow);
            NeoOcean.instance.matIspectrum.SetFloat("waveAngle", NeoOcean.instance.basicWaves.direction);
            NeoOcean.instance.matIspectrum.SetFloat("waveAmp", fftParam.waveAmp);
            NeoOcean.instance.matIspectrum.SetFloat("fftresolution", m_fftresolution);

            Vector2 twoInvSizes   = twoPI * m_inverseWorldSizes;
            Vector4 sampleFFTSize = new Vector4(twoInvSizes.y, twoInvSizes.x, twoInvSizes.y, twoInvSizes.y);

            NeoOcean.instance.matIspectrum.SetVector("sampleFFTSize", sampleFFTSize);

            NeoOcean.Blit(null, m_spectrum01, NeoOcean.instance.matIspectrum);
        }
コード例 #6
0
ファイル: NeoOcean.cs プロジェクト: hafewa/URPOcean
        void OnDestroy()
        {
            gTime = 0;

            DestroyAllMaterial();

            //if (Application.isPlaying)
            //    GerstnerWavesJobs.Cleanup();

            mainPGrid = null;

            if (instance == this)
            {
                instance = null;
            }
        }
コード例 #7
0
        protected void PhysicsUpdate()
        {
            CheckParams();

            if (matSpectrum_l == null)
            {
                return;
            }

            if (bChangeBuffer)
            {
                //Creates all the data needed to generate the waves.
                //This is not called in the constructor because greater control
                //over when exactly this data is created is needed.
                GenerateWavesSpectrum();

                matSpectrum_l.SetTexture("_Spectrum01", m_spectrum01);

                bChangeBuffer = false;
            }

            if (m_fourierBuffer0.Length == 0)
            {
                ForceReload(true);
                return;
            }

            int count = 2;

            count = Time.frameCount % count;
            if (count == 0)
            {
                InitWaveSpectrum(gTime);
            }

            PeformFFT(m_fourierBuffer0, count);

            if (count == 1)
            {
                NeoOcean.Blit(m_fourierBuffer0[1], m_map0, null);
            }
        }
コード例 #8
0
ファイル: NeoNormalGrid.cs プロジェクト: hafewa/URPOcean
        protected void PhysicsUpdate()
        {
            if (NeoOcean.instance == null)
            {
                return;
            }

            Camera cam = Camera.main;

            if (cam == null)
            {
                return;
            }

            if (!cam.gameObject.activeSelf)
            {
                return;
            }

            if (supportRT != NeoOcean.instance.supportRT)
            {
                ForceReload(true);
            }

            supportRT = NeoOcean.instance.supportRT;

            if (!NeoOcean.instance.supportRT)
            {
                return;
            }

            CheckParams();

            if (NeoOcean.instance.matSpectrum_l == null)
            {
                return;
            }

            if (bChangeBuffer)
            {
                //Creates all the data needed to generate the waves.
                //This is not called in the constructor because greater control
                //over when exactly this data is created is needed.
                GenerateWavesSpectrum();

                NeoOcean.instance.matSpectrum_l.SetTexture("_Spectrum01", m_spectrum01);

                bChangeBuffer = false;
            }

            if (m_fourierBuffer0.Length == 0)
            {
                ForceReload(true);
                return;
            }

            int count = 2;

            count = Time.frameCount % count;
            if (count == 0)
            {
                InitWaveSpectrum(_ScaledTime);
            }

            PeformFFT(m_fourierBuffer0, count);

            if (count == 1)
            {
                NeoOcean.Blit(m_fourierBuffer0[1], m_map0, null);
            }
        }