Project

General

Profile

« Previous | Next » 

Revision 513b2e9c

Added by Leszek Koltunski over 4 years ago

A lot of changes.

1) main vertex shader: remove support for degree_object. This functionality will hopefully come back when we introduce other than circular regions.
2) MeshBase: remove the need to set a Bounding box (this is the point of the whole thing - we wanted to get rid of this so that the advances in MeshJoined will be easier)
3) Set ground for removing the MeshBase.setStretch / getStretch (another thing needed to advance MeshJoined )
4) since we removed the Bounding box, we need to change the DEFORN effect to have 1 additional parameter, the 'radius' which takes over the function of the bounding box in the vertex shader.
5) since the'res no bounding box, simplify the postprocessing Halo (remove EffectQueueMatrix.magnify() )
6) adjust applications.

After this we will hopefully be ready to introduce MeshBase.preApply(VertexEffect), i.e. bending several simple Meshes with any VertexEffect - including the freshly-introduced PseudoMatrix-Vertex effects like VertexEffectScale - and then combining them into one MeshJoined.

View differences:

src/main/java/org/distorted/examples/check/CheckRenderer.java
66 66
    private DistortedScreen mScreen;
67 67
    private int mObjHeight, mObjWidth;
68 68
    private Static3D mScale, mSwirl1, mSwirl2, mDeform1, mDeform2;
69
    private Static1D mRadius;
69 70

  
70 71
///////////////////////////////////////////////////////////////////////////////////////////////////
71 72

  
......
88 89
      mDeform2= new Static3D(0,0,0);
89 90
      mScale  = new Static3D(1,1,1);
90 91

  
92
      mRadius = new Static1D(0);
93

  
91 94
      mEffects = new DistortedEffects();
92 95
      mEffects.apply(new MatrixEffectScale(mScale));
93 96

  
......
110 113
      dDeform.add(mDeform1);
111 114
      dDeform.add(mDeform2);
112 115

  
113
      if( !mEffects.apply( new VertexEffectDeform(dDeform,new Static3D(0,0,0)) ) )
116
      if( !mEffects.apply( new VertexEffectDeform(dDeform, mRadius, new Static3D(0,0,0)) ) )
114 117
        {
115 118
        Log.e("Check", "Failed to add Deform effect!");
116 119
        }
......
175 178
      mObjHeight = bitmap.getHeight();
176 179
      mObjWidth  = bitmap.getWidth();
177 180

  
181
      mRadius.set(mObjWidth/2);
182

  
178 183
      if( mTexture==null ) mTexture = new DistortedTexture();
179 184
      mTexture.setTexture(bitmap);
180 185

  
src/main/java/org/distorted/examples/deform/DeformRenderer.java
36 36

  
37 37
import org.distorted.library.message.EffectListener;
38 38
import org.distorted.library.type.Dynamic3D;
39
import org.distorted.library.type.Static1D;
39 40
import org.distorted.library.type.Static3D;
40 41
import org.distorted.library.type.Static4D;
41 42

  
......
140 141
      mScreen = new DistortedScreen();
141 142
      mScreen.showFPS();
142 143

  
143
      mMovingDistort   = new VertexEffectDistort( movingDistortDynamic  , mTouchPoint, mRegion);
144
      mMovingDeform    = new VertexEffectDeform ( movingDeformDynamic   , mTouchPoint, mRegion);
145
      mMovingShear     = new MatrixEffectShear  ( movingShearDynamic    , mTouchPoint         );
146
      mReleasedDistort = new VertexEffectDistort( releasedDistortDynamic, mTouchPoint, mRegion);
147
      mReleasedDeform  = new VertexEffectDeform ( releasedDeformDynamic , mTouchPoint, mRegion);
148
      mReleasedShear   = new MatrixEffectShear  ( releasedShearDynamic  , mTouchPoint         );
144
      Static1D deformRadius = new Static1D(0.5f);
145

  
146
      mMovingDistort   = new VertexEffectDistort( movingDistortDynamic  ,               mTouchPoint, mRegion);
147
      mMovingDeform    = new VertexEffectDeform ( movingDeformDynamic   , deformRadius, mTouchPoint, mRegion);
