I have a question related to shaders. I created a game in which I added a shader; it works fine in web mobile and Android, but in iOS it gives an error during rendering. How to solve this issue
version-3.8
error - Attribute a_uv0 is missing, add a dummy data for it.
17:39:35 [ERROR]: [ERROR] file /Applications/CocosCreator/Creator/3.8.0/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm: line 902
17:39:35 [ERROR]: Sampler binding at set 2 binding 2 is not bounded.
CCEffect %{
techniques:
- passes:
- vert: sprite-vs:vert
frag: sprite-fs:frag
depthStencilState:
depthTest: false
depthWrite: false
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendDstAlpha: one_minus_src_alpha
rasterizerState:
cullMode: none
properties:
u_dH: {
value: 0.0,
editor: {
tooltip: 'Hue',
range: [0.0, 360.0]
}
}
u_dS: {
value: 0.0,
editor: {
tooltip: 'Saturation',
range: [-1.0, 1.0]
}
}
u_dL: {
value: 0.0,
editor: {
tooltip: 'Lightness',
range: [-1.0, 1.0]
}
}
}%
CCProgram sprite-vs %{
precision highp float;
#include <builtin/uniforms/cc-global>
#if USE_LOCAL
#include <builtin/uniforms/cc-local>
#endif
in vec3 a_position;
in vec2 a_texCoord;
in vec4 a_color;
out vec4 v_color;
out vec2 v_uv0;
#if USE_TEXTURE
in vec2 a_uv0;
#endif
vec4 vert () {
vec4 pos = vec4(a_position, 1);
#if USE_LOCAL
pos = cc_matWorld * pos;
#endif
#if USE_PIXEL_ALIGNMENT
pos = cc_matView * pos;
pos.xyz = floor(pos.xyz);
pos = cc_matProj * pos;
#else
pos = cc_matViewProj * pos;
#endif
#if USE_TEXTURE
v_uv0 = a_uv0;
#endif
v_color = a_color;
v_uv0 = a_texCoord;
return pos;
}
}%
CCProgram sprite-fs %{
precision highp float;
#include <builtin/internal/embedded-alpha>
#include <builtin/internal/alpha-test>
in vec2 v_uv0;
in vec4 v_color;
#if USE_TEXTURE
#pragma builtin(local)
layout(set = 2, binding =11) uniform sampler2D cc_spriteTexture;
#endif
uniform ARGS {
float u_dH;
float u_dS;
float u_dL;
};
vec4 frag () {
vec4 texColor = CCSampleWithAlphaSeparated(cc_spriteTexture, v_uv0);
float r = texColor.r;
float g = texColor.g;
float b = texColor.b;
float a = texColor.a;
float h;
float s;
float l;
{
float maxVal = max(max(r, g), b);
float minVal = min(min(r, g), b);
if (maxVal == minVal) {
h = 0.0;
} else if (maxVal == r && g >= b) {
h = 60.0 * (g - b) / (maxVal - minVal) + 0.0;
} else if (maxVal == r && g < b) {
h = 60.0 * (g - b) / (maxVal - minVal) + 360.0;
} else if (maxVal == g) {
h = 60.0 * (b - r) / (maxVal - minVal) + 120.0;
} else if (maxVal == b) {
h = 60.0 * (r - g) / (maxVal - minVal) + 240.0;
}
l = 0.5 * (maxVal + minVal);
if (l == 0.0 || maxVal == minVal) {
s = 0.0;
} else if (0.0 <= l && l <= 0.5) {
s = (maxVal - minVal) / (2.0 * l);
} else if (l > 0.5) {
s = (maxVal - minVal) / (2.0 - 2.0 * l);
}
}
h = h + u_dH;
s = min(1.0, max(0.0, s + u_dS));
l = l;
vec4 finalColor;
{
float q;
if (l < 0.5) {
q = l * (1.0 + s);
} else if (l >= 0.5) {
q = l + s - l * s;
}
float p = 2.0 * l - q;
float hk = h / 360.0;
float t[3];
t[0] = hk + 1.0 / 3.0; t[1] = hk; t[2] = hk - 1.0 / 3.0;
for (int i = 0; i < 3; i++) {
if (t[i] < 0.0) t[i] += 1.0;
if (t[i] > 1.0) t[i] -= 1.0;
}
float c[3];
for (int i = 0; i < 3; i++) {
if (t[i] < 1.0 / 6.0) {
c[i] = p + ((q - p) * 6.0 * t[i]);
} else if (1.0 / 6.0 <= t[i] && t[i] < 0.5) {
c[i] = q;
} else if (0.5 <= t[i] && t[i] < 2.0 / 3.0) {
c[i] = p + ((q - p) * 6.0 * (2.0 / 3.0 - t[i]));
} else {
c[i] = p;
}
}
finalColor = vec4(c[0], c[1], c[2], a);
}
finalColor += vec4(u_dL, u_dL, u_dL, 0.0);
return finalColor;
}
}%