Project

General

Profile

« Previous | Next » 

Revision 46dc4091

Added by Leszek Koltunski 11 months ago

Fix a bug noticed by Rohan M.

View differences:

src/main/java/org/distorted/library/effect/EffectQuality.java
34 34
 */
35 35
public enum EffectQuality
36 36
  {
37
  HIGHEST  ( 0 ),   // has to start from 0
38
  HIGH     ( 1 ),
39
  MEDIUM   ( 2 ),
40
  LOW      ( 3 );
37
  HIGHEST  ( 0, 1.000f ),   // has to start from 0
38
  HIGH     ( 1, 0.500f ),
39
  MEDIUM   ( 2, 0.250f ),
40
  LOW      ( 3, 0.125f );
41 41

  
42 42
///////////////////////////////////////////////////////////////////////////////////////////////////
43
/**
44
 * Each next Quality level renders into 1/MULTIPLIER smaller buffers.
45
 */
46
  public static final float MULTIPLIER = 0.5f;
47 43
/**
48 44
 * Numof of possible qualities.
49 45
 */
50 46
  public static final int LENGTH = values().length;
51 47

  
52 48
  private final int level;
49
  private final float mipmap;
50

  
51
  private static final EffectQuality[] qualities;
52

  
53
  static
54
    {
55
    int i=0;
56
    qualities= new EffectQuality[LENGTH];
57
    for(EffectQuality q: EffectQuality.values()) qualities[i++] = q;
58
    }
53 59

  
54 60
///////////////////////////////////////////////////////////////////////////////////////////////////
55 61

  
56
  EffectQuality(int level)
62
  EffectQuality(int level, float mipmap)
57 63
    {
58 64
    this.level = level;
65
    this.mipmap= mipmap;
59 66
    }
60 67

  
61 68
///////////////////////////////////////////////////////////////////////////////////////////////////
......
68 75
    {
69 76
    return level;
70 77
    }
78

  
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80
/**
81
 * Only for use by the library itself.
82
 *
83
 * @y.exclude
84
 */
85
  public static float getMipmap(int quality)
86
    {
87
    return qualities[quality].mipmap;
88
    }
71 89
  }
72 90

  
src/main/java/org/distorted/library/effect/PostprocessEffect.java
227 227
      {
228 228
      job = mJobs.remove(0);
229 229

  
230
      switch(job.type)
230
      if( job.type==MIPMAP )
231 231
        {
232
        case MIPMAP: int level = job.level;
233
                     mQualityLevel = level;
234
                     mQualityScale = 1.0f;
235
                     for(int j=0; j<level; j++) mQualityScale*= EffectQuality.MULTIPLIER;
236
                     break;
232
        int level = job.level;
233
        mQualityLevel = level;
234
        mQualityScale = EffectQuality.getMipmap(level);
235
        break;
237 236
        }
238 237
      }
239 238
    }
src/main/java/org/distorted/library/main/InternalOutputSurface.java
179 179
    final int   CLEAR_S = 0;
180 180

  
181 181
    final int queueSize = DistortedLibrary.getQueueSize();
182
    float mipmap=1.0f;
183

  
184
    for (int j=0; j<quality; j++) mipmap *= EffectQuality.MULTIPLIER;
182
    float mipmap= EffectQuality.getMipmap(quality);
185 183

  
186 184
    mBuffer[quality] = new DistortedFramebuffer(queueSize,2,BOTH_DEPTH_STENCIL,TYPE_SYST, STORAGE_COMMON, (int)(width*mipmap), (int)(height*mipmap) );
187 185
    mBuffer[quality].mMipmap = mipmap;

Also available in: Unified diff