使用以下着色器代码,我可以在glControl中显示纹理。我可以使用用户选择的值垂直移动它吗?例如:如果用户选择0.8,我想将其从下到上垂直移动0.8。
public 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;
uniform float userselectedShiftVal;
void main ()
{
vec4 color = texture2D (sTexture_2,vec2(vTexCoord.x,vTexCoord.y));
gl_FragColor = color;
}");
GL.CompileShader(fragShader);
}