Revision 6bb59aad
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/effect/FragmentEffectBrightness.java | ||
---|---|---|
22 | 22 |
import org.distorted.library.type.Data1D; |
23 | 23 |
import org.distorted.library.type.Data4D; |
24 | 24 |
import org.distorted.library.type.Dynamic1D; |
25 |
import org.distorted.library.type.Dynamic4D; |
|
25 | 26 |
import org.distorted.library.type.Static1D; |
27 |
import org.distorted.library.type.Static4D; |
|
26 | 28 |
|
27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
28 | 30 |
|
29 | 31 |
public class FragmentEffectBrightness extends FragmentEffect |
30 | 32 |
{ |
33 |
private static final String NAME = "BRIGHTNESS"; |
|
31 | 34 |
private static final float[] UNITIES = new float[] {1.0f}; |
32 | 35 |
private static final int DIMENSION = 1; |
33 | 36 |
private static final boolean SUPPORTS_CENTER = false; |
34 | 37 |
private static final boolean SUPPORTS_REGION = true; |
35 | 38 |
|
36 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 |
|
|
40 |
/** |
|
41 |
* Makes a certain sub-region of the Object smoothly change its brightness level. |
|
42 |
* |
|
43 |
* @param brightness 1-dimensional Data that returns the level of brightness we want to have |
|
44 |
* at any given moment. Valid range: <0,infinity) |
|
45 |
* @param region Region this Effect is limited to. |
|
46 |
* @param smooth If true, the level of 'brightness' will smoothly fade out towards the edges of the region. |
|
47 |
*/ |
|
38 | 48 |
public FragmentEffectBrightness(Data1D brightness, Data4D region, boolean smooth) |
39 | 49 |
{ |
40 |
super(smooth?SMOOTH_BRIGHTNESS:BRIGHTNESS ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
50 |
super(smooth?SMOOTH_BRIGHTNESS:BRIGHTNESS ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
41 | 51 |
|
42 | 52 |
if( brightness instanceof Dynamic1D ) |
43 | 53 |
{ |
... | ... | |
48 | 58 |
mStatic0 = (Static1D)brightness; |
49 | 59 |
} |
50 | 60 |
|
51 |
mRegion = region; |
|
61 |
if( region instanceof Static4D) |
|
62 |
{ |
|
63 |
mStaticRegion = (Static4D)region; |
|
64 |
} |
|
65 |
else if( region instanceof Dynamic4D) |
|
66 |
{ |
|
67 |
mDynamicRegion = (Dynamic4D)region; |
|
68 |
} |
|
52 | 69 |
} |
53 | 70 |
|
54 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 |
|
|
72 |
/** |
|
73 |
* Makes the whole Object smoothly change its brightness level. |
|
74 |
* |
|
75 |
* @param brightness 1-dimensional Data that returns the level of brightness we want to have |
|
76 |
* at any given moment. Valid range: <0,infinity) |
|
77 |
*/ |
|
56 | 78 |
public FragmentEffectBrightness(Data1D brightness) |
57 | 79 |
{ |
58 |
super(BRIGHTNESS,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
80 |
super(BRIGHTNESS,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
59 | 81 |
|
60 | 82 |
if( brightness instanceof Dynamic1D ) |
61 | 83 |
{ |
... | ... | |
65 | 87 |
{ |
66 | 88 |
mStatic0 = (Static1D)brightness; |
67 | 89 |
} |
90 |
|
|
91 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
68 | 92 |
} |
69 | 93 |
|
70 | 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
71 | 95 |
|
72 | 96 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
73 | 97 |
{ |
98 |
if( mDynamicRegion!=null ) |
|
99 |
{ |
|
100 |
mDynamicRegion.interpolateMain(uniforms,index+4,currentDuration,step); |
|
101 |
} |
|
102 |
else |
|
103 |
{ |
|
104 |
uniforms[index+4] = mStaticRegion.getX(); |
|
105 |
uniforms[index+5] = mStaticRegion.getY(); |
|
106 |
uniforms[index+6] = mStaticRegion.getZ(); |
|
107 |
uniforms[index+7] = mStaticRegion.getW(); |
|
108 |
} |
|
109 |
|
|
74 | 110 |
if( mDynamic0!=null ) |
75 | 111 |
{ |
76 | 112 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
Also available in: Unified diff
Progress with support for Effect classes.