148
      mMovingShear     = new MatrixEffectShear  ( movingShearDynamic    ,               mTouchPoint         );
149
      mReleasedDistort = new VertexEffectDistort( releasedDistortDynamic,               mTouchPoint, mRegion);
150
      mReleasedDeform  = new VertexEffectDeform ( releasedDeformDynamic , deformRadius, mTouchPoint, mRegion);
151
      mReleasedShear   = new MatrixEffectShear  ( releasedShearDynamic  ,               mTouchPoint         );
149 152
      }
150 153

  
151 154
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java
69 69
      Dynamic3D dDistort = new Dynamic3D(3000,0.0f);
70 70
      dDistort.add(new Static3D( 25,0,0));
71 71
      dDistort.add(new Static3D(-25,0,0));
72
      Static3D mPoint = new Static3D(0,-60,0);
72
      Static3D point = new Static3D(0,-60,0);
73
      Static4D region= new Static4D(0,0,0,300);
73 74

  
74 75
      mEffects = new DistortedEffects[NUM];
75 76
      mEffects[0] = new DistortedEffects();
......
78 79

  
79 80
      // Add the effects only to the first queue - all VERTEX and FRAGMENT effects are shared!
80 81
      // (Matrix effect cannot be shared as we have to display each Texture in a different location)
81
      VertexEffectSink sink = new VertexEffectSink(new Static1D(8), mPoint, new Static4D(0,0,0,80));
82
      VertexEffectDistort distort = new VertexEffectDistort(dDistort,mPoint);
82
      VertexEffectSink sink = new VertexEffectSink(new Static1D(8), point, new Static4D(0,0,0,80));
83
      VertexEffectDistort distort = new VertexEffectDistort(dDistort,point,region);
83 84
      mEffects[0].apply(sink);    // enlarge the nose
84 85
      mEffects[0].apply(distort); // keep moving the whole bitmap left and right.
85 86

  
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
70 70
      // mEffects[0] effects
71 71
      Static3D pLeft = new Static3D(214 - 594/2, 394 - 600/2, 0);
72 72
      Static3D pRight= new Static3D(390 - 594/2, 388 - 600/2, 0);
73
      Static4D RegionEye = new Static4D(0,0,0,60);
74
      
73
      Static4D RegionEye = new Static4D(0,0,0, 60);
74
      Static4D RegionCen = new Static4D(0,0,0,300);
75

  
75 76
      // mEffects[1] effects
76 77
      Dynamic3D dyn = new Dynamic3D(1000,0.0f);
77 78
      dyn.add(new Static3D( 50,0,0));
......
90 91

  
91 92
      VertexEffectSink sinkL = new VertexEffectSink(sink, pLeft , RegionEye);
92 93
      VertexEffectSink sinkR = new VertexEffectSink(sink, pRight, RegionEye);
93
      VertexEffectDistort distort = new VertexEffectDistort(dyn,pNose1);
94
      VertexEffectDistort distort = new VertexEffectDistort(dyn,pNose1, RegionCen);
94 95

  
95 96
      mEffects[0].apply(sinkL);
96 97
      mEffects[0].apply(sinkR);
src/main/java/org/distorted/examples/earth/EarthRenderer.java
210 210
        case DISTORT          : vector = new Static3D( +x*mObjWidth/CORR, +y*mObjHeight/CORR, +z*mObjDepth/CORR);
211 211
                                effect = new VertexEffectDistort(   vector, center, mRegionV); break;
212 212
        case DEFORM           : vector = new Static3D( +x*mObjWidth/CORR, +y*mObjHeight/CORR, +z*mObjDepth/CORR);
213
                                effect = new VertexEffectDeform (   vector, center, mRegionV); break;
213
                                Static1D radius = new Static1D(mObjWidth/2);
214
                                effect = new VertexEffectDeform (   vector, radius, center, mRegionV); break;
214 215
        case SINK             : effect = new VertexEffectSink   (mStrength, center, mRegionV); break;
215 216
        case PINCH            : float lat = latitude>0 ? (float)(-Math.PI/2 + latitude) : (float)(Math.PI/2 + latitude);
216 217
                                float lon = longitude;
