コード例 #1
0
        private void UpdateWaves()
        {
            int frameCount = Time.frameCount;

            if (this._LastUpdateFrame == frameCount)
            {
                return;
            }
            this._LastUpdateFrame = frameCount;
            MaterialPropertyBlock propertyBlock = this._Water.Renderer.PropertyBlock;
            float time = Time.time;

            for (int i = 0; i < this._GerstnerFours.Length; i++)
            {
                Gerstner4 gerstner = this._GerstnerFours[i];
                Vector4   value;
                value.x = gerstner.Wave0.Offset + gerstner.Wave0.Speed * time;
                value.y = gerstner.Wave1.Offset + gerstner.Wave1.Speed * time;
                value.z = gerstner.Wave2.Offset + gerstner.Wave2.Speed * time;
                value.w = gerstner.Wave3.Offset + gerstner.Wave3.Speed * time;
                propertyBlock.SetVector("_GrOff" + i, value);
            }
        }
コード例 #2
0
        private void UpdateMaterial()
        {
            MaterialPropertyBlock propertyBlock = this._Water.Renderer.PropertyBlock;

            for (int i = 0; i < this._GerstnerFours.Length; i++)
            {
                Gerstner4 gerstner = this._GerstnerFours[i];
                Vector4   value;
                value.x = gerstner.Wave0.Amplitude;
                Vector4 value2;
                value2.x = gerstner.Wave0.Frequency;
                Vector4 value3;
                value3.x = gerstner.Wave0.Direction.x;
                value3.y = gerstner.Wave0.Direction.y;
                value.y  = gerstner.Wave1.Amplitude;
                value2.y = gerstner.Wave1.Frequency;
                value3.z = gerstner.Wave1.Direction.x;
                value3.w = gerstner.Wave1.Direction.y;
                value.z  = gerstner.Wave2.Amplitude;
                value2.z = gerstner.Wave2.Frequency;
                Vector4 value4;
                value4.x = gerstner.Wave2.Direction.x;
                value4.y = gerstner.Wave2.Direction.y;
                value.w  = gerstner.Wave3.Amplitude;
                value2.w = gerstner.Wave3.Frequency;
                value4.z = gerstner.Wave3.Direction.x;
                value4.w = gerstner.Wave3.Direction.y;
                propertyBlock.SetVector("_GrAB" + i, value3);
                propertyBlock.SetVector("_GrCD" + i, value4);
                propertyBlock.SetVector("_GrAmp" + i, value);
                propertyBlock.SetVector("_GrFrq" + i, value2);
            }
            for (int j = this._GerstnerFours.Length; j < 5; j++)
            {
                propertyBlock.SetVector("_GrAmp" + j, Vector4.zero);
            }
        }