Getting shader error

Hi there,
I’m getting a shader error in my scene, I’ve disabled my custom shader for water. Still I’m getting that error for some material. How to trace that material for which that error is coming?
Also I’m unable to reproduce that error, it is coming at random times.

captureconsole.ts:73 Failed to compile vertex shader:


1:	#version 300 es
2:	
3:	
4:	#define attribute in
5:	#define varying out
6:	#define texture2D texture
7:	#define GL2
8:	#define VERTEXSHADER
9:	varying vec3 vPositionW;
10:	varying vec2 vUv0;
11:	varying vec2 vUv1;
12:	attribute vec3 vertex_position;
13:	attribute vec3 vertex_normal;
14:	attribute vec4 vertex_tangent;
15:	attribute vec2 vertex_texCoord0;
16:	attribute vec2 vertex_texCoord1;
17:	attribute vec4 vertex_color;
18:	uniform mat4 matrix_viewProjection;
19:	uniform mat4 matrix_model;
20:	uniform mat3 matrix_normal;
21:	vec3 dPositionW;
22:	mat4 dModelMatrix;
23:	mat3 dNormalMatrix;
24:	#ifdef NINESLICED
25:	vec2 getUv0() {
26:		vec2 uv = vertex_position.xz;
27:		vec2 positiveUnitOffset = clamp(vertex_position.xz, vec2(0.0), vec2(1.0));
28:		vec2 negativeUnitOffset = clamp(-vertex_position.xz, vec2(0.0), vec2(1.0));
29:		uv += (-positiveUnitOffset * innerOffset.xy + negativeUnitOffset * innerOffset.zw) * vertex_texCoord0.xy;
30:		uv = uv * -0.5 + 0.5;
31:		uv = uv * atlasRect.zw + atlasRect.xy;
32:		vMask = vertex_texCoord0.xy;
33:		return uv;
34:	}
35:	#else
36:	vec2 getUv0() {
37:		return vertex_texCoord0;
38:	}
39:	#endif
40:	vec2 getUv1() {
41:		return vertex_texCoord1;
42:	}
43:	#ifdef PIXELSNAP
44:	uniform vec4 uScreenSize;
45:	#endif
46:	#ifdef MORPHING
47:	uniform vec4 morph_weights_a;
48:	uniform vec4 morph_weights_b;
49:	#endif
50:	#ifdef MORPHING_TEXTURE_BASED
51:	uniform vec4 morph_tex_params;
52:	vec2 getTextureMorphCoords() {
53:		float vertexId = morph_vertex_id;
54:		vec2 textureSize = morph_tex_params.xy;
55:		vec2 invTextureSize = morph_tex_params.zw;
56:		float morphGridV = floor(vertexId * invTextureSize.x);
57:		float morphGridU = vertexId - (morphGridV * textureSize.x);
58:		return (vec2(morphGridU, morphGridV) * invTextureSize) + (0.5 * invTextureSize);
59:	}
60:	#endif
61:	#ifdef MORPHING_TEXTURE_BASED_POSITION
62:	uniform highp sampler2D morphPositionTex;
63:	#endif
64:	mat4 getModelMatrix() {
65:		#ifdef DYNAMICBATCH
66:		return getBoneMatrix(vertex_boneIndices);
67:		#elif defined(SKIN)
68:		return matrix_model * getSkinMatrix(vertex_boneIndices, vertex_boneWeights);
69:		#elif defined(INSTANCING)
70:		return mat4(instance_line1, instance_line2, instance_line3, instance_line4);
71:		#else
72:		return matrix_model;
73:		#endif
74:	}
75:	vec4 getPosition() {
76:		dModelMatrix = getModelMatrix();
77:		vec3 localPos = vertex_position;
78:		#ifdef NINESLICED
79:		localPos.xz *= outerScale;
80:		vec2 positiveUnitOffset = clamp(vertex_position.xz, vec2(0.0), vec2(1.0));
81:		vec2 negativeUnitOffset = clamp(-vertex_position.xz, vec2(0.0), vec2(1.0));
82:		localPos.xz += (-positiveUnitOffset * innerOffset.xy + negativeUnitOffset * innerOffset.zw) * vertex_texCoord0.xy;
83:		vTiledUv = (localPos.xz - outerScale + innerOffset.xy) * -0.5 + 1.0;
84:		localPos.xz *= -0.5;
85:		localPos = localPos.xzy;
86:		#endif
87:		#ifdef MORPHING
88:		#ifdef MORPHING_POS03
89:		localPos.xyz += morph_weights_a[0] * morph_pos0;
90:		localPos.xyz += morph_weights_a[1] * morph_pos1;
91:		localPos.xyz += morph_weights_a[2] * morph_pos2;
92:		localPos.xyz += morph_weights_a[3] * morph_pos3;
93:		#endif
94:		#ifdef MORPHING_POS47
95:		localPos.xyz += morph_weights_b[0] * morph_pos4;
96:		localPos.xyz += morph_weights_b[1] * morph_pos5;
97:		localPos.xyz += morph_weights_b[2] * morph_pos6;
98:		localPos.xyz += morph_weights_b[3] * morph_pos7;
99:		#endif
100:		#endif
101:		#ifdef MORPHING_TEXTURE_BASED_POSITION
102:		vec2 morphUV = getTextureMorphCoords();
103:		vec3 morphPos = texture2D(morphPositionTex, morphUV).xyz;
104:		localPos += morphPos;
105:		#endif
106:		vec4 posW = dModelMatrix * vec4(localPos, 1.0);
107:		#ifdef SCREENSPACE
108:		posW.zw = vec2(0.0, 1.0);
109:		#endif
110:		dPositionW = posW.xyz;
111:		vec4 screenPos;
112:		#ifdef UV1LAYOUT
113:		screenPos = vec4(vertex_texCoord1.xy * 2.0 - 1.0, 0.5, 1);
114:		#else
115:		#ifdef SCREENSPACE
116:		screenPos = posW;
117:		#else
118:		screenPos = matrix_viewProjection * posW;
119:		#endif
120:		#ifdef PIXELSNAP
121:		screenPos.xy = (screenPos.xy * 0.5) + 0.5;
122:		screenPos.xy *= uScreenSize.xy;
123:		screenPos.xy = floor(screenPos.xy);
124:		screenPos.xy *= uScreenSize.zw;
125:		screenPos.xy = (screenPos.xy * 2.0) - 1.0;
126:		#endif
127:		#endif
128:		return screenPos;
129:	}
130:	vec3 getWorldPosition() {
131:		return dPositionW;
132:	}
133:	
134:	void main(void) {
135:		gl_Position = getPosition();
136:	   vPositionW    = getWorldPosition();
137:	   vec2 uv0 = getUv0();
138:	   vUv0 = uv0;
139:	   vec2 uv1 = getUv1();
140:	   vUv1 = uv1;
141:	
142:	}
(anonymous)	@	captureconsole.ts:73
(anonymous)	@	instrument.ts:129
i._isShaderCompiled	@	playcanvas.min.js?version=1.47.2:6

How do I solve this?
Thanks in Advance.
P.S: The error occurs only in Chrome and not in firefox.

Hi @yaswanth,

That’s quite strange, especially since it’s happening on random times.

That seems to be a common vertex shader generated for the standard material. Do you have many materials in your project?

Usually I would try to disable part of the hierarchy to locate the exact material triggering this. When an entity is disabled and the model won’t render, the material won’t compile on startup.

@Leonidas, Thanks for your reply.
Yes, we’ve many materials in our project.
OK, we shall try disabling parts of our hierarchy to get that material.

1 Like

@Leonidas, the webGL context is getting lost before that error occurs. Any thoughts on why this may occur?

Hmm, not sure what the cause for that would be.

@mvaligursky may know more, though I think he is away this week.

Would you be able to share the project or a publish link of the issue to look at?

Do you lock the device, or have some other app going full screen or something like this? These would be reasons for lost context.

1 Like