Project

General

Profile

« Previous | Next » 

Revision 678c391d

Added by Leszek Koltunski about 4 years ago

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.

View differences:

src/main/java/org/distorted/examples/glow/GlowRenderer.java
32 32
import org.distorted.library.main.DistortedScreen;
33 33
import org.distorted.library.main.DistortedTexture;
34 34
import org.distorted.library.mesh.MeshQuad;
35
import org.distorted.library.type.Static1D;
35
import org.distorted.library.type.Static2D;
36 36
import org.distorted.library.type.Static3D;
37 37
import org.distorted.library.type.Static4D;
38 38

  
......
47 47
class GlowRenderer implements GLSurfaceView.Renderer
48 48
{
49 49
   private static final int LEAF_SIZE = 100;
50
   private static final float HALO_TO_RADIUS = 0.2f;
50 51

  
51 52
   private GLSurfaceView mView;
52 53
   private DistortedTexture mLeaf;
......
54 55
   private PostprocessEffectGlow mGlow;
55 56
   private int mRootW, mRootH;
56 57
   private Static3D mScale;
57
   private Static1D mRadius;
58
   private Static2D mHaloRadius;
58 59
   private Static4D mColor;
59 60

  
60 61
///////////////////////////////////////////////////////////////////////////////////////////////////
......
63 64
      {     
64 65
      mView = v;
65 66

  
66
      mRootW = LEAF_SIZE;
67
      mRootH = LEAF_SIZE;
68
      mLeaf  = new DistortedTexture();
69
      mScale = new Static3D(1,1,1);
70
      mRadius= new Static1D(25);
71
      mColor = new Static4D(1.0f,0.0f,0.0f,0.5f); // half-transparent red
67
      mRootW     = LEAF_SIZE;
68
      mRootH     = LEAF_SIZE;
69
      mLeaf      = new DistortedTexture();
70
      mScale     = new Static3D(1,1,1);
71
      mHaloRadius= new Static2D(25*HALO_TO_RADIUS,25);
72
      mColor     = new Static4D(1.0f,0.0f,0.0f,0.5f); // half-transparent red
72 73

  
73
      mGlow  = new PostprocessEffectGlow(mRadius,mColor);
74
      mGlow  = new PostprocessEffectGlow(mHaloRadius,mColor);
74 75

  
75 76
      DistortedEffects effects = new DistortedEffects();
76 77
      effects.apply(new MatrixEffectScale(mScale));
......
97 98
   int setGlowRadius(int glow)
98 99
     {
99 100
     int radius = glow/2;
100
     mRadius.set(radius);
101
     mHaloRadius.set(radius*HALO_TO_RADIUS,radius);
101 102
     return radius;
102 103
     }
103 104

  

Also available in: Unified diff