title: Texture lookup inside FBO simulation shader
body: <p>I'm trying to make FBO-particle system by calculating positions in separate pass. <br>Using code from this post now <a href="http://barradeau.com/blog/?p=621" rel="nofollow noreferrer">http://barradeau.com/blog/?p=621</a>.
  I render sphere of particles, without any movement:</p>
  
  <p><a href="https://i.imgur.com/stiqtcc.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/stiqtcc.png" alt=""></a></p>
  
  <p>The only thing i'm adding so far is a texture in <strong>simulation</strong> fragment shader:</p>
  
  <pre><code>void main() {
      vec3 pos = texture2D( texture, vUv ).xyz;
      //THIS LINE, pos is approx in -200..200 range
      float map = texture2D(texture1, abs(pos.xy/200.)).r;
      ...
      // save map value in ping-pong texture as alpha
      gl_FragColor = vec4( pos, map );
  </code></pre>
  
  <p><code>texture1</code> is:  half black half white.</p>
  
  <p>Then in <strong>render</strong> vertex shader i read this map parameter:</p>
  
  <pre><code>map = texture2D( positions, position.xy ).a;
  </code></pre>
  
  <p>and use it in <strong>render</strong> fragment shader to see the color:</p>
  
  <pre><code>vec3 finalColor = mix(vec3(1.,0.,0.),vec3(0.,1.,0.),map);
  gl_FragColor = vec4( finalColor, .2 );
  </code></pre>
  
  <p>So what i hope to see is: (made by setting same texture in <strong>render</strong> shaders)</p>
  
  <p><a href="https://i.imgur.com/t053ZcA.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/t053ZcA.jpg" alt=""></a></p>
  
  <p>But what i really see is: (by setting texture in <strong>simulation</strong> shaders)</p>
  
  <p><a href="https://i.imgur.com/M4Q0unb.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/M4Q0unb.jpg" alt=""></a></p>
  
  <p>Colors are mixed up, though mostly you can see more red ones where they should be, but there are a lot of green particles in between.<br>
  Also tried to make my own demo with simplified texture and same idea and i got this:</p>
  
  <p><a href="https://i.imgur.com/6UEi6cS.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/6UEi6cS.png" alt=""></a></p>
  
  <p>Also mixed up, but you can still guess image.
  Same error.<br>
  I think i am missing something obvious. But i was struggling with this a couple of days now, not able to find a mistake by myself.</p>
  
  <p>Would be very grateful for someone to point me in the right direction. Thank you in advance!</p>
  
  <p>Demo with error: <a href="http://cssing.org.ua/examples/fbo-error/" rel="nofollow noreferrer">http://cssing.org.ua/examples/fbo-error/</a><br>
  Full code i'm referring: <a href="https://github.com/akella/fbo-test" rel="nofollow noreferrer">https://github.com/akella/fbo-test</a></p>