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