Revision 678c391d
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/postprocesstree/PostprocessTreeRenderer.java | ||
---|---|---|
36 | 36 |
import org.distorted.library.main.DistortedTexture; |
37 | 37 |
import org.distorted.library.mesh.MeshQuad; |
38 | 38 |
import org.distorted.library.type.Dynamic1D; |
39 |
import org.distorted.library.type.Dynamic2D; |
|
39 | 40 |
import org.distorted.library.type.Static1D; |
41 |
import org.distorted.library.type.Static2D; |
|
40 | 42 |
import org.distorted.library.type.Static3D; |
41 | 43 |
|
42 | 44 |
import java.io.IOException; |
... | ... | |
56 | 58 |
private DistortedTexture mLeaf; |
57 | 59 |
private DistortedScreen mScreen; |
58 | 60 |
private Static3D mScale; |
59 |
private Static1D mRadius;
|
|
61 |
private Static2D mHaloRadius;
|
|
60 | 62 |
|
61 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
62 | 64 |
|
... | ... | |
67 | 69 |
final int OUTER = 9; |
68 | 70 |
final int INNER = 4; |
69 | 71 |
|
70 |
mRadius = new Static1D(5);
|
|
71 |
Dynamic1D radiusDyn = new Dynamic1D();
|
|
72 |
radiusDyn.add(mRadius);
|
|
73 |
PostprocessEffectBlur blurEffect = new PostprocessEffectBlur(radiusDyn);
|
|
72 |
mHaloRadius = new Static2D(30,5);
|
|
73 |
Dynamic2D haloRadiusDyn = new Dynamic2D();
|
|
74 |
haloRadiusDyn.add(mHaloRadius);
|
|
75 |
PostprocessEffectBlur blurEffect = new PostprocessEffectBlur(haloRadiusDyn);
|
|
74 | 76 |
|
75 | 77 |
mLeaf = new DistortedTexture(); |
76 | 78 |
mScale= new Static3D(1,1,1); |
... | ... | |
94 | 96 |
|
95 | 97 |
Static3D center = new Static3D(0,0,0); |
96 | 98 |
Static3D axis = new Static3D(0,0,1); |
97 |
Static3D innerMoveVector = new Static3D( (1-INNER)*LEAF_SIZE/2, 0, 0);
|
|
98 |
Static3D outerMoveVector = new Static3D( (4-OUTER)*LEAF_SIZE/2, 0, 0);
|
|
99 |
Static3D innerMoveVector = new Static3D( (1-INNER)*LEAF_SIZE*0.5f, 0, 0);
|
|
100 |
Static3D outerMoveVector = new Static3D( (4-OUTER)*LEAF_SIZE*0.5f, 0, 0);
|
|
99 | 101 |
|
100 | 102 |
for(int j=0; j<NUM_LEAVES; j++) |
101 | 103 |
{ |
... | ... | |
135 | 137 |
int setBlur(int blur) |
136 | 138 |
{ |
137 | 139 |
int radius = blur/2; |
138 |
mRadius.set(radius);
|
|
140 |
mHaloRadius.set1(radius);
|
|
139 | 141 |
return radius; |
140 | 142 |
} |
141 | 143 |
|
... | ... | |
152 | 154 |
{ |
153 | 155 |
float horiRatio = (float)width ; |
154 | 156 |
float vertRatio = (float)height; |
155 |
float factor = horiRatio > vertRatio ? vertRatio : horiRatio;
|
|
157 |
float factor = Math.min(horiRatio, vertRatio);
|
|
156 | 158 |
|
157 | 159 |
mScale.set(factor,factor,factor); |
158 | 160 |
mScreen.resize(width, height); |
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.