Project

General

Profile

« Previous | Next » 

Revision 62c869ad

Added by Leszek Koltunski over 3 years ago

Fix normals in case of MatrixEffectScale / Shear.
Fix displaying the normal vector.

View differences:

src/main/res/raw/main_vertex_shader.glsl
40 40
out vec2 v_TexCoordinate;            //
41 41

  
42 42
uniform mat4 u_MVPMatrix;            // the combined model/view/projection matrix.
43
uniform mat4 u_MVMatrix;             // the combined model/view matrix.
43
uniform mat4 u_MVMatrixP;            // the combined model/view matrix. (for points)
44
uniform mat4 u_MVMatrixV;            // the combined model/view matrix. (for vectors)
45
                                     // which need to work differently on points and vectors
44 46
uniform float u_Inflate;             // how much should we inflate (>0.0) or deflate (<0.0) the mesh.
47
uniform int u_TransformFeedback;     // are we doing the transform feedback now?
45 48

  
46 49
#if NUM_VERTEX>0
47 50
uniform int vNumEffects;             // total number of vertex effects
......
119 122
    effect+=3;
120 123
    }
121 124
#endif
122
   
123
  v_Position      = v;
124 125

  
125 126
#ifdef PREAPPLY
126
  v_endPosition   = n;
127
  v_Inflate       = inf;
127
  v_Position   = v;
128
  v_endPosition= n;
129
  v_Inflate    = inf;
128 130
#else
129
  v_endPosition   = v + 0.5*n;
131
  if( u_TransformFeedback == 1 )
132
    {
133
    vec4 tmp1 =  u_MVMatrixP * vec4(v,1.0);
134
    vec4 tmp2 =  normalize(u_MVMatrixV * vec4(n,0.0));
135

  
136
    v_Position    = vec3(tmp1);
137
    v_endPosition = vec3(tmp1+100.0*tmp2);
138
    }
130 139
#endif
131 140

  
132 141
  v_TexCoordinate = a_TexCoordinate;
133
  v_Normal        = normalize(vec3(u_MVMatrix*vec4(n,0.0)));
142
  v_Normal        = normalize(vec3(u_MVMatrixV*vec4(n,0.0)));
134 143
  gl_Position     = u_MVPMatrix*vec4(v,1.0);
135 144
  }                               

Also available in: Unified diff