Project

General

Profile

« Previous | Next » 

Revision 667a1ad9

Added by Leszek Koltunski over 7 years ago

improve Postprocessing; new icon; minor things.

View differences:

src/main/res/raw/post_fragment_shader.glsl
22 22
varying vec2 v_TexCoordinate;
23 23
uniform sampler2D u_Texture;
24 24
uniform vec2 u_objD;
25
uniform int pNumEffects;                   // total number of postprocessing effects
25
uniform int pNumEffects;                 // total number of postprocessing effects
26 26

  
27 27
#if NUM_POSTPROCESS>0
28
uniform int pType[NUM_POSTPROCESS];        // their types.
29
uniform vec4 pUniforms[2*NUM_POSTPROCESS]; // i-th effect is 2 consecutive vec4's: [2*i], [2*i+1].
28
uniform int pType[NUM_POSTPROCESS];      // their types.
29
uniform vec4 pUniforms[NUM_POSTPROCESS]; // i-th effect is 1 vec4: [i].
30 30

  
31 31
//////////////////////////////////////////////////////////////////////////////////////////////
32 32
// BLUR EFFECT
33 33

  
34
void blur(out vec4 pixel)
34
void blur(out vec4 pixel,float radius)
35 35
  {
36 36
  pixel = vec4(0.0);
37 37

  
38 38
  float blurSizeH = 1.0 / u_objD.x;
39 39
  float blurSizeV = 1.0 / u_objD.y;
40
  float denom     = 1.0 / ((2.0*radius+1.0)*(2.0*radius+1.0));
40 41

  
41
  for (float x = -4.0; x <= 4.0; x+=1.0)
42
    for (float y = -4.0; y <= 4.0; y+=1.0)
42
  for (float x = -radius; x <= radius; x+=1.0)
43
    for (float y = -radius; y <= radius; y+=1.0)
43 44
      {
44
      pixel += texture2D( u_Texture, vec2(v_TexCoordinate.x + x * blurSizeH, v_TexCoordinate.y + y * blurSizeV) ) / 81.0;
45
      pixel += texture2D( u_Texture, vec2(v_TexCoordinate.x + x*blurSizeH, v_TexCoordinate.y + y*blurSizeV) ) *denom;
45 46
      }
46 47
  }
47 48

  
......
56 57
#if NUM_POSTPROCESS>0
57 58
  for(int i=0; i<pNumEffects; i++)
58 59
    {
59
    if( pType[i]==BLUR ) blur(pixel);
60
    if( pType[i]==BLUR ) blur(pixel,pUniforms[i].x);
60 61
    }
61 62
#endif
62 63

  

Also available in: Unified diff