Revision 895d2f4f
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/blur/BlurRenderer.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.graphics.Bitmap; |
23 | 23 |
import android.graphics.BitmapFactory; |
24 |
import android.opengl.GLES30; |
|
25 | 24 |
import android.opengl.GLSurfaceView; |
26 | 25 |
|
27 | 26 |
import org.distorted.examples.R; |
28 | 27 |
import org.distorted.library.Distorted; |
29 | 28 |
import org.distorted.library.DistortedEffects; |
29 |
import org.distorted.library.DistortedEffectsPostprocess; |
|
30 |
import org.distorted.library.DistortedNode; |
|
30 | 31 |
import org.distorted.library.DistortedScreen; |
31 | 32 |
import org.distorted.library.DistortedTexture; |
32 | 33 |
import org.distorted.library.EffectNames; |
... | ... | |
48 | 49 |
{ |
49 | 50 |
private GLSurfaceView mView; |
50 | 51 |
private DistortedEffects mEffects; |
52 |
private DistortedEffectsPostprocess mPostEffects; |
|
51 | 53 |
private DistortedScreen mScreen; |
52 | 54 |
private MeshFlat mMesh; |
53 | 55 |
private Static1D mRadiusSta; |
... | ... | |
57 | 59 |
|
58 | 60 |
BlurRenderer(GLSurfaceView v) |
59 | 61 |
{ |
60 |
mView = v; |
|
61 |
mMesh = new MeshFlat(1,1); |
|
62 |
mEffects = new DistortedEffects(); |
|
63 |
mScreen = new DistortedScreen(); |
|
62 |
mView = v; |
|
63 |
mMesh = new MeshFlat(1,1); |
|
64 |
mEffects = new DistortedEffects(); |
|
65 |
mPostEffects = new DistortedEffectsPostprocess(); |
|
66 |
mScreen = new DistortedScreen(); |
|
64 | 67 |
|
65 | 68 |
mRadiusSta = new Static1D(5); |
66 | 69 |
Dynamic1D radiusDyn = new Dynamic1D(); |
67 | 70 |
radiusDyn.add(mRadiusSta); |
68 | 71 |
|
69 |
mEffects.blur(radiusDyn); |
|
72 |
mPostEffects.blur(radiusDyn);
|
|
70 | 73 |
} |
71 | 74 |
|
72 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
138 | 141 |
texture.setTexture(bitmap); |
139 | 142 |
|
140 | 143 |
mScreen.detachAll(); |
141 |
mScreen.attach(texture,mEffects,mMesh); |
|
144 |
DistortedNode node = new DistortedNode(texture,mEffects,mMesh); |
|
145 |
node.setPostprocessEffects(mPostEffects); |
|
146 |
mScreen.attach(node); |
|
142 | 147 |
|
143 | 148 |
DistortedEffects.enableEffect(EffectNames.BLUR); |
144 | 149 |
|
src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java | ||
---|---|---|
26 | 26 |
import org.distorted.examples.R; |
27 | 27 |
import org.distorted.library.Distorted; |
28 | 28 |
import org.distorted.library.DistortedEffects; |
29 |
import org.distorted.library.DistortedEffectsPostprocess; |
|
30 |
import org.distorted.library.DistortedNode; |
|
29 | 31 |
import org.distorted.library.DistortedScreen; |
30 | 32 |
import org.distorted.library.DistortedTexture; |
31 | 33 |
import org.distorted.library.EffectNames; |
... | ... | |
66 | 68 |
private GLSurfaceView mView; |
67 | 69 |
private DistortedTexture mTex1, mTex2; |
68 | 70 |
private DistortedEffects[] mEffects; |
71 |
private DistortedNode[] mNode; |
|
72 |
private DistortedEffectsPostprocess mPostEffects; |
|
69 | 73 |
private Static3D[] mMoveVector; |
70 | 74 |
private Dynamic3D[] mMoveDynamic; |
71 | 75 |
private Static1D mBlurVector; |
... | ... | |
88 | 92 |
mBlurStatus = new boolean[NUM_OBJECTS]; |
89 | 93 |
mMoveDynamic= new Dynamic3D[NUM_OBJECTS]; |
90 | 94 |
mMoveVector = new Static3D[NUM_OBJECTS]; |
95 |
mNode = new DistortedNode[NUM_OBJECTS]; |
|
91 | 96 |
mEffects = new DistortedEffects[NUM_OBJECTS]; |
97 |
mPostEffects= new DistortedEffectsPostprocess(); |
|
92 | 98 |
|
93 | 99 |
for(int i=0; i<NUM_OBJECTS; i++) |
94 | 100 |
{ |
... | ... | |
103 | 109 |
mBlurDynamic= new Dynamic1D(); |
104 | 110 |
mBlurVector = new Static1D(10); |
105 | 111 |
mBlurDynamic.add(mBlurVector); |
106 |
|
|
107 |
mBlurStatus[0] = true; |
|
108 |
mEffects[0].blur(mBlurDynamic); |
|
112 |
mPostEffects.blur(mBlurDynamic); |
|
109 | 113 |
|
110 | 114 |
MeshCubes mesh = new MeshCubes(1,1,false); |
111 | 115 |
|
... | ... | |
124 | 128 |
mScreen = new DistortedScreen(); |
125 | 129 |
|
126 | 130 |
for(int i=0; i<NUM_OBJECTS; i++) |
127 |
mScreen.attach( i<NUM_OBJECTS/2 ? mTex1:mTex2, mEffects[i], mesh); |
|
131 |
{ |
|
132 |
mNode[i] = new DistortedNode(i < NUM_OBJECTS / 2 ? mTex1 : mTex2, mEffects[i], mesh); |
|
133 |
mScreen.attach(mNode[i]); |
|
134 |
} |
|
135 |
|
|
136 |
mBlurStatus[0] = true; |
|
137 |
mNode[0].setPostprocessEffects(mPostEffects); |
|
128 | 138 |
} |
129 | 139 |
|
130 | 140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
240 | 250 |
|
241 | 251 |
void setChecked(int number, boolean checked) |
242 | 252 |
{ |
243 |
if( number>=0 && number<=7 && mEffects!=null )
|
|
253 |
if( number>=0 && number<=7 ) |
|
244 | 254 |
{ |
245 | 255 |
if( checked && !mBlurStatus[number] ) |
246 | 256 |
{ |
247 | 257 |
mBlurStatus[number] = true; |
248 |
mEffects[number].blur(mBlurDynamic);
|
|
258 |
mNode[number].setPostprocessEffects(mPostEffects);
|
|
249 | 259 |
} |
250 | 260 |
if( !checked && mBlurStatus[number] ) |
251 | 261 |
{ |
252 | 262 |
mBlurStatus[number] = false; |
253 |
mEffects[number].abortEffects(EffectNames.BLUR);
|
|
263 |
mNode[number].setPostprocessEffects(null);
|
|
254 | 264 |
} |
255 | 265 |
} |
256 | 266 |
else |
257 | 267 |
{ |
258 |
android.util.Log.e("renderer", "Error, number: "+number+" checked: "+checked+" mEffects="+ (mEffects==null ? "null":"not null") );
|
|
268 |
android.util.Log.e("renderer", "Error, number: "+number+" checked: "+checked ); |
|
259 | 269 |
} |
260 | 270 |
|
261 | 271 |
//android.util.Log.d("renderer", "setting box "+number+" BLUR state to "+checked); |
Also available in: Unified diff
Separate the Postprocessing Effects to their own DistortedEffectsPostprocess queue.
This partly breaks Multiblur (to be debugged)