title: How to determine if point lies inside shape?
body: <p>I need to determine if point lies inside shape. In case our shape is circle it's easy:</p>
  
  <pre><code>highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
  highp float dist = distance(center, textureCoordinateToUse);
  textureCoordinateToUse = textureCoordinate;
  if (dist &lt; radius) {
      ...
  }
  </code></pre>
  
  <p>But what if my shape is star, hexagon, spirale or etc? Does somebody know any fast way to do it? May I use images with alpha channels as shapes? How to do it?</p>
  
  <p><strong>UPDATE:</strong> I have just understand that the best option now is to pass another texture to shader. How can I do it? Now shader has 2 properties: <code>varying highp vec2 textureCoordinate;</code> and <code>uniform sampler2D inputImageTexture;</code>. And I want to pass another texture to check alpha channel of it inside shader code.</p>
  
  <p><strong>UPDATE 2:</strong> I have tried to load shape to shader (I think so). I'm using GPUImage framework, so I have set sampler2D with my shape to uniform and tried to check alpha channel there. Is it okay? On my iPhone 5s it's looks very well, but what about performance?</p>