Project

General

Profile

« Previous | Next » 

Revision b7dba709

Added by Leszek Koltunski about 7 years ago

Roll back the recent MIPMAP work.

View differences:

src/main/java/org/distorted/library/DistortedOutputSurface.java
27 27

  
28 28
abstract class DistortedOutputSurface extends DistortedSurface implements DistortedSlave
29 29
{
30
  private static final int NUM_MIPMAP = 4;
31
          static final int CUR_MIPMAP = 1;
32

  
33 30
  private static final int ATTACH = 0;
34 31
  private static final int DETACH = 1;
35 32
  private static final int DETALL = 2;
......
54 51

  
55 52
  private ArrayList<Job> mJobs = new ArrayList<>();
56 53

  
57
  DistortedFramebuffer[] mBuffer1, mBuffer2;
54
  DistortedFramebuffer mBuffer1, mBuffer2;
58 55

  
59 56
  private long mTime;
60 57
  private float mFOV;
......
98 95

  
99 96
    mClearDepth = 1.0f;
100 97

  
101
    mBuffer1 = new DistortedFramebuffer[NUM_MIPMAP];
102
    mBuffer2 = new DistortedFramebuffer[NUM_MIPMAP];
103

  
104 98
    createProjection();
105 99
    }
106 100

  
......
177 171
        }
178 172
      else
