Hello to the forum!
I do have a little issue with a ‘thinInstancing’ shader and safari. The ‘thinInstancing’ shader works fine in all other browsers, but unfortunately not in safari (not even in safari 14.0). Hence my question if this is a known issue and what would be ways to work around it. Following I attached the shader and the safari errors. The main problem is that ‘gl_InstanceID’ is an undeclared identifier. Why is undeclared in safari and not in all the other browsers. Thank you for any advice…
// VERTEX SHADER
precision highp float;
attribute vec3 position;
attribute vec4 world0;
attribute vec4 world1;
attribute vec4 world2;
attribute vec4 world3;
uniform mat4 world;
uniform mat4 viewProjection;
uniform float u_instanceSize;
uniform float u_noiseDirection;
uniform float u_Time;
uniform float u_waveSpeed;
uniform float u_waveLength;
uniform float u_waveHeight;
uniform float u_waveAmplitude;
varying float v_sinWave;
float u_PI = 3.14;
void main() {
#ifdef INSTANCES
mat4 instanceWorldMatrix1 = mat4(world0, world1, world2, world3);
#ifdef THIN_INSTANCES
instanceWorldMatrix1 = world * instanceWorldMatrix1;
#endif
float instanceID1 = float(gl_InstanceID);
#else
mat4 instanceWorldMatrix1 = world;
float instanceID1 = 0.0;
#endif
vec3 instancePos = vec3(instanceID1);
float direction = u_PI * u_noiseDirection;
vec4 instanceOrientation = vec4(instancePos.x * sin(direction), instancePos.y, instancePos.z * cos(direction), 0.0);
float sinWave = sin((instanceOrientation.x - u_Time * u_waveSpeed) / u_waveLength) * u_waveHeight + u_waveAmplitude;
vec4 instanceScaleVector = vec4(u_instanceSize);
vec4 instanceScale0 = world0 * instanceScaleVector;
vec4 instanceScale1 = world1 * instanceScaleVector;
vec4 instanceScale2 = world2 * instanceScaleVector;
#ifdef INSTANCES
mat4 instanceWorldMatrix2 = mat4(instanceScale0, instanceScale1, instanceScale2, world3);
#ifdef THIN_INSTANCES
instanceWorldMatrix2 = world * instanceWorldMatrix2;
#endif
float instanceID0 = float(gl_InstanceID);
#else
mat4 instanceWorldMatrix2 = world;
float instanceID0 = 0.0;
#endif
gl_Position = viewProjection * instanceWorldMatrix2 * vec4(position, 1.0);
v_sinWave = sinWave;
}
// FRAGMENT SHADER
precision highp float;
uniform float u_instanceSize;
uniform float u_noiseDirection;
uniform float u_Time;
uniform float u_waveSpeed;
uniform float u_waveLength;
uniform float u_waveHeight;
uniform float u_waveAmplitude;
varying float v_sinWave;
//#include<helperFunctions>
float u_PI = 3.14;
void main() {
vec3 rgb = vec3(v_sinWave, 0.0, 0.0);
//vec3 rgb = vec3(1.0,0.0,0.0);
gl_FragColor = vec4(rgb, 1.0);
#ifdef CONVERTTOLINEAR0
gl_FragColor = toLinearSpace(gl_FragColor);
#endif
#ifdef CONVERTTOGAMMA0
gl_FragColor = toGammaSpace(gl_FragColor);
#endif
}