Project

General

Profile

« Previous | Next » 

Revision ff8ad0a7

Added by Leszek Koltunski almost 8 years ago

Fix for Bug #16: When rotated at an angle, surfaces get increasingly transparent.

This also fixes the saturation, chroma, alpha + contrast effects, while completely breaking macroblocks :)

View differences:

src/main/res/raw/main_fragment_shader.glsl
92 92
void main()                    		
93 93
  {  
94 94
  vec2 tex = v_TexCoordinate;
95
  vec4 col = vec4(1.0,1.0,1.0,1.0);
95
  vec4 col = texture2D(u_Texture, tex);
96 96

  
97 97
#if NUM_FRAGMENT>0
98 98
  vec2 diff;
......
116 116
    else if( fType[i]==SMOOTH_SATURATION ) saturation(     pointDegree ,2*i,col);
117 117
    }
118 118
#endif
119
 
120
  gl_FragColor = (col * 0.5 * (v_Normal.z+1.0) * texture2D(u_Texture, tex));
119

  
120
  gl_FragColor = vec4(col.rgb * 0.5 * (v_Normal.z+1.0), col.a);
121 121
  }
src/main/res/raw/main_vertex_shader.glsl
87 87
// Otherwise, let X be the point where the halfline SP meets the region circle - return |PX|/||SX|,
88 88
// aka the 'degree' of point P.
89 89
//
90
// We solve the the triangle OPX.
90
// We solve the triangle OPX.
91 91
// We know the lengths |PO|, |OX| and the angle OPX, because cos(OPX) = cos(180-OPS) = -cos(OPS) = -PS*PO/(|PS|*|PO|)
92 92
// then from the law of cosines PX^2 + PO^2 - 2*PX*PO*cos(OPX) = OX^2 so PX = -a + sqrt(a^2 + OX^2 - PO^2)
93 93
// where a = PS*PO/|PS| but we are really looking for d = |PX|/(|PX|+|PS|) = 1/(1+ (|PS|/|PX|) ) and
......
319 319
// This effect rotates the current vertex V by vInterpolated.x radians clockwise around the circle dilated 
320 320
// by (1-d) around the center of the effect S.
321 321

  
322
void swirl(in int effect, inout vec4 P)
322
void swirl(in int effect, inout vec4 v)
323 323
  {
324 324
  vec2 S  = vUniforms[effect+2].yz;
325
  vec2 PS = S-P.xy;
325
  vec2 PS = S-v.xy;
326 326
  vec3 SO = vUniforms[effect+1];
327 327
  float d1_circle = degree_region(SO,PS);
328 328
  float d1_bitmap = degree_bitmap(S,PS);
......
332 332
  vec3 SG = (1.0-d1_circle)*SO;                                // coordinates of the dilated circle P is going to get rotated around
333 333
  float d2 = max(0.0,degree(SG,S,PS2));                        // make it a max(0,deg) because when S=left edge of the bitmap, otherwise
334 334
                                                               // some points end up with d2<0 and they disappear off view.
335
  P.xy += min(d1_circle,d1_bitmap)*(PS - PS2/(1.0-d2));        // if d2=1 (i.e P=S) we should have P unchanged. How to do it?
335
  v.xy += min(d1_circle,d1_bitmap)*(PS - PS2/(1.0-d2));        // if d2=1 (i.e P=S) we should have P unchanged. How to do it?
336 336
  }
337 337

  
338 338
#endif

Also available in: Unified diff