Project

General

Profile

« Previous | Next » 

Revision 2fce34f4

Added by Leszek Koltunski almost 8 years ago

Major push towards simplifying DistortedObject's public API.
All Fragment effects are using the new API - the 'DataND' marker interfaces.

View differences:

src/main/res/raw/main_fragment_shader.glsl
21 21
  
22 22
uniform sampler2D u_Texture;            // The input texture.
23 23
    
24
varying vec3 v_Position;		// Interpolated position for this fragment.
24
varying vec3 v_Position;                // Interpolated position for this fragment.
25 25
varying vec4 v_Color;                   // This is the color from the vertex shader interpolated across the triangle per fragment.
26 26
varying vec3 v_Normal;                  // Interpolated normal for this fragment.
27 27
varying vec2 v_TexCoordinate;           // Interpolated texture coordinate per fragment.
......
30 30

  
31 31
#if NUM_FRAGMENT>0
32 32
uniform int fType[NUM_FRAGMENT];        // their types.
33
uniform vec3 fUniforms[3*NUM_FRAGMENT]; // i-th effect is 3 consecutive vec3's: [3*i], [3*i+1], [3*i+2]. first 4 floats are the Interpolated values,
34
                                        // next 5 describe the Region, i.e. area over which the effect is active.
35
                                        // Important note: here the Region is written in a different order than in the Vertex shader.
36
 
33
uniform vec4 fUniforms[2*NUM_FRAGMENT]; // i-th effect is 2 consecutive vec4's: [2*i], [2*i+1]. First vec4 is the Interpolated values,
34
                                        // next describes the Region, i.e. area over which the effect is active.
35

  
37 36
const vec3 LUMI = vec3( 0.2125, 0.7154, 0.0721 );                                        
38 37
 
39 38
//////////////////////////////////////////////////////////////////////////////////////////////
......
51 50

  
52 51
void chroma(float degree, int effect, inout vec4 color)
53 52
  {
54
  color.rgb = mix(color.rgb, vec3(fUniforms[effect].yz,fUniforms[effect+1].x), degree*fUniforms[effect].x); 
53
  color.rgb = mix(color.rgb, fUniforms[effect].yzw, degree*fUniforms[effect].x);
55 54
  }
56 55

  
57 56
//////////////////////////////////////////////////////////////////////////////////////////////
......
101 100
#if NUM_FRAGMENT>0  
102 101
  for(int i=0; i<fNumEffects; i++)
103 102
    {
104
    diff = (v_Position.xy - fUniforms[3*i+2].yz)/fUniforms[3*i+1].yz;
103
    diff = (v_Position.xy - fUniforms[2*i+1].xy)/fUniforms[2*i+1].zw;
105 104
    pointDegree = max(0.0,1.0-dot(diff,diff));
106 105
  
107
    //switch(fType[i])
106
    //switch(fType[i])  // future version of GLSL
108 107
    //  {
109
    //  case MACROBLOCK        : macroblock(sign(pointDegree),3*i,tex); break;
110
    //  case CHROMA            : chroma    (sign(pointDegree),3*i,col); break;
111
    //  case SMOOTH_CHROMA     : chroma    (     pointDegree ,3*i,col); break;
112
    //  case ALPHA             : alpha     (sign(pointDegree),3*i,col); break;
113
    //  case SMOOTH_ALPHA      : alpha     (     pointDegree ,3*i,col); break;
114
    //  case BRIGHTNESS        : brightness(sign(pointDegree),3*i,col); break;
115
    //  case SMOOTH_BRIGHTNESS : brightness(     pointDegree ,3*i,col); break;
116
    //  case CONTRAST          : contrast  (sign(pointDegree),3*i,col); break;
117
    //  case SMOOTH_CONTRAST   : contrast  (     pointDegree ,3*i,col); break;
118
    //  case SATURATION        : saturation(sign(pointDegree),3*i,col); break;
119
    //  case SMOOTH_SATURATION : saturation(     pointDegree ,3*i,col); break;
108
    //  case MACROBLOCK        : macroblock(sign(pointDegree),2*i,tex); break;
109
    //  case CHROMA            : chroma    (sign(pointDegree),2*i,col); break;
110
    //  case SMOOTH_CHROMA     : chroma    (     pointDegree ,2*i,col); break;
111
    //  case ALPHA             : alpha     (sign(pointDegree),2*i,col); break;
112
    //  case SMOOTH_ALPHA      : alpha     (     pointDegree ,2*i,col); break;
113
    //  case BRIGHTNESS        : brightness(sign(pointDegree),2*i,col); break;
114
    //  case SMOOTH_BRIGHTNESS : brightness(     pointDegree ,2*i,col); break;
115
    //  case CONTRAST          : contrast  (sign(pointDegree),2*i,col); break;
116
    //  case SMOOTH_CONTRAST   : contrast  (     pointDegree ,2*i,col); break;
117
    //  case SATURATION        : saturation(sign(pointDegree),2*i,col); break;
118
    //  case SMOOTH_SATURATION : saturation(     pointDegree ,2*i,col); break;
120 119
    //  }
121 120
    
122
         if( fType[i]==MACROBLOCK        ) macroblock(sign(pointDegree),3*i,tex);
123
    else if( fType[i]==CHROMA            ) chroma    (sign(pointDegree),3*i,col);
124
    else if( fType[i]==SMOOTH_CHROMA     ) chroma    (     pointDegree ,3*i,col);
125
    else if( fType[i]==ALPHA             ) alpha     (sign(pointDegree),3*i,col);
126
    else if( fType[i]==SMOOTH_ALPHA      ) alpha     (     pointDegree ,3*i,col);
127
    else if( fType[i]==BRIGHTNESS        ) brightness(sign(pointDegree),3*i,col);
128
    else if( fType[i]==SMOOTH_BRIGHTNESS ) brightness(     pointDegree ,3*i,col);
129
    else if( fType[i]==CONTRAST          ) contrast  (sign(pointDegree),3*i,col);
130
    else if( fType[i]==SMOOTH_CONTRAST   ) contrast  (     pointDegree ,3*i,col);
131
    else if( fType[i]==SATURATION        ) saturation(sign(pointDegree),3*i,col);
132
    else if( fType[i]==SMOOTH_SATURATION ) saturation(     pointDegree ,3*i,col);
121
         if( fType[i]==MACROBLOCK        ) macroblock(sign(pointDegree),2*i,tex);
122
    else if( fType[i]==CHROMA            ) chroma    (sign(pointDegree),2*i,col);
123
    else if( fType[i]==SMOOTH_CHROMA     ) chroma    (     pointDegree ,2*i,col);
124
    else if( fType[i]==ALPHA             ) alpha     (sign(pointDegree),2*i,col);
125
    else if( fType[i]==SMOOTH_ALPHA      ) alpha     (     pointDegree ,2*i,col);
126
    else if( fType[i]==BRIGHTNESS        ) brightness(sign(pointDegree),2*i,col);
127
    else if( fType[i]==SMOOTH_BRIGHTNESS ) brightness(     pointDegree ,2*i,col);
128
    else if( fType[i]==CONTRAST          ) contrast  (sign(pointDegree),2*i,col);
129
    else if( fType[i]==SMOOTH_CONTRAST   ) contrast  (     pointDegree ,2*i,col);
130
    else if( fType[i]==SATURATION        ) saturation(sign(pointDegree),2*i,col);
131
    else if( fType[i]==SMOOTH_SATURATION ) saturation(     pointDegree ,2*i,col);
133 132
    }
134 133
#endif
135 134
 

Also available in: Unified diff