I have made an effect to apply the vertical gradient on node but I am getting the following error:
W/renderer (1056): Can not find vertex attribute: a_texCoord
This is the code for the effect file used:
CCEffect %{
properties:
texture: { value: white, editor: { type: texture } } # Texture property
alphaThreshold: { value: 0.5 }
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
depthStencilState:
depthTest: true
depthWrite: true
}%
CCProgram vs %{
precision mediump float;
// Uniform block for matrix uniforms
uniform MatBlock {
mat4 cc_matViewProj; // Matrix uniform
};
// Attributes for vertex position and texture coordinates
attribute vec3 a_position;
attribute vec2 a_texCoord; // Ensure this matches your model's vertex attributes
// Varying to pass texture coordinates to the fragment shader
varying vec2 v_texCoord;
void main() {
gl_Position = cc_matViewProj * vec4(a_position, 1.0);
v_texCoord = a_texCoord; // Pass the texture coordinates
}
}%
CCProgram fs %{
precision mediump float;
// Uniform block for color
uniform ColorBlock {
vec4 color; // Non-sampler uniform for color
};
// Sampler uniform for texture
uniform sampler2D texture;
// Varying to receive texture coordinates
varying vec2 v_texCoord;
void main() {
// Sample the texture
vec4 texColor = texture2D(texture, v_texCoord);
// Create a vertical gradient using the y-coordinate
float gradient = v_texCoord.y;
// Mix the sampled texture color with the gradient color
vec4 gradientColor = mix(vec4(1.0, 1.0, 1.0, 1.0), color, gradient);
// Output the final fragment color
gl_FragColor = texColor * gradientColor;
}
}%
Can someone help me with this issue? How can I solve it or if there is some better way to my problem.