1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2017 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.type.Data4D;
|
23
|
import org.distorted.library.type.Dynamic;
|
24
|
import org.distorted.library.type.Static;
|
25
|
|
26
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
27
|
// FRAGMENT EFFECTS
|
28
|
// 8 Uniforms: 4-per effect interpolated values, 4 dimensional Region.
|
29
|
|
30
|
public abstract class FragmentEffect extends Effect
|
31
|
{
|
32
|
public static final int NUM_UNIFORMS = 8;
|
33
|
|
34
|
public static final int CHROMA = 0;
|
35
|
public static final int SMOOTH_CHROMA = 1;
|
36
|
public static final int ALPHA = 2;
|
37
|
public static final int SMOOTH_ALPHA = 3;
|
38
|
public static final int BRIGHTNESS = 4;
|
39
|
public static final int SMOOTH_BRIGHTNESS = 5;
|
40
|
public static final int CONTRAST = 6;
|
41
|
public static final int SMOOTH_CONTRAST = 7;
|
42
|
public static final int SATURATION = 8;
|
43
|
public static final int SMOOTH_SATURATION = 9;
|
44
|
public static final int NUM_EFFECTS =10;
|
45
|
|
46
|
static final int MAX = 5;
|
47
|
private static final int MAX_UNITY_DIM = 1;
|
48
|
|
49
|
Dynamic mDynamic0, mDynamic1;
|
50
|
Static mStatic0, mStatic1;
|
51
|
Data4D mRegion;
|
52
|
|
53
|
private final static float[] mUnity = new float[MAX_UNITY_DIM*NUM_EFFECTS];
|
54
|
private final static int[] mUnityDim = new int[NUM_EFFECTS];
|
55
|
|
56
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
57
|
|
58
|
public FragmentEffect(int name,float[] unity, int dimension, boolean center, boolean region)
|
59
|
{
|
60
|
super(FRAGMENT,name,dimension,center,region);
|
61
|
|
62
|
for(int i=0; i<unity.length; i++)
|
63
|
{
|
64
|
mUnity[name*MAX_UNITY_DIM+i] = unity[i];
|
65
|
}
|
66
|
|
67
|
mUnityDim[name] = unity.length;
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
|
72
|
public static boolean isUnity(int name, float[] buffer, int index)
|
73
|
{
|
74
|
switch(mUnityDim[name])
|
75
|
{
|
76
|
case 0: return true;
|
77
|
case 1: return buffer[index ]==mUnity[MAX_UNITY_DIM*name ];
|
78
|
case 2: return buffer[index ]==mUnity[MAX_UNITY_DIM*name ] &&
|
79
|
buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1];
|
80
|
case 3: return buffer[index ]==mUnity[MAX_UNITY_DIM*name ] &&
|
81
|
buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
|
82
|
buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2];
|
83
|
case 4: return buffer[index ]==mUnity[MAX_UNITY_DIM*name ] &&
|
84
|
buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
|
85
|
buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2] &&
|
86
|
buffer[index+3]==mUnity[MAX_UNITY_DIM*name+3];
|
87
|
}
|
88
|
|
89
|
return false;
|
90
|
}
|
91
|
}
|