src/main/java/org/distorted/examples/generic/GenericEffect.java
118 118
      case SCALE            : effect = new MatrixEffectScale       (mDyn3)                   ; break;
119 119
      case SHEAR            : effect = new MatrixEffectShear       (mDyn3, mCenterDyn)       ; break;
120 120

  
121
      case DISTORT          : effect = new VertexEffectDistort     (mDyn3, mCenterDyn, mRegion4Dyn); break;
122
      case DEFORM           : effect = new VertexEffectDeform      (mDyn3, mCenterDyn, mRegion4Dyn); break;
123
      case SINK             : effect = new VertexEffectSink        (mDyn1, mCenterDyn, mRegion4Dyn); break;
124
      case PINCH            : effect = new VertexEffectPinch       (mDyn3, mCenterDyn, mRegion4Dyn); break;
125
      case SWIRL            : effect = new VertexEffectSwirl       (mDyn1, mCenterDyn, mRegion4Dyn); break;
126
      case WAVE             : effect = new VertexEffectWave        (mDyn5, mCenterDyn, mRegion4Dyn); break;
127
      case VERTEX_MOVE      : effect = new VertexEffectMove        (mDyn3)                         ; break;
128
      case VERTEX_QUATERNION: effect = new VertexEffectQuaternion  (mDyn4, mCenterDyn)             ; break;
129
      case VERTEX_ROTATE    : effect = new VertexEffectRotate      (mDyn1, mDyn3, mCenterDyn)      ; break;
130
      case VERTEX_SCALE     : effect = new VertexEffectScale       (mDyn3)                         ; break;
131
      case VERTEX_SHEAR     : effect = new VertexEffectShear       (mDyn3, mCenterDyn)             ; break;
121
      case DISTORT          : effect = new VertexEffectDistort     (mDyn3, mCenterDyn, mRegion4Dyn)              ; break;
122
      case DEFORM           : effect = new VertexEffectDeform      (mDyn3, mDyn1, mCenterDyn, mRegion4Dyn)       ; break;
123
      case SINK             : effect = new VertexEffectSink        (mDyn1, mCenterDyn, mRegion4Dyn)              ; break;
124
      case PINCH            : effect = new VertexEffectPinch       (mDyn3, mCenterDyn, mRegion4Dyn)              ; break;
125
      case SWIRL            : effect = new VertexEffectSwirl       (mDyn1, mCenterDyn, mRegion4Dyn)              ; break;
126
      case WAVE             : effect = new VertexEffectWave        (mDyn5, mCenterDyn, mRegion4Dyn)              ; break;
127
      case VERTEX_MOVE      : effect = new VertexEffectMove        (mDyn3)                                       ; break;
128
      case VERTEX_QUATERNION: effect = new VertexEffectQuaternion  (mDyn4, mCenterDyn)                           ; break;
129
      case VERTEX_ROTATE    : effect = new VertexEffectRotate      (mDyn1, mDyn3, mCenterDyn)                    ; break;
130
      case VERTEX_SCALE     : effect = new VertexEffectScale       (mDyn3)                                       ; break;
131
      case VERTEX_SHEAR     : effect = new VertexEffectShear       (mDyn3, mCenterDyn)                           ; break;
132 132

  
133 133
      case ALPHA            : effect = new FragmentEffectAlpha     (mDyn1,        mCenterDyn, mRegion3Dyn, false); break;
134 134
      case SMOOTH_ALPHA     : effect = new FragmentEffectAlpha     (mDyn1,        mCenterDyn, mRegion3Dyn, true ); break;
......
207 207
      ///////////////////////////////////////////////////////////////////////////////////////
208 208

  
209 209
      case VERTEX_MOVE      :
210
      case DISTORT          :
211
      case DEFORM           : float ld = mAct.get().getWidth()/50.0f;
210
      case DISTORT          : float ld = mAct.get().getWidth()/50.0f;
212 211
                              float xd = (mInter[0]-50)*ld;
213 212
                              float yd = (mInter[1]-50)*ld;
214 213
                              float zd = (mInter[2]-50)*ld;
215 214
                              mSta3.set(xd,yd,zd);
216 215
                              break;