179 173
        {
180
        if( mBuffer1[0]==null )
174
        if( mBuffer1==null )
181 175
          {
182
          int sizeX = mWidth;
183
          int sizeY = mHeight;
184

  
185
          for(int j=0; j<NUM_MIPMAP; j++)
186
            {
187
            mBuffer1[j] = new DistortedFramebuffer(mDepthCreated!=DONT_CREATE, DistortedSurface.TYPE_SYST, sizeX, sizeY);
188
            mBuffer2[j] = new DistortedFramebuffer(false                     , DistortedSurface.TYPE_SYST, sizeX, sizeY);
189

  
190
            sizeX *= 0.9f;
191
            sizeY *= 0.9f;
192
            }
176
          mBuffer1 = new DistortedFramebuffer(mDepthCreated!=DONT_CREATE, DistortedSurface.TYPE_SYST, mWidth, mHeight);
177
          mBuffer2 = new DistortedFramebuffer(false                     , DistortedSurface.TYPE_SYST, mWidth, mHeight);
193 178
          }
194 179

  
195
        numRenders += child.draw(time,mBuffer1[CUR_MIPMAP]);
180
        numRenders += child.draw(time,mBuffer1);
196 181
        if( i==num-1 )
197 182
          {
198 183
          numRenders += currP.postprocess(time,this);
src/main/java/org/distorted/library/EffectQueuePostprocess.java
93 93
  private static float[] offsetsCache = new float[MAX_BLUR + MAX_BLUR*MAX_BLUR/4];
94 94

  
95 95
  private static DistortedProgram mBlur1Program, mBlur2Program;
96
  private static int mRadius1H,mOffsets1H,mWeights1H,mDepth1H, mScale1H, mColorTexture1H;
97
  private static int mRadius2H,mOffsets2H,mWeights2H,mDepth2H, mScale2H, mColorTexture2H, mDepthTexture2H;
96
  private static int mRadius1H,mOffsets1H,mWeights1H,mDepth1H, mColorTexture1H;
97
  private static int mRadius2H,mOffsets2H,mWeights2H,mDepth2H, mColorTexture2H, mDepthTexture2H;
98 98
  private static float[] mWeights = new float[MAX_BLUR];
99 99
  private static float[] mOffsets = new float[MAX_BLUR];
100 100
  // another effect ....
......
131 131
    mOffsets1H      = GLES30.glGetUniformLocation( blur1ProgramH, "u_Offsets");
132 132
    mWeights1H      = GLES30.glGetUniformLocation( blur1ProgramH, "u_Weights");
133 133
    mDepth1H        = GLES30.glGetUniformLocation( blur1ProgramH, "u_Depth");
134
    mScale1H        = GLES30.glGetUniformLocation( blur1ProgramH, "u_Scale");
135 134
    mColorTexture1H = GLES30.glGetUniformLocation( blur1ProgramH, "u_ColorTexture");
136 135

  
137 136
    final InputStream blur2VertexStream   = resources.openRawResource(R.raw.blur_vertex_shader);
......
155 154
    mOffsets2H      = GLES30.glGetUniformLocation( blur2ProgramH, "u_Offsets");
156 155
    mWeights2H      = GLES30.glGetUniformLocation( blur2ProgramH, "u_Weights");
157 156
    mDepth2H        = GLES30.glGetUniformLocation( blur2ProgramH, "u_Depth");
158
    mScale2H        = GLES30.glGetUniformLocation( blur2ProgramH, "u_Scale");
159 157
    mColorTexture2H = GLES30.glGetUniformLocation( blur2ProgramH, "u_ColorTexture");
160 158
    mDepthTexture2H = GLES30.glGetUniformLocation( blur2ProgramH, "u_DepthTexture");
161 159
    }
......
261 259
      {
262 260
      compute(time);
263 261

  
264
      surface.mBuffer1[DistortedOutputSurface.CUR_MIPMAP].setAsInput();
265
      float w = surface.mBuffer1[DistortedOutputSurface.CUR_MIPMAP].mWidth;
266
      float h = surface.mBuffer1[DistortedOutputSurface.CUR_MIPMAP].mHeight;
262
      surface.mBuffer1.setAsInput();
263
      float w = surface.mBuffer1.mWidth;
264
      float h = surface.mBuffer2.mHeight;
267 265

  
268 266
      int radius = (int)mUniforms[0];
269 267
      if( radius>=MAX_BLUR ) radius = MAX_BLUR-1;
......
276 274

  
277 275
      // horizontal blur
278 276
      mBlur1Program.useProgram();
279
      surface.mBuffer2[DistortedOutputSurface.CUR_MIPMAP].setAsOutput(time);
277
      surface.mBuffer2.setAsOutput(time);
280 278

  
281 279
      GLES30.glUniform1fv( mWeights1H, radius+1, weightsCache,offset);
282 280
      GLES30.glUniform1i( mRadius1H, radius);
283 281
      GLES30.glUniform1f( mDepth1H , 1.0f-surface.mNear);
284
      GLES30.glUniform1f( mScale1H , 1.0f);
285 282
      GLES30.glUniform1i( mColorTexture1H , 0 );
286 283
      for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h;
287 284
      GLES30.glUniform1fv( mOffsets1H ,radius+1, mOffsets,0);
......
291 288

  
292 289
      // vertical blur
293 290
      mBlur2Program.useProgram();
294
      surface.mBuffer2[DistortedOutputSurface.CUR_MIPMAP].setAsInput();
295
      surface.mBuffer1[DistortedOutputSurface.CUR_MIPMAP].setAsDepth();
291
      surface.mBuffer2.setAsInput();
292
      surface.mBuffer1.setAsDepth();
296 293
      surface.setAsOutput(time);
297 294

  
298 295
      GLES30.glUniform1fv( mWeights2H, radius+1, weightsCache,offset);
299 296
      GLES30.glUniform1i( mRadius2H, radius);
300 297
      GLES30.glUniform1f( mDepth2H , 1.0f-surface.mNear);
301
      GLES30.glUniform1f( mScale2H , 0.9f);
302 298
      GLES30.glUniform1i( mColorTexture2H , 0 );
303 299
      GLES30.glUniform1i( mDepthTexture2H , 1 );
304 300
      for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w;
src/main/res/raw/blur_vertex_shader.glsl
30 30
#endif
31 31

  
32 32
uniform float u_Depth;    // distance from the near plane to render plane, in clip coords
33
uniform float u_Scale;
34 33

  
35 34
//////////////////////////////////////////////////////////////////////////////////////////////
36 35

  
37 36
void main()
38 37
  {
39
  v_TexCoordinate = u_Scale*a_TexCoordinate;
38
  v_TexCoordinate = a_TexCoordinate;
40 39
  gl_Position     = vec4(2.0*a_Position,u_Depth,1.0);
41 40
  }

Also available in: Unified diff