发现纹理的特定强度点 - OpenTK

Found particular intensity points of texture - OpenTK

借助这个 我可以改变整个纹理的强度。现在我想检测纹理上强度大于 0.7 的所有点。我怎样才能做到这一点?

private void CreateShaders()
{
    /***********Vert Shader********************/
    vertShader = GL.CreateShader(ShaderType.VertexShader);
    GL.ShaderSource(vertShader, @"
        attribute vec3 a_position;
        varying vec2 vTexCoord;
        void main() {
            vTexCoord = (a_position.xy + 1) / 2;
            gl_Position = vec4(a_position,1);
        }");
    GL.CompileShader(vertShader);

    /***********Frag Shader ****************/
    fragShader = GL.CreateShader(ShaderType.FragmentShader);
    GL.ShaderSource(fragShader, @"
        precision highp float;
        uniform sampler2D sTexture;
        varying vec2 vTexCoord;
        const float Epsilon = 1e-10;

        //RGBtoHSV
        //HSVtoRGB

        void main ()
        {
            vec4  color = texture2D (sTexture, vTexCoord);
            float u_saturate=0.7;
            vec3 col_hsv = RGBtoHSV(color.rgb);
            col_hsv.z *= (u_saturate * 2.0);
            vec3 col_rgb = HSVtoRGB(col_hsv.rgb);
            gl_FragColor = vec4(col_rgb.rgb, color.a);
        }");
    GL.CompileShader(fragShader);
}

将强度与阈值进行比较,并根据强度使用不同的颜色:

gl_FragColor = intensity > 0.7 ? colorH : vec4(col_rgb.rgb, color.a);  

片段着色器 main 可能如下所示:

void main ()
{
    vec4  color = texture2D (sTexture, vTexCoord);
    float u_saturate=0.7;

    vec3  col_hsv = RGBtoHSV(color.rgb);
    float intensity = col_hsv.z;

    col_hsv.z *= (u_saturate * 2.0);
    vec3 col_rgb = HSVtoRGB(col_hsv.rgb);   

    vec4 colorH = vec4(0.0, 0.0, 0.0, 1.0);
    gl_FragColor = intensity > 0.7 ? colorH : vec4(col_rgb.rgb, color.a);
}