Strange shader Error


#1

Hello
I stumbled upon this shader error (chrome console):

playcanvas-latest.min.js:40 ERROR:   Failed to compile fragment shader:

1:	precision highp float;
2:	#ifdef GL2
3:	precision highp sampler2DShadow;
4:	#endif
5:	vec3 fixSeams(vec3 vec, float mipmapIndex) {
6:	    float scale = 1.0 - exp2(mipmapIndex) / 128.0;
7:	    float M = max(max(abs(vec.x), abs(vec.y)), abs(vec.z));
8:	    if (abs(vec.x) != M) vec.x *= scale;
9:	    if (abs(vec.y) != M) vec.y *= scale;
10:	    if (abs(vec.z) != M) vec.z *= scale;
11:	    return vec;
12:	}
13:	vec3 fixSeams(vec3 vec) {
14:	    float scale = 1.0 - 1.0 / 128.0;
15:	    float M = max(max(abs(vec.x), abs(vec.y)), abs(vec.z));
16:	    if (abs(vec.x) != M) vec.x *= scale;
17:	    if (abs(vec.y) != M) vec.y *= scale;
18:	    if (abs(vec.z) != M) vec.z *= scale;
19:	    return vec;
20:	}
21:	vec3 fixSeamsStatic(vec3 vec, float invRecMipSize) {
22:	    float scale = invRecMipSize;
23:	    float M = max(max(abs(vec.x), abs(vec.y)), abs(vec.z));
24:	    if (abs(vec.x) != M) vec.x *= scale;
25:	    if (abs(vec.y) != M) vec.y *= scale;
26:	    if (abs(vec.z) != M) vec.z *= scale;
27:	    return vec;
28:	}
29:	vec3 processEnvironment(vec3 color) {
30:	    return color;
31:	}
32:	vec4 texture2DSRGB(sampler2D tex, vec2 uv) {
33:	    return texture2D(tex, uv);
34:	}
35:	vec4 texture2DSRGB(sampler2D tex, vec2 uv, float bias) {
36:	    return texture2D(tex, uv, bias);
37:	}
38:	vec4 textureCubeSRGB(samplerCube tex, vec3 uvw) {
39:	    return textureCube(tex, uvw);
40:	}
41:	vec3 gammaCorrectOutput(vec3 color) {
42:	    return color;
43:	}
44:	vec3 gammaCorrectInput(vec3 color) {
45:	    return color;
46:	}
47:	float gammaCorrectInput(float color) {
48:	    return color;
49:	}
50:	vec4 gammaCorrectInput(vec4 color) {
51:	    return color;
52:	}
53:	uniform float exposure;
54:	vec3 toneMap(vec3 color) {
55:	    return color * exposure;
56:	}
57:	vec3 decodeRGBM(vec4 rgbm) {
58:	    vec3 color = (8.0 * rgbm.a) * rgbm.rgb;
59:	    return color * color;
60:	}
61:	vec3 texture2DRGBM(sampler2D tex, vec2 uv) {
62:	    return decodeRGBM(texture2D(tex, uv));
63:	}
64:	vec3 textureCubeRGBM(samplerCube tex, vec3 uvw) {
65:	    return decodeRGBM(textureCube(tex, uvw));
66:	}
67:	varying vec3 vViewDir;
68:	uniform samplerCube texture_cubeMap;
69:	void main(void) {
70:	    vec3 color = processEnvironment(textureCubeSRGB(texture_cubeMap, fixSeamsStatic(vViewDir, NaN)).rgb);
71:	    color = toneMap(color);
72:	    color = gammaCorrectOutput(color);
73:	    gl_FragColor = vec4(color, 1.0);
74:	}
75:	

ERROR: 0:70: 'NaN' : undeclared identifier

does anyone know what may be possible causes?


#2

The NaN on this line is not a variable that has been declared


#3

Hello @yaustar, thanks for the reply.

I was able to discover the problem: it happens when app.scene.skyboxMip is set with a value of mipmap not present in the dds cubemap file.
I hope it can be useful to someone.