title: Using compute shader to return whether texture has certain colour
body: <p>I'm writing a Compute Shader (in the unity environment, which uses DirectX11 DirectCompute) which I need to do a very simple task: check whether any pixel in the image has green == 1 and blue > 0.5. (For clarity - the green channel is a 2d "light" and the blue channel is that lights "trail" - I want to detect whenever the light crosses back over its trail.)</p>
  
  <p>I'm as far as displaying the overlap (shown in white) for debugging purposes, but I have no idea how to do something as simple as return a value indicating whether the texture actually contains an overlap. My confusion stems from how threads work. I have a float buffer with room for a single float - I simply need a 1 or 0.</p>
  
  <p>For clarification the following two images show a "before" and "after" - all I need is a single "true" value telling me that some white exists in the second image.</p>
  
  <p><a href="https://i.stack.imgur.com/CModf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CModf.png" alt="The original image"></a>
  <a href="https://i.stack.imgur.com/NGRyL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NGRyL.png" alt="The &quot;overlap&quot;"></a></p>
  
  <p>The compute shader is as follows:</p>
  
  <pre><code>#pragma kernel CSMain
  
  Texture2D&lt;float4&gt; InputTexture;
  RWTexture2D&lt;float4&gt; OutputTexture;
  RWStructuredBuffer&lt;float&gt; FloatBuffer;
  
  [numthreads(8,8,1)]
  void CSMain(uint3 id : SV_DispatchThreadID)
  {
      // need to detect any region where g == 1 and blue &gt; 0.5
  
      float green = InputTexture[id.xy].g;
      float blue = round(InputTexture[id.xy].b);
  
      float overlap = round((green + blue) / 2.0);
  
      OutputTexture[id.xy] = float4(overlap, overlap, overlap, 1);
  
      // answer here?? Note that the output texture is only for debugging purposes
      FloatBuffer[0] = ??
  }
  </code></pre>