Project

General

Profile

« Previous | Next » 

Revision 93dca704

Added by Leszek Koltunski almost 8 years ago

Minor progress with Gaussian. Still need to cache the Weights and Offests tables.

View differences:

src/main/java/org/distorted/library/EffectQueuePostprocess.java
171 171

  
172 172
///////////////////////////////////////////////////////////////////////////////////////////////////
173 173

  
174
  private int computeKernel(int radius, float height)
174
  private int computeGaussianKernel(int radius)
175 175
    {
176 176
    if( radius>=MAX_BLUR ) radius = MAX_BLUR-1;
177 177

  
178
    // Box Blur size 'radius'
179
/*
180
    for(int i=0; i<=radius; i++)
181
      {
182
      mWeights[i] = 1.0f / (2.0f*radius+1.0f);
183
      mOffsets[i] = i*height;
184
      }
185
*/
186
    // Gaussian Blur size 'radius'
187

  
188 178
    float P = (float)NUM_GAUSSIAN / (radius>3 ? radius:3);
189 179
    float x = 0.0f;
190 180
    mWeights[0] = GAUSSIAN[0];
......
201 191

  
202 192
      mWeights[i] = (1-z)*GAUSSIAN[j] + z*GAUSSIAN[j+1];
203 193
      sum += 2*mWeights[i];
204
      mOffsets[i] = i*height;
205 194
      }
206 195

  
207 196
    for(int i=0; i<=radius; i++)
......
214 203

  
215 204
    for(int i=0; i<numloops; i++)
216 205
      {
217
      mOffsets[i+1] = mWeights[2*i+1]*mOffsets[2*i+1] + mWeights[2*i+2]*mOffsets[2*i+2];
206
      mOffsets[i+1] = mWeights[2*i+1]*(2*i+1) + mWeights[2*i+2]*(2*i+2);
218 207
      mWeights[i+1] = mWeights[2*i+1] + mWeights[2*i+2];
219 208
      mOffsets[i+1] /= mWeights[i+1];
220 209
      }
......
242 231
    {
243 232
    mBlurProgram.useProgram();
244 233

  
245
    int radius = computeKernel( (int)mUniforms[0], 1/h );
234
    int radius = computeGaussianKernel( (int)mUniforms[0] );
235

  
236
    float adjust = 1/h;
237
    for(int i=0; i<=radius; i++) mOffsets[i] *= adjust;
246 238

  
247 239
    GLES30.glUniform1fv( mWeightsH, radius+1, mWeights,0);
248 240
    GLES30.glUniform1i( mRadiusH, radius);
......
267 259
    df.setAsOutput();
268 260
    GLES30.glViewport(0, 0, df.mWidth, df.mHeight);
269 261

  
270
    float adjust = h/w;
262
    adjust = h/w;
271 263
    for(int i=0; i<=radius; i++) mOffsets[i] *= adjust;
272 264

  
273 265
    // vertical blur

Also available in: Unified diff