1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2021 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// 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
|
// Distorted 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 //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.library.effect;
|
21
|
|
22
|
import org.distorted.library.main.DistortedFramebuffer;
|
23
|
import org.distorted.library.type.Data1D;
|
24
|
import org.distorted.library.type.Data4D;
|
25
|
|
26
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
27
|
|
28
|
/**
|
29
|
* Similar effect to Glow, but this one is not blurred and it's entirely behind the object.
|
30
|
*/
|
31
|
public class PostprocessEffectBorder extends PostprocessEffect
|
32
|
{
|
33
|
private final Data1D mHalo;
|
34
|
private final Data4D mColor;
|
35
|
|
36
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37
|
// Clean up of static variables on exit. Called by reflection from super class.
|
38
|
|
39
|
@SuppressWarnings("unused")
|
40
|
static void destroyStatics()
|
41
|
{
|
42
|
|
43
|
}
|
44
|
|
45
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46
|
/**
|
47
|
* Only for use by the library itself.
|
48
|
*
|
49
|
* @y.exclude
|
50
|
*/
|
51
|
public boolean compute(float[] uniforms, int index, long currentDuration, long step )
|
52
|
{
|
53
|
mColor.get(uniforms,index+2,currentDuration,step);
|
54
|
return mHalo.get(uniforms,index,currentDuration,step);
|
55
|
}
|
56
|
|
57
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58
|
/**
|
59
|
* Only for use by the library itself.
|
60
|
*
|
61
|
* @y.exclude
|
62
|
*/
|
63
|
public boolean getRenderDirectly()
|
64
|
{
|
65
|
return true;
|
66
|
}
|
67
|
|
68
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
/**
|
70
|
* Only for use by the library itself.
|
71
|
*
|
72
|
* @y.exclude
|
73
|
*/
|
74
|
public int postprocess(float[] uniforms, int index, DistortedFramebuffer buffer)
|
75
|
{
|
76
|
return 0;
|
77
|
}
|
78
|
|
79
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80
|
// PUBLIC API
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
/**
|
83
|
* No local programs; we do not postprocess anything here. No need to do anything
|
84
|
*/
|
85
|
public static void enable()
|
86
|
{
|
87
|
|
88
|
}
|
89
|
|
90
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91
|
/**
|
92
|
* Draw a sharp 'border' around the object. Unlike 'GLOW', the border is entirely around the object
|
93
|
* and not in front of it.
|
94
|
*
|
95
|
* @param halo How far beyond the object does the effect stretch to? Unit: Percentage of the size
|
96
|
* of the original object, i.e. halo=0 --> no effect at all, halo=100 --> border of
|
97
|
* size of the object itself.
|
98
|
*
|
99
|
* @param color RGBA of the color with which to draw the border; example: (1.0f,0.0f,0.0f,0.5f) -
|
100
|
* half transparent red.
|
101
|
*/
|
102
|
public PostprocessEffectBorder(Data1D halo, Data4D color)
|
103
|
{
|
104
|
super(EffectName.BORDER);
|
105
|
|
106
|
mHalo = halo;
|
107
|
mColor= color;
|
108
|
}
|
109
|
}
|