title: OPEN GL - Change Vertex position from a texture color
body: <p>I have a plane, made from a NURB surface, with many vertex so it can create a curved surface depending on the vertex positions ( control points ).</p>
  
  <p>I bind the plane object with two different textures, one is the color texture to be displayed on the object, the other is an heightMap, ( black and white ), which has to alter de vertex <code>yy</code> positions of the plane depending of the color white in the correspondent texture coordinate.</p>
  
  <p>I know the problem is in my shaders. I do not have many experience with OPENGL.</p>
  
  <p>Here is the <code>shader.vert</code> that I use:</p>
  
  <pre><code>attribute vec3 aVertexPosition;
  attribute vec3 aVertexNormal;
  attribute vec2 aTextureCoord;
  
  uniform mat4 uMVMatrix;
  uniform mat4 uPMatrix;
  uniform mat4 uNMatrix;
  
  varying vec2 vTextureCoord;
  
  uniform sampler2D uSampler2;
  
  uniform float heightScale;
  
  void main() {
  
  //change texture coordinates
  vec2 texInver=vec2(1.0, -1.0);
  
  vTextureCoord = aTextureCoord*texInver;
  //--------------------------
  
  //change vertex position
  vec4 filter = texture2D(uSampler2, vTextureCoord);
  
  float offset = filter.r;
  
  vec3 inc = vec3(0.0, offset, 0.0);
  
  gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition + inc, 1.0);
  //----------------------
  }
  </code></pre>
  
  <p>Since the image is black and white, R = G = B. That is why I only check the <code>filter.r</code></p>
  
  <p>And my <code>shader.frag</code> is:</p>
  
  <pre><code>#ifdef GL_ES
  precision highp float;
  #endif
  
  varying vec2 vTextureCoord;
  
  uniform sampler2D uSampler;
  
  void main() {
  gl_FragColor = texture2D(uSampler, vTextureCoord);
  }
  </code></pre>
  
  <p>This is the height map ( <code>.jpg</code> ):</p>
  
  <p><a href="https://i.stack.imgur.com/2rHuB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2rHuB.jpg" alt="enter image description here"></a></p>
  
  <p>The result I get is a plane all incremented by 1 in the <code>yy</code> coordinate.</p>
  
  <p>The result I expect is SOME vertex of the plane to be incremented by a 0-1 value in the <code>yy</code> coordinate.</p>