Project

General

Profile

Download (4.38 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / effect / PostprocessEffectBlur.java @ d58407a8

1 125cee3d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2017 Leszek Koltunski                                                               //
3
//                                                                                               //
4 46b572b5 Leszek Koltunski
// This file is part of Distorted.                                                               //
5 125cee3d Leszek Koltunski
//                                                                                               //
6 46b572b5 Leszek Koltunski
// Distorted is free software: you can redistribute it and/or modify                             //
7 125cee3d Leszek Koltunski
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11 46b572b5 Leszek Koltunski
// Distorted is distributed in the hope that it will be useful,                                  //
12 125cee3d Leszek Koltunski
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17 46b572b5 Leszek Koltunski
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18 125cee3d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.library.effect;
21
22 bb4755e2 Leszek Koltunski
import org.distorted.library.type.Data2D;
23 125cee3d Leszek Koltunski
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25 faa3ff56 Leszek Koltunski
/**
26
 * Blur the Framebuffer.
27
 */
28 d58407a8 Leszek Koltunski
public class PostprocessEffectBlur extends PostprocessEffectBlurred
29 125cee3d Leszek Koltunski
  {
30 d58407a8 Leszek Koltunski
  private final Data2D mHaloAndRadius;
31 15aa7d94 Leszek Koltunski
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33 faa3ff56 Leszek Koltunski
/**
34
 * Only for use by the library itself.
35
 *
36
 * @y.exclude
37
 */
38 15aa7d94 Leszek Koltunski
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
39
    {
40 d58407a8 Leszek Koltunski
    return mHaloAndRadius.get(uniforms,index,currentDuration,step);
41 15aa7d94 Leszek Koltunski
    }
42 1dfc9074 leszek
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44 143095f7 Leszek Koltunski
/**
45
 * Only for use by the library itself.
46
 *
47
 * @y.exclude
48
 */
49 d58407a8 Leszek Koltunski
  public boolean getRenderDirectly()
50 9e771d06 Leszek Koltunski
    {
51
    return false;
52
    }
53 86d322b5 Leszek Koltunski
54 1dfc9074 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
55 faa3ff56 Leszek Koltunski
// PUBLIC API
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
/**
58 7602a827 Leszek Koltunski
 * Have to call this before the shaders get compiled (i.e before DistortedLibrary.onCreate()) for the Effect to work.
59 faa3ff56 Leszek Koltunski
 */
60 041b6dee Leszek Koltunski
  public static void enable()
61
    {
62 d58407a8 Leszek Koltunski
    PostprocessEffectBlurred.enable("BLUR1","BLUR2");
63
    }
64 041b6dee Leszek Koltunski
65 d58407a8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
66
// Clean up of static variables on exit. Called by reflection from super class.
67 1dfc9074 leszek
68 d58407a8 Leszek Koltunski
  @SuppressWarnings("unused")
69
  static void destroyStatics()
70
    {
71
    PostprocessEffectBlurred.destroyStatics();
72 1dfc9074 leszek
    }
73
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75 faa3ff56 Leszek Koltunski
/**
76
 * Blur the Framebuffer.
77
 *
78 d58407a8 Leszek Koltunski
 * @param haloAndRadius First float: the halo.
79
 *                      How far beyond the object does the effect stretch to? Unit: Percentage
80
 *                      of the size of the original object, i.e. Halo=0 --> no halo around, this
81
 *                      would mean sharp edges around the object; Halo=100 --> halo of the size
82
 *                      of the object itself around (in case of blur, this would be - in vast
83
 *                      majority of cases except an object rendered very closely to the near plane-
84
 *                      an overkill).
85
 *                      Second float: the radius.
86
 *                      The 'strength' if the blur of the edges, in pixels. 0 = no blur, 10 =
87
 *                      blur of roughly 10 pixels around the whole halo.
88 bb4755e2 Leszek Koltunski
89 faa3ff56 Leszek Koltunski
 */
90 d58407a8 Leszek Koltunski
  public PostprocessEffectBlur(Data2D haloAndRadius)
91 1dfc9074 leszek
    {
92 faa3ff56 Leszek Koltunski
    super(EffectName.BLUR);
93 d58407a8 Leszek Koltunski
    mHaloAndRadius = haloAndRadius;
94 1dfc9074 leszek
    }
95 125cee3d Leszek Koltunski
  }