示例#1
0
        public void OnCopyModeChanged()
        {
            if (windWaves != null && windWaves.CopyFrom != null)
            {
                FreeResources();

                windWaves.CopyFrom.DynamicSmoothness.ValidateVarianceTextures(windWaves.CopyFrom);
                windWaves.GetComponent <Water>().WaterMaterial.SetTexture("_SlopeVariance", windWaves.CopyFrom.DynamicSmoothness.varianceTexture);
            }
        }
示例#2
0
        public SpectrumResolver(WindWaves windWaves, Shader spectrumShader) : base(windWaves, 4)
        {
            this.water     = windWaves.GetComponent <Water>();
            this.windWaves = windWaves;

            renderTimeId = Shader.PropertyToID("_RenderTime");

            animationMaterial           = new Material(spectrumShader);
            animationMaterial.hideFlags = HideFlags.DontSave;
            animationMaterial.SetFloat(renderTimeId, Time.time);
        }
示例#3
0
        public SpectrumResolverCPU(WindWaves windWaves, int numScales)
        {
            this.water            = windWaves.GetComponent <Water>();
            this.windWaves        = windWaves;
            this.spectraDataCache = new Dictionary <WaterWavesSpectrum, WaterWavesSpectrumData>();
            this.spectraDataList  = new List <WaterWavesSpectrumData>();
            this.filteredCpuWaves = new WaterWave[0];
            this.numTiles         = numScales;
            this.cachedSeed       = windWaves.GetComponent <Water>().Seed;

            if (fftComputationCosts == null)
            {
                PrecomputeFFTCosts();
            }

            CreateSpectraLevels();
        }
示例#4
0
        internal void Enable(WindWaves windWaves)
        {
            if (enabled)
            {
                return;
            }

            enabled = true;

            this.water     = windWaves.GetComponent <Water>();
            this.windWaves = windWaves;

            if (Application.isPlaying)
            {
                water.ProfilesChanged.AddListener(OnProfilesChanged);
                FindBestWaves();
            }
        }
示例#5
0
        private void ValidateVarianceTextures(WindWaves windWaves)
        {
            if (varianceTexture == null)
            {
                varianceTexture = CreateVarianceTexture(RenderTextureFormat.RGHalf);
            }

            if (!varianceTexture.IsCreated())
            {
                varianceTexture.Create();

                var water = windWaves.GetComponent <Water>();
                water.WaterMaterial.SetTexture("_SlopeVariance", varianceTexture);
                varianceShader.SetTexture(0, "_Variance", varianceTexture);

                lastResetIndex = 0;
                currentIndex   = 0;
            }
        }
示例#6
0
        internal void Enable(WindWaves windWaves)
        {
            if (enabled)
            {
                return;
            }

            if (dx11FFT != null)
            {
                defaultDx11Fft = dx11FFT;
            }
            else
            {
                dx11FFT = defaultDx11Fft;
            }

            enabled = true;

            this.water     = windWaves.GetComponent <Water>();
            this.windWaves = windWaves;

            OnCopyModeChanged();

            if (Application.isPlaying)
            {
                if (lastCopyFrom == null)
                {
                    ValidateResources();
                }

                windWaves.ResolutionChanged.AddListener(OnResolutionChanged);
            }

            OnValidate(windWaves);

            water.InvalidateMaterialKeywords();

            fftUtilitiesMaterial           = new Material(fftUtilitiesShader);
            fftUtilitiesMaterial.hideFlags = HideFlags.DontSave;
        }
示例#7
0
 public WaterTileSpectrum(WindWaves windWaves, int index)
 {
     this.windWaves = windWaves;
     this.water     = windWaves.GetComponent <Water>();
     this.tileIndex = index;
 }