Hi,
I have a default vertex shader where I’m trying to pass in an attribute of type float: (nightCol)
attribute float nightCol;
attribute vec4 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord0;
uniform mat4 u_projTrans;
varying float vNightCol;
varying vec4 vColor;
varying vec2 vTexCoord;
void main() {
vNightCol = nightCol;
vColor = a_color;
vTexCoord = a_texCoord0;
gl_Position = u_projTrans * a_position;
}
And a fragment shader:
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
uniform sampler2D u_texture;
varying vec4 vColor;
varying vec2 vTexCoord;
varying float vNightCol;
const vec3 grayScaleMultiplier = vec3(0.299, 0.587, 0.114);
void main() {
vec4 texColor = texture2D(u_texture, vTexCoord);
vec3 gray = vec3(dot(texColor.rgb, grayScaleMultiplier));
gl_FragColor = vec4(gray.r, gray.g, gray.b, texColor.a * vNightCol);
}
I set the attribute up as follows:
nightShader.begin();
nightShader.setAttributef("nightCol", nightCol,0,0,0);
nightShader.end();
Exception I get: java.lang.IllegalArgumentException: no uniform with name ‘u_projTrans’ in shader
It is as though it isn’t finding nightCol which I thought would be passed through from the vertex shader to the pixel shader?
Logging the error after checking compilation fails on the shader I get:
Shader: The fragment shader uses varying vNightCol, but previous shader does not write to it.
Any help is appreciated.
Thanks