actarian / vscode-glsl-canvas

Live WebGL preview of GLSL shaders
MIT License
335 stars 25 forks source link

using a_texcoord causes error #62

Open SET001 opened 3 years ago

SET001 commented 3 years ago

in this simple example:

#ifdef GL_ES
precision highp float;
#endif

uniform vec2 u_resolution;
uniform float u_time;
uniform sampler2D u_texture_1;
varying vec2 a_texcoord;

void main(){
  // float a=length(a_texcoord);
  gl_FragColor=texture2D(u_texture_1,vec2(.0,.0));
}

as soon as I uncomment the first line of the main, I'm getting this error:

Load error: "TypeError: Cannot read property 'replace' of undefined" sasdsddasasdasdasdddsaasd

loganbenjamin commented 3 years ago

I had the same issue, the variable name you are looking for is v_texcoord

#ifdef GL_ES
precision highp float;
#endif

uniform sampler2D u_texture_0;
varying vec2 v_texcoord;

void main(){
    gl_FragColor=texture2D(u_texture_0,v_texcoord);
}
bencresty commented 2 years ago

I had the same issue, the variable name you are looking for is v_texcoord

I can confirm. Using v_texcoord (instead of a_texcoord) inside the fragment shader works fine. a_texcoord is probably only available in the vertex shader and passed through to v_texcoord there to be available in the fragment shader.