216
      case DEFORM           : float le = mAct.get().getWidth()/50.0f;
217
                              float xe = (mInter[0]-50)*le;
218
                              float ye = (mInter[1]-50)*le;
219
                              float ze = (mInter[2]-50)*le;
220
                              mSta3.set(xe,ye,ze);
221
                              float re = (mInter[3])*le;
222
                              mSta1.set(re);
223
                              break;
217 224
      case WAVE             : float l2 = mAct.get().getWidth()/50.0f;
218 225
                              float x2 = (mInter[0]-50)*l2;
219 226
                              float y2 = (mInter[1]-50)*l2;
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
66 66
    private int mCurrEffect;
67 67
    private int mSize1, mSize2;
68 68
    private Static3D mDeform;
69
    private Static1D mRadius;
69 70

  
70 71
    private MovingEffectsRenderer mRenderer;
71 72

  
......
88 89
      
89 90
      mCenter = new Dynamic3D(LOOP_TIME,0.0f);
90 91
      mDeform = new Static3D(0,0,0.15f);
92
      mRadius = new Static1D(0);
91 93

  
92 94
      if(!isInEditMode())
93 95
        {
......
103 105
        Static3D regionFrag = new Static3D(0.15f,0.15f,0.15f);
104 106
        Static4D regionVert = new Static4D(0,0,0,0.15f);
105 107

  
106
        mEffectDeform  = new VertexEffectDeform  ( mDeform          , mCenter, regionVert);
108
        mEffectDeform  = new VertexEffectDeform  ( mDeform          , mRadius, mCenter, regionVert);
107 109
        mEffectSink    = new VertexEffectSink    (new Static1D(10)  , mCenter, regionVert);
108 110
        mEffectSwirl   = new VertexEffectSwirl   (new Static1D(30)  , mCenter, regionVert);
109 111
        mEffectAlpha   = new FragmentEffectAlpha (new Static1D(0.5f), mCenter, regionFrag, true);
......
120 122
      mScrWidth  = width;
121 123
      mScrHeight = height;
122 124

  
125
      mRadius.set(max/2);
126

  
123 127
      mSize1 = max/200;
124 128
      mSize2 = max/80;
125 129
      }
src/main/java/org/distorted/examples/movingglow/MovingGlowRenderer.java
108 108

  
109 109
      Dynamic1D radiusDyn = new Dynamic1D(FLASH_TIME,1.0f);
110 110
      radiusDyn.add(new Static1D( 0));
111
      radiusDyn.add(new Static1D(50));
111
      radiusDyn.add(new Static1D(70));
112 112

  
113 113
      for(int leaf=0; leaf<NUM_LEAVES; leaf++)
114 114
        {
src/main/java/org/distorted/examples/objecttree/ObjectTreeRenderer.java
56 56
class ObjectTreeRenderer implements GLSurfaceView.Renderer
57 57
{
58 58
   private static final int NODE_FBO_SIZE = 300;
59
   private static final int GRID = 20;
59 60

  
60 61
   private GLSurfaceView mView;
61 62
   private DistortedEffects mEffectsNode, mEffectsGrid;
......
85 86

  
86 87
      mEffectsGrid = new DistortedEffects();
87 88

  
88
      float factor = NODE_FBO_SIZE/2;
89
      MatrixEffectScale scale = new MatrixEffectScale( new Static3D(factor,factor,factor/10) );
89
      float factor = NODE_FBO_SIZE/(2.0f*GRID);
90
      MatrixEffectScale scale = new MatrixEffectScale( new Static3D(factor,factor,factor) );
90 91
      mEffectsGrid.apply(scale);
91 92

  
92 93
      Dynamic1D rotDyn = new Dynamic1D(12000,0.0f);
......
99 100
      Dynamic1D sinkDyn = new Dynamic1D(3000,0.0f);
100 101
      sinkDyn.add(new Static1D(1.0f));
101 102
      sinkDyn.add(new Static1D(0.3f));
102
      VertexEffectSink sink = new VertexEffectSink(sinkDyn, new Static3D(0,0,0) );
103
      VertexEffectSink sink = new VertexEffectSink(sinkDyn, new Static3D(0,0,0), new Static4D(0,0,0,10) );
103 104
      mEffectsGrid.apply(sink);
104 105

  
105 106
      mScreen = new DistortedScreen();
......
179 180
      mLisaTexture.setTexture(bitmapLisa);
180 181
      mGridTexture.setTexture(bitmapGrid);
181 182

  
182
      final int GRID = 20;
183 183
      final Static4D mapFB = new Static4D(0.0f,0.0f,1.0f     ,1.0f     );
184 184
      final Static4D mapLR = new Static4D(0.0f,0.0f,1.0f/GRID,1.0f     );
185 185
      final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f     ,1.0f/GRID);
186 186

  
187 187
      if( mMeshQuad ==null ) mMeshQuad = new MeshQuad();
188
      if( mMeshCubes==null ) mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB);
