I created a sample scene in react-native (v0.71.8) (+ r3f) and it worked perfectly file on android studio emulator. But when I compiled the app and ran it on a physical device, all the objects with a ShaderMaterial, didn’t show up.
Here are the shaders:
float rand(vec2 p){return fract(cos(dot(p,vec2(23.,2.)))*12345.);}
#define BLACK vec3(0.0, 0.0, 0.0)
uniform float uTime;
uniform sampler2D uPerlinTexture;
varying vec2 vUv;
uniform vec3 uBlobColor;
uniform float uSmokeSize;
uniform float isAngry;
uniform float opc;
uniform vec3 uSpeachDisplacement;
void main() {
// Scale and animate
vec2 smokeUv = vUv;
smokeUv.x *= 0.5;
smokeUv.y *= 0.3;
smokeUv.y -= uTime * 0.03;
// Smoke
vec4 smpl = texture(uPerlinTexture, smokeUv);
float smoke = smpl.r;
smoke *= uSmokeSize;
// Remap
smoke = smoothstep(0.4, 1.0, smoke);
// Edges
smoke *= smoothstep(0.0, 0.1, vUv.x);
smoke *= smoothstep(1.0, 0.9, vUv.x);
smoke *= smoothstep(0.0, 0.1, vUv.y);
smoke *= smoothstep(1.0, 0.4, vUv.y);
float dist = distance(vUv, vec2(0.5)); // Calculate distance from center
vec3 finalColor = mix(uBlobColor, uBlobColor* 2.0, dist);
vec3 oblivion = BLACK;
finalColor.rgb *= 2.0;
gl_FragColor = vec4(finalColor, (smoke*2.0) - opc);
}
uniform float uTime;
uniform sampler2D uPerlinTexture;
uniform float uSmokeSpeed;
uniform vec3 uSpeachDisplacement;
varying vec2 vUv;
vec2 rotate2D(vec2 value, float angle)
{
float s = sin(angle);
float c = cos(angle);
mat2 m = mat2(c, s, -s, c);
return m * value;
}
void main() {
vec3 newPosition = position;
vec4 perlinTxt = texture(uPerlinTexture, uv);
// Twist
float twistPerlin = texture(
uPerlinTexture,
vec2(0.5, uv.y * 0.2 - uTime * 0.005)
).r;
float angle = twistPerlin * 10.0;
newPosition.xz = rotate2D(newPosition.xz, angle);
// Wind
vec2 windOffset = vec2(
texture(uPerlinTexture, vec2(0.25, uTime * 0.01)).r - 0.5,
texture(uPerlinTexture, vec2(0.75, uTime * 0.01)).r - 0.5
);
windOffset *= pow(uv.y, 2.0) * 10.;
newPosition.y += abs(sin(uTime*(uSpeachDisplacement.x ))) * 0.025;
newPosition.z += abs(sin(uTime*(uSpeachDisplacement.x ))) * 0.025;
newPosition.x += abs(sin(uTime*(uSpeachDisplacement.x ))) * 0.025;
// Final position
gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
// Varyings
vUv = uv;
}```