Project

General

Profile

« Previous | Next » 

Revision 7ad20cce

Added by Leszek Koltunski over 7 years ago

Debugging Glow.

View differences:

src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java
191 191
    mProgram2.useProgram();
192 192
    outBuffer.bindForOutput(0);
193 193
    outBuffer.setAsInput(1);
194

  
194
/*
195
GLES30.glColorMask(true,true,true,true);
196
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f);
197
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);
198
*/
195 199
    GLES30.glUniform1f ( mProgram2.mUniform[0] , near);
196 200
    GLES30.glUniform1i ( mProgram2.mUniform[1] , 0 );
197 201
    GLES30.glUniform1fv( mProgram2.mUniform[2] , radius+1, mOffsets,0);
......
241 245
      "uniform int u_Radius;              \n"+
242 246
      "uniform vec4 u_Color;              \n"+
243 247

  
244
      "void main()                                                                                             \n"+
245
      "  {                                                                                                     \n"+
246
      "  float alpha= texture(u_ColorTexture,v_TexCoord).a * u_Weights[0];                                     \n"+
247
      "  for (int i=1; i<=u_Radius; i+=1)                                                                      \n"+
248
      "    {                                                                                                   \n"+
249
      "    alpha += ( texture(u_ColorTexture,vec2(v_TexCoord.x+u_Offsets[i],v_TexCoord.y)).a +                 \n"+
250
      "               texture(u_ColorTexture,vec2(v_TexCoord.x-u_Offsets[i],v_TexCoord.y)).a ) * u_Weights[i]; \n"+
251
      "    }                                                                                                   \n"+
252
      "  fragColor = vec4(u_Color.rgb,alpha);                                                                  \n"+
248
      "void main()                                                                                           \n"+
249
      "  {                                                                                                   \n"+
250
      "  vec4 pixel = texture(u_ColorTexture,v_TexCoord) * u_Weights[0];                                     \n"+
251
      "  for (int i=1; i<=u_Radius; i+=1)                                                                    \n"+
252
      "    {                                                                                                 \n"+
253
      "    pixel += ( texture(u_ColorTexture,vec2(v_TexCoord.x+u_Offsets[i],v_TexCoord.y)) +                 \n"+
254
      "               texture(u_ColorTexture,vec2(v_TexCoord.x-u_Offsets[i],v_TexCoord.y)) ) * u_Weights[i]; \n"+
255
      "    }                                                                                                 \n"+
256
      "  fragColor = vec4( 0.5*(pixel.rgb+u_Color.rgb), sign(pixel.a)*u_Color.a);                            \n"+
253 257
      "  }";
254 258

  
255 259
    final String glowFragment2 =
......
265 269
      "uniform int u_Radius;              \n"+
266 270
      "uniform vec4 u_Color;              \n"+
267 271

  
268
      "void main()                                                                                             \n"+
269
      "  {                                                                                                     \n"+
270
      "  float alpha= texture(u_ColorTexture,v_TexCoord).a * u_Weights[0];                                     \n"+
271
      "  for (int i=1; i<=u_Radius; i+=1)                                                                      \n"+
272
      "    {                                                                                                   \n"+
273
      "    alpha += ( texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y+u_Offsets[i])).a +                 \n"+
274
      "               texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y-u_Offsets[i])).a ) * u_Weights[i]; \n"+
275
      "    }                                                                                                   \n"+
276
      "  fragColor = vec4(u_Color.rgb,alpha);                                                                  \n"+
272
      "void main()                                                                                           \n"+
273
      "  {                                                                                                   \n"+
274
      "  vec4 pixel = texture(u_ColorTexture,v_TexCoord) * u_Weights[0];                                     \n"+
275
      "  for (int i=1; i<=u_Radius; i+=1)                                                                    \n"+
276
      "    {                                                                                                 \n"+
277
      "    pixel += ( texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y+u_Offsets[i])) +                 \n"+
278
      "               texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y-u_Offsets[i])) ) * u_Weights[i]; \n"+
279
      "    }                                                                                                 \n"+
280
      "  fragColor = vec4( 0.5*(pixel.rgb+u_Color.rgb), sign(pixel.a)*u_Color.a);                            \n"+
277 281
      "  }";
278 282

  
279
    mIndex1 = PostprocessEffect.register("BLUR1", glowVertex,glowFragment1);
280
    mIndex2 = PostprocessEffect.register("BLUR2", glowVertex,glowFragment2);
283
    mIndex1 = PostprocessEffect.register("GLOW1", glowVertex,glowFragment1);
284
    mIndex2 = PostprocessEffect.register("GLOW2", glowVertex,glowFragment2);
281 285
    }
282 286

  
283 287
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/main/DistortedOutputSurface.java
184 184
      mBuffer[j] = new DistortedFramebuffer(2,BOTH_DEPTH_STENCIL,TYPE_SYST, (int)(mWidth*mipmap), (int)(mHeight*mipmap) );
185 185
      mBuffer[j].mMipmap = mipmap;
186 186
      mBuffer[j].mNear   = mNear;  // copy mNear as well (for blitting- see PostprocessEffectBlur.apply() )
187
      mBuffer[j].glClearColor(1.0f,1.0f,1.0f,0.0f);
187 188
      mipmap *= EffectQuality.MULTIPLIER;
188 189
      }
189 190

  
src/main/java/org/distorted/library/main/EffectQueueMatrix.java
96 96
    float ylen = projection.mHeight*(mMaxy-mMiny)/2;
97 97
    float scale = 1.0f + marginInPixels/( xlen>ylen ? ylen:xlen );
98 98

  
99
    //android.util.Log.d("scale", ""+marginInPixels+" scale= "+scale+" xlen="+xlen+" ylen="+ylen);
99
    android.util.Log.d("scale", ""+marginInPixels+" scale= "+scale+" xlen="+xlen+" ylen="+ylen+" meshW="+(2*halfX)+" meshY="+(2*halfY));
100 100

  
101 101
    Matrix.scaleM(mViewMatrix, 0, scale, scale, scale);
102 102
    }

Also available in: Unified diff