188
      if( mMeshCubes==null )
189
        {
190
        mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB);
191
        mMeshCubes.setStretch(GRID,GRID,1);
192
        }
193

  
189 194

  
190 195
      mRoot = new DistortedNode(mLisaTexture, mEffectsNode, mMeshQuad);
191 196
      mRoot.resizeFBO(NODE_FBO_SIZE,NODE_FBO_SIZE);
src/main/java/org/distorted/examples/projection/ProjectionRenderer.java
29 29
import org.distorted.library.main.DistortedScreen;
30 30
import org.distorted.library.mesh.MeshRectangles;
31 31
import org.distorted.library.main.DistortedTexture;
32
import org.distorted.library.type.Static1D;
32 33
import org.distorted.library.type.Static3D;
33 34
import org.distorted.library.type.Static4D;
34 35

  
......
65 66
      Static4D region = new Static4D( 0, 0, 0, 0.25f);
66 67
      Static3D vector = new Static3D( 0, 0, 0.25f);
67 68

  
69
      Static1D deformRadius = new Static1D(1);
70

  
68 71
      mScale = new Static3D(1,1,1);
69 72

  
70 73
      mEffects.apply( new MatrixEffectScale(mScale) );
71 74

  
72
      mEffects.apply( new VertexEffectDeform(vector, point1, region) );
73
      mEffects.apply( new VertexEffectDeform(vector, point2, region) );
74
      mEffects.apply( new VertexEffectDeform(vector, point3, region) );
75
      mEffects.apply( new VertexEffectDeform(vector, point4, region) );
75
      mEffects.apply( new VertexEffectDeform(vector, deformRadius, point1, region) );
76
      mEffects.apply( new VertexEffectDeform(vector, deformRadius, point2, region) );
77
      mEffects.apply( new VertexEffectDeform(vector, deformRadius, point3, region) );
78
      mEffects.apply( new VertexEffectDeform(vector, deformRadius, point4, region) );
76 79

  
77 80
      mTexture= new DistortedTexture();
78 81
      }
src/main/java/org/distorted/examples/sink/SinkRenderer.java
37 37
import org.distorted.library.type.Dynamic1D;
38 38
import org.distorted.library.type.Static1D;
39 39
import org.distorted.library.type.Static3D;
40
import org.distorted.library.type.Static4D;
40 41

  
41 42
import android.graphics.Bitmap;
42 43
import android.graphics.BitmapFactory;
......
64 65
    mScreen  = new DistortedScreen();
65 66

  
66 67
    Dynamic1D sinkStrength = new Dynamic1D(2000,0.0f);
67
    sinkStrength.add(new Static1D(1.0f));
68
    sinkStrength.add(new Static1D(2.0f));
68 69
    sinkStrength.add(new Static1D(0.2f));
69 70

  
70 71
    // strength [changing in time from 1.0 to 0.2 and back],
71 72
    // center   [(0,0,0), i.e. center of the bitmap],
72
    // region   [null - apply to the whole bitmap
73
    VertexEffectSink sinkEffect = new VertexEffectSink(sinkStrength, new Static3D(0,0,0), null);
73
    // region   [ (0,0,0) with radius 0.5 - apply to the center circle of the bitmap ]
74
    VertexEffectSink sinkEffect = new VertexEffectSink(sinkStrength, new Static3D(0,0,0), new Static4D(0,0,0,0.5f) );
