title: OpenGL photoshop overlay blend mode
body: <p>Im trying to implement a particle system (using OpenGL 2.0 ES), where each particle is made up of a quad with a simple texture</p>
  
  <p><img src="https://i.stack.imgur.com/Tg6Ol.png" alt="the red pixels are transparent"></p>
  
  <p>the red pixels are transparent. Each particle will have a random alpha value from 50% to 100% </p>
  
  <p>Now the tricky part is i like each particle to have a blendmode much like Photoshop "overlay" i tried many different combinations with the glBlendFunc() but without luck.</p>
  
  <p>I dont understand how i could implement this in a fragment shader, since i need infomations about the current color of the fragment. So that i can calculate a new color based on the current and texture color.</p>
  
  <p>I also thought about using a frame buffer object, but i guess i would need to re-render my frame-buffer-object into a texture, for each particle since each particle every frame, since i need the calculated fragment color when particles overlap each other.</p>
  
  <p>Ive found math' and other infomations regrading the Overlay calculation but i have a hard time figuring out which direction i could go to implement this. </p>
  
  <ul>
  <li><a href="http://www.pegtop.net/delphi/articles/blendmodes/" rel="nofollow noreferrer">http://www.pegtop.net/delphi/articles/blendmodes/</a></li>
  <li><a href="https://stackoverflow.com/questions/818230/photoshop-blending-mode-to-opengl-es-without-shaders">Photoshop blending mode to OpenGL ES without shaders</a></li>
  </ul>
  
  <p>Im hoping to have a effect like this:</p>
  
  <p><img src="https://i.stack.imgur.com/V448A.png" alt="overlapping particles and how they blend together"></p>