Пример #1
0
 void Update()
 {
     if (Time.timeSinceLevelLoad < 1f)
     {
         water_input_drawer_.putPoint(2f, 2f, -0.5f, 0.1f);
     }
     water_input_drawer_.renderUpdate(0 /* front */);
     water_input_drawer_.render(0 /* front */);
     wave_equation_.render(Time.time,
                           wave_equation_material_,
                           water_input_drawer_.getRenderTexture());
     surface_material_.SetTexture("_MainTex", wave_equation_.getLatestRenderTexture());
     wave_equation_.bind(surface_material_);
 }
Пример #2
0
        private void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            float v = 0f;

            if (Player.Instance != null)
            {
                v = Player.Instance.getAuraValue();
            }
            value_ = Mathf.Lerp(value_, v, 0.1f);
            var col = color_ * value_;

            aura_material_.SetColor(AuraColorId, col);
            wave_equation_.render(render_time_, wave_equation_material_, source);
            wave_equation_.bind(aura_material_);
            Graphics.Blit(source, destination, aura_material_);
        }
Пример #3
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));
    }
Пример #4
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_);
        }