74 75
    mEffects.apply(sinkEffect);
75 76

  
76 77
    mScale = new Static3D(1,1,1);
src/main/java/org/distorted/examples/triblur/TriblurRenderer.java
32 32
import org.distorted.library.effect.MatrixEffectScale;
33 33
import org.distorted.library.effect.PostprocessEffectBlur;
34 34
import org.distorted.library.effect.PostprocessEffectGlow;
35
import org.distorted.library.effect.VertexEffectScale;
35 36
import org.distorted.library.main.DistortedLibrary;
36 37
import org.distorted.library.main.DistortedEffects;
37 38
import org.distorted.library.main.DistortedNode;
......
110 111
      mScale2 = new Static3D(1.5f,1.5f,1.5f);
111 112
      Static3D center = new Static3D(0,0,0);
112 113

  
114
     // VertexEffectScale scaleEffectV = new VertexEffectScale(OBJ_SIZE);
113 115
      MatrixEffectScale scaleEffect1 = new MatrixEffectScale(mScale1);
114 116
      MatrixEffectScale scaleEffect2 = new MatrixEffectScale(mScale2);
115 117
      MatrixEffectQuaternion quatEffect1 = new MatrixEffectQuaternion(mQuat1, center);
......
126 128
        effects[i]       = new DistortedEffects();
127 129
        effects[i].apply(mBlur[i]);
128 130
        effects[i].apply(chroma[i]);
129

  
131
      //  effects[i].apply(scaleEffectV);
130 132
        effects[i].apply(new MatrixEffectMove(moveVector[i]));
131 133
        effects[i].apply(quatEffect2);
132 134
        effects[i].apply(quatEffect1);
......
193 195

  
194 196
      mTex.setTexture(bitmap);
195 197

  
198
      VertexEffectScale.enable();
196 199
      PostprocessEffectBlur.enable();
197 200
      FragmentEffectChroma.enable();
198 201

  
src/main/java/org/distorted/examples/wind/WindEffectsManager.java
28 28
import org.distorted.library.main.DistortedEffects;
29 29
import org.distorted.library.type.Dynamic;
30 30
import org.distorted.library.type.Dynamic5D;
31
import org.distorted.library.type.Static1D;
31 32
import org.distorted.library.type.Static3D;
32 33
import org.distorted.library.type.Static4D;
33 34
import org.distorted.library.type.Static5D;
......
114 115
    effects.apply( new MatrixEffectScale(scaleFactor) );
115 116
    effects.apply( new MatrixEffectShear(shearFactor,midLeft) );
116 117

  
117
    effects.apply( new VertexEffectDeform(deformForce,midRight) );
118
    effects.apply( new VertexEffectDeform(deformForce, new Static1D(mWidth/2), midRight) );
118 119
    effects.apply( new VertexEffectWave(windDynamic1, midRight, windRegion) );
119 120
    effects.apply( new VertexEffectWave(windDynamic2, midRight, windRegion) );
120 121
    effects.apply( new VertexEffectWave(windDynamic3, midRight, windRegion) );
src/main/java/org/distorted/examples/wind/WindRenderer.java
49 49

  
50 50
class WindRenderer implements GLSurfaceView.Renderer
51 51
{
52
   private static final int X = 50;
53
   private static final int Y = 30;
54
   private static final int Z =  1;
55

  
52 56
   private GLSurfaceView mView;
53 57
   private DistortedTexture mTexture;
54 58
   private DistortedScreen mScreen;
......
63 67
      { 
64 68
      mView = view;
65 69

  
66
      MeshCubes cubes = new MeshCubes(50,30,1);
70
      MeshCubes cubes = new MeshCubes(X,Y,Z);
67 71
      DistortedEffects effects = new DistortedEffects();
68
      cubes.setStretch(50,30,1);
72
      cubes.setStretch(X,Y,Z);
69 73

  
70 74
      mTexture = new DistortedTexture();
71
      mManager = new WindEffectsManager(50,30);
75
      mManager = new WindEffectsManager(X,Y);
72 76
      mGust    = new WindGust();
73 77
      mScreen  = new DistortedScreen();
74 78

  

Also available in: Unified diff