# Shader code for show selected part of image - OpenTk

**URL:** <https://discourse.processing.org/t/shader-code-for-show-selected-part-of-image-opentk/12316>\
**Category:** Coding Questions\
**Created:** [June 26, 2019, 6:09pm UTC](https://discourse.processing.org/t/shader-code-for-show-selected-part-of-image-opentk/12316 "2019-06-26T18:09:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NSDS](https://avatars.discourse-cdn.com/v4/letter/n/b38774/32.png) [@NSDS](https://discourse.processing.org/u/NSDS)\
**Post date:** [June 26, 2019, 6:09pm UTC](https://discourse.processing.org/t/shader-code-for-show-selected-part-of-image-opentk/12316/1 "2019-06-26T18:09:22Z")

</div>

I want to show second half portion of an image in my glcontrol, in a condition that only 0.7 to 0. 9 of second half is want to see in glControl. For that I have done like below. But it shows portion of first half of image too. Please help to correct the shader code.

```auto
 public void CreateShaders()
{
    / ***********Vert Shader******************** /
    vertShader = GL.CreateShader(ShaderType.VertexShader);
    GL.ShaderSource(vertShader, @"attribute vec3 a_position;
                                varying vec2 vTexCoordIn; 

                                void main() {
                       vTexCoordIn=( 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 vTexCoordIn;
void main ()
{
vec2 vTexCoord=vec2(vTexCoordIn.x,vTexCoordIn.y);
float rightsliderStartval=0.7;//0.5 to 1.0
float rightsliderEndval=0.9;//1.0 to 0.5
float rightsliderDelta=rightsliderEndval-rightsliderStartval;

vec4 color= texture2D(sTexture, vec2((0.5+vTexCoord.x)-(rightsliderStartval-0.5)-(1.0-rightsliderEndval), vTexCoord.y));
gl_FragColor = color;

 }");
    GL.CompileShader(fragShader);
}

```
