Пример #1
0
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            Click();
            //wave_input_drawer_.putPoint(0.0f, 0.0f, -0.5f, 0.1f);
        }
        wave_equation_.render(wave_equation_material_, wave_input_drawer_.getRenderTexture());
        wave_equation_.bind(wave_surface_material_);

        var mat    = wave_surface_material_;
        var scale_ = SCALE;

        mat.SetVector(MaterialInfo.RScale, new Vector2(1f / (scale_), 1f / (scale_)));
        var stride = 1f / wave_equation_.getRenderTextureWidth();

        mat.SetVector(MaterialInfo.Stride, new Vector2(stride, stride));
    }
Пример #2
0
        public void render(double render_time)
        {
            if (centered_transform_ != null)
            {
                var dist = WaterSurface.Instance.getScale() * 0.5f;
                var pos  = centered_transform_.TransformPoint(new Vector3(0f, 0f, dist));
                pos.y = 0f;                             // ground
                transform.localPosition = pos;
                float y = centered_transform_.rotation.eulerAngles.y;
                transform.localRotation = Quaternion.Euler(0f, y, 0f);
            }

            Material mat = surface_material_;

            wave_equation_.render(render_time,
                                  wave_equation_material_,
                                  WaterSurface.Instance.getWaterInput());
            wave_equation_.bind(mat);

            Vector4     waveSpeed     = mat.GetVector(MaterialInfo.WaveSpeed);
            const float waveScale     = 0.75f;
            Vector4     waveScale4    = new Vector4(waveScale, waveScale, waveScale * 0.2f, waveScale * 0.225f);
            float       t             = (float)render_time / 20.0f;
            Vector4     offsetClamped = new Vector4(Mathf.Repeat(waveSpeed.x * waveScale4.x * t, 1f),
                                                    Mathf.Repeat(waveSpeed.y * waveScale4.y * t, 1f),
                                                    Mathf.Repeat(waveSpeed.z * waveScale4.z * t, 1f),
                                                    Mathf.Repeat(waveSpeed.w * waveScale4.w * t, 1f));

            mat.SetVector(MaterialInfo.WaveOffset, offsetClamped);
            mat.SetVector(MaterialInfo.WaveScale4, waveScale4);
            mat.SetVector(MaterialInfo.Scale, new Vector2(scale_, scale_));
            mat.SetVector(MaterialInfo.RScale, new Vector2(1f / (scale_), 1f / (scale_)));
            var stride = 1f / wave_equation_.getRenderTextureWidth();

            mat.SetVector(MaterialInfo.Stride, new Vector2(stride, stride));
            mat.SetColor(MaterialInfo.BaseColor, current_base_color_);
        }