Revision 6bb59aad
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/effect/FragmentEffectChroma.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Data4D; |
25 | 25 |
import org.distorted.library.type.Dynamic1D; |
26 | 26 |
import org.distorted.library.type.Dynamic3D; |
27 |
import org.distorted.library.type.Dynamic4D; |
|
27 | 28 |
import org.distorted.library.type.Static1D; |
28 | 29 |
import org.distorted.library.type.Static3D; |
30 |
import org.distorted.library.type.Static4D; |
|
29 | 31 |
|
30 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
31 | 33 |
|
32 | 34 |
public class FragmentEffectChroma extends FragmentEffect |
33 | 35 |
{ |
36 |
private static final String NAME = "CHROMA"; |
|
34 | 37 |
private static final float[] UNITIES = new float[] {0.0f}; |
35 | 38 |
private static final int DIMENSION = 4; |
36 | 39 |
private static final boolean SUPPORTS_CENTER = false; |
37 | 40 |
private static final boolean SUPPORTS_REGION = true; |
38 | 41 |
|
39 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 |
|
|
43 |
/** |
|
44 |
* Makes a certain sub-region of the Object smoothly change all three of its RGB components. |
|
45 |
* |
|
46 |
* @param blend 1-dimensional Data that returns the level of blend a given pixel will be |
|
47 |
* mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color. |
|
48 |
* Valid range: <0,1> |
|
49 |
* @param color Color to mix. (1,0,0) is RED. |
|
50 |
* @param region Region this Effect is limited to. |
|
51 |
* @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region. |
|
52 |
*/ |
|
41 | 53 |
public FragmentEffectChroma(Data1D blend, Data3D color, Data4D region, boolean smooth) |
42 | 54 |
{ |
43 |
super(smooth?SMOOTH_CHROMA:CHROMA ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
55 |
super(smooth?SMOOTH_CHROMA:CHROMA ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
44 | 56 |
|
45 | 57 |
if( blend instanceof Dynamic1D ) |
46 | 58 |
{ |
... | ... | |
60 | 72 |
mStatic1 = (Static3D)color; |
61 | 73 |
} |
62 | 74 |
|
63 |
mRegion = region; |
|
75 |
if( region instanceof Static4D) |
|
76 |
{ |
|
77 |
mStaticRegion = (Static4D)region; |
|
78 |
} |
|
79 |
else if( region instanceof Dynamic4D) |
|
80 |
{ |
|
81 |
mDynamicRegion = (Dynamic4D)region; |
|
82 |
} |
|
64 | 83 |
} |
65 | 84 |
|
66 | 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
67 |
|
|
86 |
/** |
|
87 |
* Makes the whole Object smoothly change all three of its RGB components. |
|
88 |
* |
|
89 |
* @param blend 1-dimensional Data that returns the level of blend a given pixel will be |
|
90 |
* mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color. |
|
91 |
* Valid range: <0,1> |
|
92 |
* @param color Color to mix. (1,0,0) is RED. |
|
93 |
*/ |
|
68 | 94 |
public FragmentEffectChroma(Data1D blend, Data3D color) |
69 | 95 |
{ |
70 |
super(CHROMA,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
96 |
super(CHROMA,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
71 | 97 |
|
72 | 98 |
if( blend instanceof Dynamic1D ) |
73 | 99 |
{ |
... | ... | |
86 | 112 |
{ |
87 | 113 |
mStatic1 = (Static3D)color; |
88 | 114 |
} |
115 |
|
|
116 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
89 | 117 |
} |
90 | 118 |
|
91 | 119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
92 | 120 |
|
93 | 121 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
94 | 122 |
{ |
123 |
if( mDynamicRegion!=null ) |
|
124 |
{ |
|
125 |
mDynamicRegion.interpolateMain(uniforms,index+4,currentDuration,step); |
|
126 |
} |
|
127 |
else |
|
128 |
{ |
|
129 |
uniforms[index+4] = mStaticRegion.getX(); |
|
130 |
uniforms[index+5] = mStaticRegion.getY(); |
|
131 |
uniforms[index+6] = mStaticRegion.getZ(); |
|
132 |
uniforms[index+7] = mStaticRegion.getW(); |
|
133 |
} |
|
134 |
|
|
95 | 135 |
if( mDynamic1!=null ) |
96 | 136 |
{ |
97 | 137 |
mDynamic1.interpolateMain(uniforms,index+1,currentDuration,step); |
Also available in: Unified diff
Progress with support for Effect classes.