Revision 678c391d
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/triblur/TriblurRenderer.java | ||
---|---|---|
40 | 40 |
import org.distorted.library.main.DistortedTexture; |
41 | 41 |
import org.distorted.library.mesh.MeshCubes; |
42 | 42 |
import org.distorted.library.type.Static1D; |
43 |
import org.distorted.library.type.Static2D; |
|
43 | 44 |
import org.distorted.library.type.Static3D; |
44 | 45 |
import org.distorted.library.type.Static4D; |
45 | 46 |
|
... | ... | |
68 | 69 |
private GLSurfaceView mView; |
69 | 70 |
private DistortedTexture mTex; |
70 | 71 |
private DistortedNode[] mNode; |
71 |
private Static1D[] mEffectVector;
|
|
72 |
private Static2D[] mEffectHaloRadius;
|
|
72 | 73 |
private DistortedScreen mScreen; |
73 | 74 |
private PostprocessEffectBlur[] mBlur; |
74 | 75 |
private PostprocessEffectGlow[] mGlow; |
... | ... | |
95 | 96 |
mScreen = new DistortedScreen(); |
96 | 97 |
mScreen.showFPS(); |
97 | 98 |
|
98 |
mEffectStatus = new int[NUM_OBJECTS]; |
|
99 |
mEffectVector = new Static1D[NUM_OBJECTS];
|
|
100 |
mNode = new DistortedNode[NUM_OBJECTS]; |
|
101 |
mBlur = new PostprocessEffectBlur[NUM_OBJECTS]; |
|
102 |
mGlow = new PostprocessEffectGlow[NUM_OBJECTS]; |
|
99 |
mEffectStatus = new int[NUM_OBJECTS];
|
|
100 |
mEffectHaloRadius= new Static2D[NUM_OBJECTS];
|
|
101 |
mNode = new DistortedNode[NUM_OBJECTS];
|
|
102 |
mBlur = new PostprocessEffectBlur[NUM_OBJECTS];
|
|
103 |
mGlow = new PostprocessEffectGlow[NUM_OBJECTS];
|
|
103 | 104 |
|
104 | 105 |
FragmentEffectChroma[] chroma= new FragmentEffectChroma[NUM_OBJECTS]; |
105 | 106 |
Static3D[] chromaVector = new Static3D[NUM_OBJECTS]; |
... | ... | |
119 | 120 |
|
120 | 121 |
for(int i=0; i<NUM_OBJECTS; i++) |
121 | 122 |
{ |
122 |
moveVector[i] = new Static3D(OBJECTS[NUM*i ], OBJECTS[NUM*i+1], OBJECTS[NUM*i+2]); |
|
123 |
chromaVector[i] = new Static3D(OBJECTS[NUM*i+3], OBJECTS[NUM*i+4], OBJECTS[NUM*i+5]); |
|
124 |
mEffectVector[i] = new Static1D(10);
|
|
125 |
mBlur[i] = new PostprocessEffectBlur(mEffectVector[i]);
|
|
126 |
mGlow[i] = new PostprocessEffectGlow(mEffectVector[i], new Static4D(1.0f,1.0f,1.0f,0.5f) );
|
|
127 |
chroma[i] = new FragmentEffectChroma( new Static1D(0.3f), chromaVector[i]); |
|
128 |
effects[i] = new DistortedEffects(); |
|
123 |
moveVector[i] = new Static3D(OBJECTS[NUM*i ], OBJECTS[NUM*i+1], OBJECTS[NUM*i+2]);
|
|
124 |
chromaVector[i] = new Static3D(OBJECTS[NUM*i+3], OBJECTS[NUM*i+4], OBJECTS[NUM*i+5]);
|
|
125 |
mEffectHaloRadius[i]= new Static2D(10,10);
|
|
126 |
mBlur[i] = new PostprocessEffectBlur(mEffectHaloRadius[i] );
|
|
127 |
mGlow[i] = new PostprocessEffectGlow(mEffectHaloRadius[i], new Static4D(1.0f,1.0f,1.0f,0.5f) );
|
|
128 |
chroma[i] = new FragmentEffectChroma( new Static1D(0.3f), chromaVector[i]);
|
|
129 |
effects[i] = new DistortedEffects();
|
|
129 | 130 |
effects[i].apply(mBlur[i]); |
130 | 131 |
effects[i].apply(chroma[i]); |
131 | 132 |
// effects[i].apply(scaleEffectV); |
... | ... | |
213 | 214 |
|
214 | 215 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
215 | 216 |
{ |
216 |
mScreenMin = width<height ? width:height;
|
|
217 |
mScreenMin = Math.min(width, height);
|
|
217 | 218 |
|
218 | 219 |
float factor1 = 0.20f*mScreenMin/OBJ_SIZE; |
219 | 220 |
float factor2 = 0.75f*factor1; |
... | ... | |
228 | 229 |
{ |
229 | 230 |
if( object>=0 && object<NUM_OBJECTS ) |
230 | 231 |
{ |
231 |
mEffectVector[object].set(range / 2);
|
|
232 |
mEffectHaloRadius[object].set(range*0.5f,range*0.5f);
|
|
232 | 233 |
} |
233 | 234 |
} |
234 | 235 |
|
Also available in: Unified diff
Change the Postprocessing effects: separate the radius and the halo.
Reason: we needed a way to specify the size of the halo around a postprocessed object; before it was automatically (and not very correctly) computed from the radius - before we knew the size of the object's bounding box, so this automatic computation was possible. Now we're removing the MashBase.getBounding(0 API, so the size of the halo has to be explicitly given by the user. This way is more correct anyway and gives the user more control (as the Multiblur app proves!)
Warning: here for the first time I can see that the 2 Examples (PostprocessingTree and MovingGlow) sometimes would not appear (black screen). Maybe this commit introduces such a bug - investigate.