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.main.DistortedFramebuffer;
|
24
|
import org.distorted.library.type.Data1D;
|
25
|
import org.distorted.library.type.Data4D;
|
26
|
|
27
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
|
29
|
/**
|
30
|
* Similar effect to Glow, but this one is not blurred and it's entirely behind the object.
|
31
|
*/
|
32
|
public class PostprocessEffectBorder extends PostprocessEffect
|
33
|
{
|
34
|
private final Data1D mHalo;
|
35
|
private final Data4D mColor;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
// Clean up of static variables on exit. Called by reflection from super class.
|
39
|
|
40
|
@SuppressWarnings("unused")
|
41
|
static void destroyStatics()
|
42
|
{
|
43
|
|
44
|
}
|
45
|
|
46
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47
|
/**
|
48
|
* Only for use by the library itself.
|
49
|
*
|
50
|
* @y.exclude
|
51
|
*/
|
52
|
public boolean compute(float[] uniforms, int index, long currentDuration, long step )
|
53
|
{
|
54
|
mColor.get(uniforms,index+2,currentDuration,step);
|
55
|
return mHalo.get(uniforms,index,currentDuration,step);
|
56
|
}
|
57
|
|
58
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59
|
/**
|
60
|
* Only for use by the library itself.
|
61
|
*
|
62
|
* @y.exclude
|
63
|
*/
|
64
|
public boolean getRenderDirectly()
|
65
|
{
|
66
|
return true;
|
67
|
}
|
68
|
|
69
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70
|
/**
|
71
|
* Only for use by the library itself.
|
72
|
*
|
73
|
* @y.exclude
|
74
|
*/
|
75
|
public int postprocess(float[] uniforms, int index, DistortedFramebuffer buffer)
|
76
|
{
|
77
|
return 0;
|
78
|
}
|
79
|
|
80
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
81
|
// PUBLIC API
|
82
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83
|
/**
|
84
|
* No local programs; we do not postprocess anything here. No need to do anything
|
85
|
*/
|
86
|
public static void enable()
|
87
|
{
|
88
|
|
89
|
}
|
90
|
|
91
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
92
|
/**
|
93
|
* Draw a sharp 'border' around the object.
|
94
|
* One can decide if the border is around the object or behind it by carefully setting the
|
95
|
* componentCenters of the object's mesh first.
|
96
|
*
|
97
|
* @param halo How far beyond the object does the effect stretch to? Unit: Percentage of the size
|
98
|
* of the original object, i.e. halo=0 --> no effect at all, halo=100 --> border of
|
99
|
* size of the object itself.
|
100
|
*
|
101
|
* @param color RGBA of the color with which to draw the border; example: (1.0f,0.0f,0.0f,0.5f) -
|
102
|
* half transparent red.
|
103
|
*/
|
104
|
public PostprocessEffectBorder(Data1D halo, Data4D color)
|
105
|
{
|
106
|
super(EffectName.BORDER);
|
107
|
|
108
|
mHalo = halo;
|
109
|
mColor= color;
|
110
|
}
|
111
|
}
|