WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Z level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Z level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Z level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Z level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_X level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_POSITIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Y level 0 is incurring lazy initialization.
WebGL warning: generateMipmap: Tex image TEXTURE_CUBE_MAP_NEGATIVE_Z level 0 is incurring lazy initialization.
WebGL warning: texSubImage: Texture has not been initialized prior to a partial upload, forcing the browser to clear it. This may be slow.
WebGL warning: texSubImage: Tex image TEXTURE_2D level 0 is incurring lazy initialization.
LoadScene MainScene
LoadScene MainScene
VertexShader in 'pipeline/planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag' compilation failed.
Shader source dump:, 1 #define CC_DEVICE_SUPPORT_FLOAT_TEXTURE 1 2 #define CC_ENABLE_CLUSTERED_LIGHT_CULLING 0 3 #define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS 256 4 #define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS 224 5 #define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT 0 6 #define CC_PLATFORM_ANDROID_AND_WEBGL 1 7 #define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0 8 #define CC_JOINT_UNIFORM_CAPACITY 72 9 #define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS 128 10 #define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS 60 11 #define USE_INSTANCING 0 12 #define USE_BATCHING 0 13 #define CC_USE_SKINNING 0 14 #define CC_USE_BAKED_ANIMATION 0 15 #define CC_USE_LIGHTMAP 0 16 #define CC_RECEIVE_SHADOW 0 17 #define CC_USE_MORPH 0 18 #define CC_MORPH_TARGET_COUNT 2 19 #define CC_MORPH_TARGET_HAS_POSITION 0 20 #define CC_MORPH_TARGET_HAS_NORMAL 0 21 #define CC_MORPH_TARGET_HAS_TANGENT 0 22 #define CC_MORPH_PRECOMPUTED 0 23 #define CC_USE_REAL_TIME_JOINT_TEXTURE 0 24 25 precision highp float; 26 #define QUATER_PI 0.78539816340 27 #define HALF_PI 1.57079632679 28 #define PI 3.14159265359 29 #define PI2 6.28318530718 30 #define PI4 12.5663706144 31 #define INV_QUATER_PI 1.27323954474 32 #define INV_HALF_PI 0.63661977237 33 #define INV_PI 0.31830988618 34 #define INV_PI2 0.15915494309 35 #define INV_PI4 0.07957747155 36 #define EPSILON 1e-6 37 #define EPSILON_LOWP 1e-4 38 #define LOG2 1.442695 39 #define EXP_VALUE 2.71828183f 40 #define FP_MAX 65504.0 41 #define FP_SCALE 0.0009765625 42 #define FP_SCALE_INV 1024.0 43 #define GRAY_VECTOR vec3(0.299, 0.587, 0.114) 44 highp float decode32 (highp vec4 rgba) { 45 rgba = rgba * 255.0; 46 highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0; 47 highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0; 48 highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0; 49 return Sign * exp2(Exponent - 23.0) * Mantissa; 50 } 51 struct StandardVertInput { 52 highp vec4 position; 53 vec3 normal; 54 vec4 tangent; 55 }; 56 in vec3 a_position; 57 in vec3 a_normal; 58 in vec2 a_texCoord; 59 in vec4 a_tangent; 60 #if CC_USE_SKINNING 61 in vec4 a_joints; 62 in vec4 a_weights; 63 #endif 64 #if USE_INSTANCING 65 #if CC_USE_BAKED_ANIMATION 66 in highp vec4 a_jointAnimInfo; 67 #endif 68 in vec4 a_matWorld0; 69 in vec4 a_matWorld1; 70 in vec4 a_matWorld2; 71 #if CC_USE_LIGHTMAP 72 in vec4 a_lightingMapUVParam; 73 #endif 74 #if CC_RECEIVE_SHADOW 75 in vec2 a_localShadowBias; 76 #endif 77 #elif USE_BATCHING 78 in float a_dyn_batch_id; 79 #endif 80 #if CC_USE_MORPH 81 in float a_vertexId; 82 int getVertexId() { 83 return int(a_vertexId); 84 } 85 #endif 86 #if CC_USE_MORPH 87 layout(std140) uniform CCMorph { 88 vec4 cc_displacementWeights[15]; 89 vec4 cc_displacementTextureInfo; 90 }; 91 #if CC_MORPH_TARGET_HAS_POSITION 92 uniform sampler2D cc_PositionDisplacements; 93 #endif 94 #if CC_MORPH_TARGET_HAS_NORMAL 95 uniform sampler2D cc_NormalDisplacements; 96 #endif 97 #if CC_MORPH_TARGET_HAS_TANGENT 98 uniform sampler2D cc_TangentDisplacements; 99 #endif 100 vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) { 101 float pixelIndexF = float(pixelIndex); 102 float x = mod(pixelIndexF, textureResolution.x); 103 float y = floor(pixelIndexF / textureResolution.x); 104 return vec2(x, y); 105 } 106 vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) { 107 return (vec2(location.x, location.y) + .5) / textureResolution; 108 } 109 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 110 vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) { 111 ivec2 texSize = textureSize(tex, 0); 112 return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0); 113 } 114 #else 115 vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) { 116 int pixelIndex = elementIndex * 4; 117 vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex); 118 vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy); 119 vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy); 120 vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy); 121 return vec4( 122 decode32(texture(tex, x)), 123 decode32(texture(tex, y)), 124 decode32(texture(tex, z)), 125 1.0 126 ); 127 } 128 #endif 129 float getDisplacementWeight(int index) { 130 int quot = index / 4; 131 int remainder = index - quot * 4; 132 if (remainder == 0) { 133 return cc_displacementWeights[quot].x; 134 } else if (remainder == 1) { 135 return cc_displacementWeights[quot].y; 136 } else if (remainder == 2) { 137 return cc_displacementWeights[quot].z; 138 } else { 139 return cc_displacementWeights[quot].w; 140 } 141 } 142 vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) { 143 #if CC_MORPH_PRECOMPUTED 144 return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb; 145 #else 146 vec3 result = vec3(0, 0, 0); 147 int nVertices = int(cc_displacementTextureInfo.z); 148 for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) { 149 result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget)); 150 } 151 return result; 152 #endif 153 } 154 #if CC_MORPH_TARGET_HAS_POSITION 155 vec3 getPositionDisplacement(int vertexId) { 156 return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId); 157 } 158 #endif 159 #if CC_MORPH_TARGET_HAS_NORMAL 160 vec3 getNormalDisplacement(int vertexId) { 161 return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId); 162 } 163 #endif 164 #if CC_MORPH_TARGET_HAS_TANGENT 165 vec3 getTangentDisplacement(int vertexId) { 166 return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId); 167 } 168 #endif 169 void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) { 170 int vertexId = getVertexId(); 171 #if CC_MORPH_TARGET_HAS_POSITION 172 position.xyz = position.xyz + getPositionDisplacement(vertexId); 173 #endif 174 #if CC_MORPH_TARGET_HAS_NORMAL 175 normal.xyz = normal.xyz + getNormalDisplacement(vertexId); 176 #endif 177 #if CC_MORPH_TARGET_HAS_TANGENT 178 tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId); 179 #endif 180 } 181 void applyMorph (inout vec4 position) { 182 #if CC_MORPH_TARGET_HAS_POSITION 183 position.xyz = position.xyz + getPositionDisplacement(getVertexId()); 184 #endif 185 } 186 #endif 187 #if CC_USE_SKINNING 188 #if CC_USE_BAKED_ANIMATION 189 layout(std140) uniform CCSkinningTexture { 190 highp vec4 cc_jointTextureInfo; 191 }; 192 layout(std140) uniform CCSkinningAnimation { 193 highp vec4 cc_jointAnimInfo; 194 }; 195 uniform highp sampler2D cc_jointTexture; 196 void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize) 197 { 198 #if USE_INSTANCING 199 highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z; 200 #else 201 highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z; 202 #endif 203 invSize = cc_jointTextureInfo.w; 204 highp float tempY = floor(temp * invSize); 205 x = floor(temp - tempY * cc_jointTextureInfo.x); 206 y = (tempY + 0.5) * invSize; 207 } 208 #else 209 #if CC_USE_REAL_TIME_JOINT_TEXTURE 210 uniform highp sampler2D cc_realtimeJoint; 211 #else 212 layout(std140) uniform CCSkinning { 213 highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3]; 214 }; 215 #endif 216 #endif 217 #if CC_USE_BAKED_ANIMATION 218 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 219 mat4 getJointMatrix (float i) { 220 highp float x, y, invSize; 221 CCGetJointTextureCoords(3.0, i, x, y, invSize); 222 vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y)); 223 vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y)); 224 vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y)); 225 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 226 } 227 #else 228 mat4 getJointMatrix (float i) { 229 highp float x, y, invSize; 230 CCGetJointTextureCoords(12.0, i, x, y, invSize); 231 vec4 v1 = vec4( 232 decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))), 233 decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))), 234 decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))), 235 decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y))) 236 ); 237 vec4 v2 = vec4( 238 decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))), 239 decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))), 240 decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))), 241 decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y))) 242 ); 243 vec4 v3 = vec4( 244 decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))), 245 decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))), 246 decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))), 247 decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y))) 248 ); 249 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 250 } 251 #endif 252 #else 253 #if CC_USE_REAL_TIME_JOINT_TEXTURE 254 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 255 mat4 getJointMatrix (float i) { 256 float x = i; 257 vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0)); 258 vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0)); 259 vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0)); 260 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 261 } 262 #else 263 mat4 getJointMatrix (float i) { 264 float x = 4.0 * i; 265 vec4 v1 = vec4( 266 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))), 267 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))), 268 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))), 269 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0))) 270 ); 271 vec4 v2 = vec4( 272 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))), 273 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))), 274 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))), 275 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0))) 276 ); 277 vec4 v3 = vec4( 278 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))), 279 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))), 280 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))), 281 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0))) 282 ); 283 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 284 } 285 #endif 286 #else 287 mat4 getJointMatrix (float i) { 288 int idx = int(i); 289 vec4 v1 = cc_joints[idx * 3]; 290 vec4 v2 = cc_joints[idx * 3 + 1]; 291 vec4 v3 = cc_joints[idx * 3 + 2]; 292 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 293 } 294 #endif 295 #endif 296 mat4 skinMatrix () { 297 vec4 joints = vec4(a_joints); 298 return getJointMatrix(joints.x) * a_weights.x 299 + getJointMatrix(joints.y) * a_weights.y 300 + getJointMatrix(joints.z) * a_weights.z 301 + getJointMatrix(joints.w) * a_weights.w; 302 } 303 void CCSkin (inout vec4 position) { 304 mat4 m = skinMatrix(); 305 position = m * position; 306 } 307 void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) { 308 mat4 m = skinMatrix(); 309 position = m * position; 310 normal = (m * vec4(normal, 0.0)).xyz; 311 tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz; 312 } 313 #endif 314 void CCVertInput(inout vec4 In) 315 { 316 In = vec4(a_position, 1.0); 317 #if CC_USE_MORPH 318 applyMorph(In); 319 #endif 320 #if CC_USE_SKINNING 321 CCSkin(In); 322 #endif 323 } 324 layout(std140) uniform CCGlobal { 325 highp vec4 cc_time; 326 mediump vec4 cc_screenSize; 327 mediump vec4 cc_nativeSize; 328 mediump vec4 cc_debug_view_mode; 329 mediump vec4 cc_debug_view_composite_pack_1; 330 mediump vec4 cc_debug_view_composite_pack_2; 331 mediump vec4 cc_debug_view_composite_pack_3; 332 }; 333 layout(std140) uniform CCCamera { 334 highp mat4 cc_matView; 335 highp mat4 cc_matViewInv; 336 highp mat4 cc_matProj; 337 highp mat4 cc_matProjInv; 338 highp mat4 cc_matViewProj; 339 highp mat4 cc_matViewProjInv; 340 highp vec4 cc_cameraPos; 341 mediump vec4 cc_surfaceTransform; 342 mediump vec4 cc_screenScale; 343 mediump vec4 cc_exposure; 344 mediump vec4 cc_mainLitDir; 345 mediump vec4 cc_mainLitColor; 346 mediump vec4 cc_ambientSky; 347 mediump vec4 cc_ambientGround; 348 mediump vec4 cc_fogColor; 349 mediump vec4 cc_fogBase; 350 mediump vec4 cc_fogAdd; 351 mediump vec4 cc_nearFar; 352 mediump vec4 cc_viewPort; 353 }; 354 #if !USE_INSTANCING 355 #if USE_BATCHING 356 layout(std140) uniform CCLocalBatched { 357 highp mat4 cc_matWorlds[10]; 358 }; 359 #else 360 layout(std140) uniform CCLocal { 361 highp mat4 cc_matWorld; 362 highp mat4 cc_matWorldIT; 363 highp vec4 cc_lightingMapUVParam; 364 highp vec4 cc_localShadowBias; 365 }; 366 #endif 367 #endif 368 void CCGetWorldMatrix(out mat4 matWorld) 369 { 370 #if USE_INSTANCING 371 matWorld = mat4( 372 vec4(a_matWorld0.xyz, 0.0), 373 vec4(a_matWorld1.xyz, 0.0), 374 vec4(a_matWorld2.xyz, 0.0), 375 vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0) 376 ); 377 #elif USE_BATCHING 378 matWorld = cc_matWorlds[int(a_dyn_batch_id)]; 379 #else 380 matWorld = cc_matWorld; 381 #endif 382 } 383 layout(std140) uniform CCShadow { 384 highp mat4 cc_matLightView; 385 highp mat4 cc_matLightViewProj; 386 highp vec4 cc_shadowInvProjDepthInfo; 387 highp vec4 cc_shadowProjDepthInfo; 388 highp vec4 cc_shadowProjInfo; 389 mediump vec4 cc_shadowNFLSInfo; 390 mediump vec4 cc_shadowWHPBInfo; 391 mediump vec4 cc_shadowLPNNInfo; 392 lowp vec4 cc_shadowColor; 393 mediump vec4 cc_planarNDInfo; 394 }; 395 out float v_dist; 396 vec4 vert () { 397 vec4 position; 398 CCVertInput(position); 399 mat4 matWorld; 400 CCGetWorldMatrix(matWorld); 401 vec3 P = (matWorld * position).xyz; 402 vec3 L = cc_mainLitDir.xyz; 403 vec3 N = cc_planarNDInfo.xyz; 404 float d = cc_planarNDInfo.w + 0.001; 405 float dist = (-d - dot(P, N)) / (dot(L, N) + 0.0001); 406 vec3 shadowPos = P + L * dist; 407 vec3 view = normalize(cc_cameraPos.xyz - shadowPos); 408 float viewLength = length(cc_cameraPos.xyz - shadowPos); 409 shadowPos += view * min(1.0, 0.005 * viewLength); 410 position = cc_matProj * cc_matView * vec4(shadowPos, 1.0); 411 v_dist = dist; 412 return position; 413 } 414 void main() { gl_Position = vert(); }
VertexShader in 'pipeline/planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag|CC_RECEIVE_SHADOW1' compilation failed.
Shader source dump:, 1 #define CC_DEVICE_SUPPORT_FLOAT_TEXTURE 1 2 #define CC_ENABLE_CLUSTERED_LIGHT_CULLING 0 3 #define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS 256 4 #define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS 224 5 #define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT 0 6 #define CC_PLATFORM_ANDROID_AND_WEBGL 1 7 #define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0 8 #define CC_JOINT_UNIFORM_CAPACITY 72 9 #define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS 128 10 #define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS 60 11 #define USE_INSTANCING 0 12 #define USE_BATCHING 0 13 #define CC_USE_SKINNING 0 14 #define CC_USE_BAKED_ANIMATION 0 15 #define CC_USE_LIGHTMAP 0 16 #define CC_RECEIVE_SHADOW 1 17 #define CC_USE_MORPH 0 18 #define CC_MORPH_TARGET_COUNT 2 19 #define CC_MORPH_TARGET_HAS_POSITION 0 20 #define CC_MORPH_TARGET_HAS_NORMAL 0 21 #define CC_MORPH_TARGET_HAS_TANGENT 0 22 #define CC_MORPH_PRECOMPUTED 0 23 #define CC_USE_REAL_TIME_JOINT_TEXTURE 0 24 25 precision highp float; 26 #define QUATER_PI 0.78539816340 27 #define HALF_PI 1.57079632679 28 #define PI 3.14159265359 29 #define PI2 6.28318530718 30 #define PI4 12.5663706144 31 #define INV_QUATER_PI 1.27323954474 32 #define INV_HALF_PI 0.63661977237 33 #define INV_PI 0.31830988618 34 #define INV_PI2 0.15915494309 35 #define INV_PI4 0.07957747155 36 #define EPSILON 1e-6 37 #define EPSILON_LOWP 1e-4 38 #define LOG2 1.442695 39 #define EXP_VALUE 2.71828183f 40 #define FP_MAX 65504.0 41 #define FP_SCALE 0.0009765625 42 #define FP_SCALE_INV 1024.0 43 #define GRAY_VECTOR vec3(0.299, 0.587, 0.114) 44 highp float decode32 (highp vec4 rgba) { 45 rgba = rgba * 255.0; 46 highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0; 47 highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0; 48 highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0; 49 return Sign * exp2(Exponent - 23.0) * Mantissa; 50 } 51 struct StandardVertInput { 52 highp vec4 position; 53 vec3 normal; 54 vec4 tangent; 55 }; 56 in vec3 a_position; 57 in vec3 a_normal; 58 in vec2 a_texCoord; 59 in vec4 a_tangent; 60 #if CC_USE_SKINNING 61 in vec4 a_joints; 62 in vec4 a_weights; 63 #endif 64 #if USE_INSTANCING 65 #if CC_USE_BAKED_ANIMATION 66 in highp vec4 a_jointAnimInfo; 67 #endif 68 in vec4 a_matWorld0; 69 in vec4 a_matWorld1; 70 in vec4 a_matWorld2; 71 #if CC_USE_LIGHTMAP 72 in vec4 a_lightingMapUVParam; 73 #endif 74 #if CC_RECEIVE_SHADOW 75 in vec2 a_localShadowBias; 76 #endif 77 #elif USE_BATCHING 78 in float a_dyn_batch_id; 79 #endif 80 #if CC_USE_MORPH 81 in float a_vertexId; 82 int getVertexId() { 83 return int(a_vertexId); 84 } 85 #endif 86 #if CC_USE_MORPH 87 layout(std140) uniform CCMorph { 88 vec4 cc_displacementWeights[15]; 89 vec4 cc_displacementTextureInfo; 90 }; 91 #if CC_MORPH_TARGET_HAS_POSITION 92 uniform sampler2D cc_PositionDisplacements; 93 #endif 94 #if CC_MORPH_TARGET_HAS_NORMAL 95 uniform sampler2D cc_NormalDisplacements; 96 #endif 97 #if CC_MORPH_TARGET_HAS_TANGENT 98 uniform sampler2D cc_TangentDisplacements; 99 #endif 100 vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) { 101 float pixelIndexF = float(pixelIndex); 102 float x = mod(pixelIndexF, textureResolution.x); 103 float y = floor(pixelIndexF / textureResolution.x); 104 return vec2(x, y); 105 } 106 vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) { 107 return (vec2(location.x, location.y) + .5) / textureResolution; 108 } 109 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 110 vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) { 111 ivec2 texSize = textureSize(tex, 0); 112 return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0); 113 } 114 #else 115 vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) { 116 int pixelIndex = elementIndex * 4; 117 vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex); 118 vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy); 119 vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy); 120 vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy); 121 return vec4( 122 decode32(texture(tex, x)), 123 decode32(texture(tex, y)), 124 decode32(texture(tex, z)), 125 1.0 126 ); 127 } 128 #endif 129 float getDisplacementWeight(int index) { 130 int quot = index / 4; 131 int remainder = index - quot * 4; 132 if (remainder == 0) { 133 return cc_displacementWeights[quot].x; 134 } else if (remainder == 1) { 135 return cc_displacementWeights[quot].y; 136 } else if (remainder == 2) { 137 return cc_displacementWeights[quot].z; 138 } else { 139 return cc_displacementWeights[quot].w; 140 } 141 } 142 vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) { 143 #if CC_MORPH_PRECOMPUTED 144 return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb; 145 #else 146 vec3 result = vec3(0, 0, 0); 147 int nVertices = int(cc_displacementTextureInfo.z); 148 for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) { 149 result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget)); 150 } 151 return result; 152 #endif 153 } 154 #if CC_MORPH_TARGET_HAS_POSITION 155 vec3 getPositionDisplacement(int vertexId) { 156 return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId); 157 } 158 #endif 159 #if CC_MORPH_TARGET_HAS_NORMAL 160 vec3 getNormalDisplacement(int vertexId) { 161 return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId); 162 } 163 #endif 164 #if CC_MORPH_TARGET_HAS_TANGENT 165 vec3 getTangentDisplacement(int vertexId) { 166 return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId); 167 } 168 #endif 169 void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) { 170 int vertexId = getVertexId(); 171 #if CC_MORPH_TARGET_HAS_POSITION 172 position.xyz = position.xyz + getPositionDisplacement(vertexId); 173 #endif 174 #if CC_MORPH_TARGET_HAS_NORMAL 175 normal.xyz = normal.xyz + getNormalDisplacement(vertexId); 176 #endif 177 #if CC_MORPH_TARGET_HAS_TANGENT 178 tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId); 179 #endif 180 } 181 void applyMorph (inout vec4 position) { 182 #if CC_MORPH_TARGET_HAS_POSITION 183 position.xyz = position.xyz + getPositionDisplacement(getVertexId()); 184 #endif 185 } 186 #endif 187 #if CC_USE_SKINNING 188 #if CC_USE_BAKED_ANIMATION 189 layout(std140) uniform CCSkinningTexture { 190 highp vec4 cc_jointTextureInfo; 191 }; 192 layout(std140) uniform CCSkinningAnimation { 193 highp vec4 cc_jointAnimInfo; 194 }; 195 uniform highp sampler2D cc_jointTexture; 196 void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize) 197 { 198 #if USE_INSTANCING 199 highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z; 200 #else 201 highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z; 202 #endif 203 invSize = cc_jointTextureInfo.w; 204 highp float tempY = floor(temp * invSize); 205 x = floor(temp - tempY * cc_jointTextureInfo.x); 206 y = (tempY + 0.5) * invSize; 207 } 208 #else 209 #if CC_USE_REAL_TIME_JOINT_TEXTURE 210 uniform highp sampler2D cc_realtimeJoint; 211 #else 212 layout(std140) uniform CCSkinning { 213 highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3]; 214 }; 215 #endif 216 #endif 217 #if CC_USE_BAKED_ANIMATION 218 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 219 mat4 getJointMatrix (float i) { 220 highp float x, y, invSize; 221 CCGetJointTextureCoords(3.0, i, x, y, invSize); 222 vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y)); 223 vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y)); 224 vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y)); 225 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 226 } 227 #else 228 mat4 getJointMatrix (float i) { 229 highp float x, y, invSize; 230 CCGetJointTextureCoords(12.0, i, x, y, invSize); 231 vec4 v1 = vec4( 232 decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))), 233 decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))), 234 decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))), 235 decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y))) 236 ); 237 vec4 v2 = vec4( 238 decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))), 239 decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))), 240 decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))), 241 decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y))) 242 ); 243 vec4 v3 = vec4( 244 decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))), 245 decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))), 246 decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))), 247 decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y))) 248 ); 249 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 250 } 251 #endif 252 #else 253 #if CC_USE_REAL_TIME_JOINT_TEXTURE 254 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 255 mat4 getJointMatrix (float i) { 256 float x = i; 257 vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0)); 258 vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0)); 259 vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0)); 260 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 261 } 262 #else 263 mat4 getJointMatrix (float i) { 264 float x = 4.0 * i; 265 vec4 v1 = vec4( 266 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))), 267 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))), 268 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))), 269 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0))) 270 ); 271 vec4 v2 = vec4( 272 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))), 273 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))), 274 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))), 275 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0))) 276 ); 277 vec4 v3 = vec4( 278 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))), 279 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))), 280 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))), 281 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0))) 282 ); 283 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 284 } 285 #endif 286 #else 287 mat4 getJointMatrix (float i) { 288 int idx = int(i); 289 vec4 v1 = cc_joints[idx * 3]; 290 vec4 v2 = cc_joints[idx * 3 + 1]; 291 vec4 v3 = cc_joints[idx * 3 + 2]; 292 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 293 } 294 #endif 295 #endif 296 mat4 skinMatrix () { 297 vec4 joints = vec4(a_joints); 298 return getJointMatrix(joints.x) * a_weights.x 299 + getJointMatrix(joints.y) * a_weights.y 300 + getJointMatrix(joints.z) * a_weights.z 301 + getJointMatrix(joints.w) * a_weights.w; 302 } 303 void CCSkin (inout vec4 position) { 304 mat4 m = skinMatrix(); 305 position = m * position; 306 } 307 void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) { 308 mat4 m = skinMatrix(); 309 position = m * position; 310 normal = (m * vec4(normal, 0.0)).xyz; 311 tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz; 312 } 313 #endif 314 void CCVertInput(inout vec4 In) 315 { 316 In = vec4(a_position, 1.0); 317 #if CC_USE_MORPH 318 applyMorph(In); 319 #endif 320 #if CC_USE_SKINNING 321 CCSkin(In); 322 #endif 323 } 324 layout(std140) uniform CCGlobal { 325 highp vec4 cc_time; 326 mediump vec4 cc_screenSize; 327 mediump vec4 cc_nativeSize; 328 mediump vec4 cc_debug_view_mode; 329 mediump vec4 cc_debug_view_composite_pack_1; 330 mediump vec4 cc_debug_view_composite_pack_2; 331 mediump vec4 cc_debug_view_composite_pack_3; 332 }; 333 layout(std140) uniform CCCamera { 334 highp mat4 cc_matView; 335 highp mat4 cc_matViewInv; 336 highp mat4 cc_matProj; 337 highp mat4 cc_matProjInv; 338 highp mat4 cc_matViewProj; 339 highp mat4 cc_matViewProjInv; 340 highp vec4 cc_cameraPos; 341 mediump vec4 cc_surfaceTransform; 342 mediump vec4 cc_screenScale; 343 mediump vec4 cc_exposure; 344 mediump vec4 cc_mainLitDir; 345 mediump vec4 cc_mainLitColor; 346 mediump vec4 cc_ambientSky; 347 mediump vec4 cc_ambientGround; 348 mediump vec4 cc_fogColor; 349 mediump vec4 cc_fogBase; 350 mediump vec4 cc_fogAdd; 351 mediump vec4 cc_nearFar; 352 mediump vec4 cc_viewPort; 353 }; 354 #if !USE_INSTANCING 355 #if USE_BATCHING 356 layout(std140) uniform CCLocalBatched { 357 highp mat4 cc_matWorlds[10]; 358 }; 359 #else 360 layout(std140) uniform CCLocal { 361 highp mat4 cc_matWorld; 362 highp mat4 cc_matWorldIT; 363 highp vec4 cc_lightingMapUVParam; 364 highp vec4 cc_localShadowBias; 365 }; 366 #endif 367 #endif 368 void CCGetWorldMatrix(out mat4 matWorld) 369 { 370 #if USE_INSTANCING 371 matWorld = mat4( 372 vec4(a_matWorld0.xyz, 0.0), 373 vec4(a_matWorld1.xyz, 0.0), 374 vec4(a_matWorld2.xyz, 0.0), 375 vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0) 376 ); 377 #elif USE_BATCHING 378 matWorld = cc_matWorlds[int(a_dyn_batch_id)]; 379 #else 380 matWorld = cc_matWorld; 381 #endif 382 } 383 layout(std140) uniform CCShadow { 384 highp mat4 cc_matLightView; 385 highp mat4 cc_matLightViewProj; 386 highp vec4 cc_shadowInvProjDepthInfo; 387 highp vec4 cc_shadowProjDepthInfo; 388 highp vec4 cc_shadowProjInfo; 389 mediump vec4 cc_shadowNFLSInfo; 390 mediump vec4 cc_shadowWHPBInfo; 391 mediump vec4 cc_shadowLPNNInfo; 392 lowp vec4 cc_shadowColor; 393 mediump vec4 cc_planarNDInfo; 394 }; 395 out float v_dist; 396 vec4 vert () { 397 vec4 position; 398 CCVertInput(position); 399 mat4 matWorld; 400 CCGetWorldMatrix(matWorld); 401 vec3 P = (matWorld * position).xyz; 402 vec3 L = cc_mainLitDir.xyz; 403 vec3 N = cc_planarNDInfo.xyz; 404 float d = cc_planarNDInfo.w + 0.001; 405 float dist = (-d - dot(P, N)) / (dot(L, N) + 0.0001); 406 vec3 shadowPos = P + L * dist; 407 vec3 view = normalize(cc_cameraPos.xyz - shadowPos); 408 float viewLength = length(cc_cameraPos.xyz - shadowPos); 409 shadowPos += view * min(1.0, 0.005 * viewLength); 410 position = cc_matProj * cc_matView * vec4(shadowPos, 1.0); 411 v_dist = dist; 412 return position; 413 } 414 void main() { gl_Position = vert(); }
VertexShader in 'pipeline/planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag|USE_INSTANCING1' compilation failed.
Shader source dump:, 1 #define CC_DEVICE_SUPPORT_FLOAT_TEXTURE 1 2 #define CC_ENABLE_CLUSTERED_LIGHT_CULLING 0 3 #define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS 256 4 #define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS 224 5 #define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT 0 6 #define CC_PLATFORM_ANDROID_AND_WEBGL 1 7 #define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0 8 #define CC_JOINT_UNIFORM_CAPACITY 72 9 #define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS 128 10 #define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS 60 11 #define USE_INSTANCING 1 12 #define USE_BATCHING 0 13 #define CC_USE_SKINNING 0 14 #define CC_USE_BAKED_ANIMATION 0 15 #define CC_USE_LIGHTMAP 0 16 #define CC_RECEIVE_SHADOW 0 17 #define CC_USE_MORPH 0 18 #define CC_MORPH_TARGET_COUNT 2 19 #define CC_MORPH_TARGET_HAS_POSITION 0 20 #define CC_MORPH_TARGET_HAS_NORMAL 0 21 #define CC_MORPH_TARGET_HAS_TANGENT 0 22 #define CC_MORPH_PRECOMPUTED 0 23 #define CC_USE_REAL_TIME_JOINT_TEXTURE 0 24 25 precision highp float; 26 #define QUATER_PI 0.78539816340 27 #define HALF_PI 1.57079632679 28 #define PI 3.14159265359 29 #define PI2 6.28318530718 30 #define PI4 12.5663706144 31 #define INV_QUATER_PI 1.27323954474 32 #define INV_HALF_PI 0.63661977237 33 #define INV_PI 0.31830988618 34 #define INV_PI2 0.15915494309 35 #define INV_PI4 0.07957747155 36 #define EPSILON 1e-6 37 #define EPSILON_LOWP 1e-4 38 #define LOG2 1.442695 39 #define EXP_VALUE 2.71828183f 40 #define FP_MAX 65504.0 41 #define FP_SCALE 0.0009765625 42 #define FP_SCALE_INV 1024.0 43 #define GRAY_VECTOR vec3(0.299, 0.587, 0.114) 44 highp float decode32 (highp vec4 rgba) { 45 rgba = rgba * 255.0; 46 highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0; 47 highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0; 48 highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0; 49 return Sign * exp2(Exponent - 23.0) * Mantissa; 50 } 51 struct StandardVertInput { 52 highp vec4 position; 53 vec3 normal; 54 vec4 tangent; 55 }; 56 in vec3 a_position; 57 in vec3 a_normal; 58 in vec2 a_texCoord; 59 in vec4 a_tangent; 60 #if CC_USE_SKINNING 61 in vec4 a_joints; 62 in vec4 a_weights; 63 #endif 64 #if USE_INSTANCING 65 #if CC_USE_BAKED_ANIMATION 66 in highp vec4 a_jointAnimInfo; 67 #endif 68 in vec4 a_matWorld0; 69 in vec4 a_matWorld1; 70 in vec4 a_matWorld2; 71 #if CC_USE_LIGHTMAP 72 in vec4 a_lightingMapUVParam; 73 #endif 74 #if CC_RECEIVE_SHADOW 75 in vec2 a_localShadowBias; 76 #endif 77 #elif USE_BATCHING 78 in float a_dyn_batch_id; 79 #endif 80 #if CC_USE_MORPH 81 in float a_vertexId; 82 int getVertexId() { 83 return int(a_vertexId); 84 } 85 #endif 86 #if CC_USE_MORPH 87 layout(std140) uniform CCMorph { 88 vec4 cc_displacementWeights[15]; 89 vec4 cc_displacementTextureInfo; 90 }; 91 #if CC_MORPH_TARGET_HAS_POSITION 92 uniform sampler2D cc_PositionDisplacements; 93 #endif 94 #if CC_MORPH_TARGET_HAS_NORMAL 95 uniform sampler2D cc_NormalDisplacements; 96 #endif 97 #if CC_MORPH_TARGET_HAS_TANGENT 98 uniform sampler2D cc_TangentDisplacements; 99 #endif 100 vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) { 101 float pixelIndexF = float(pixelIndex); 102 float x = mod(pixelIndexF, textureResolution.x); 103 float y = floor(pixelIndexF / textureResolution.x); 104 return vec2(x, y); 105 } 106 vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) { 107 return (vec2(location.x, location.y) + .5) / textureResolution; 108 } 109 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 110 vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) { 111 ivec2 texSize = textureSize(tex, 0); 112 return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0); 113 } 114 #else 115 vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) { 116 int pixelIndex = elementIndex * 4; 117 vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex); 118 vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy); 119 vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy); 120 vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy); 121 return vec4( 122 decode32(texture(tex, x)), 123 decode32(texture(tex, y)), 124 decode32(texture(tex, z)), 125 1.0 126 ); 127 } 128 #endif 129 float getDisplacementWeight(int index) { 130 int quot = index / 4; 131 int remainder = index - quot * 4; 132 if (remainder == 0) { 133 return cc_displacementWeights[quot].x; 134 } else if (remainder == 1) { 135 return cc_displacementWeights[quot].y; 136 } else if (remainder == 2) { 137 return cc_displacementWeights[quot].z; 138 } else { 139 return cc_displacementWeights[quot].w; 140 } 141 } 142 vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) { 143 #if CC_MORPH_PRECOMPUTED 144 return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb; 145 #else 146 vec3 result = vec3(0, 0, 0); 147 int nVertices = int(cc_displacementTextureInfo.z); 148 for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) { 149 result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget)); 150 } 151 return result; 152 #endif 153 } 154 #if CC_MORPH_TARGET_HAS_POSITION 155 vec3 getPositionDisplacement(int vertexId) { 156 return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId); 157 } 158 #endif 159 #if CC_MORPH_TARGET_HAS_NORMAL 160 vec3 getNormalDisplacement(int vertexId) { 161 return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId); 162 } 163 #endif 164 #if CC_MORPH_TARGET_HAS_TANGENT 165 vec3 getTangentDisplacement(int vertexId) { 166 return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId); 167 } 168 #endif 169 void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) { 170 int vertexId = getVertexId(); 171 #if CC_MORPH_TARGET_HAS_POSITION 172 position.xyz = position.xyz + getPositionDisplacement(vertexId); 173 #endif 174 #if CC_MORPH_TARGET_HAS_NORMAL 175 normal.xyz = normal.xyz + getNormalDisplacement(vertexId); 176 #endif 177 #if CC_MORPH_TARGET_HAS_TANGENT 178 tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId); 179 #endif 180 } 181 void applyMorph (inout vec4 position) { 182 #if CC_MORPH_TARGET_HAS_POSITION 183 position.xyz = position.xyz + getPositionDisplacement(getVertexId()); 184 #endif 185 } 186 #endif 187 #if CC_USE_SKINNING 188 #if CC_USE_BAKED_ANIMATION 189 layout(std140) uniform CCSkinningTexture { 190 highp vec4 cc_jointTextureInfo; 191 }; 192 layout(std140) uniform CCSkinningAnimation { 193 highp vec4 cc_jointAnimInfo; 194 }; 195 uniform highp sampler2D cc_jointTexture; 196 void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize) 197 { 198 #if USE_INSTANCING 199 highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z; 200 #else 201 highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z; 202 #endif 203 invSize = cc_jointTextureInfo.w; 204 highp float tempY = floor(temp * invSize); 205 x = floor(temp - tempY * cc_jointTextureInfo.x); 206 y = (tempY + 0.5) * invSize; 207 } 208 #else 209 #if CC_USE_REAL_TIME_JOINT_TEXTURE 210 uniform highp sampler2D cc_realtimeJoint; 211 #else 212 layout(std140) uniform CCSkinning { 213 highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3]; 214 }; 215 #endif 216 #endif 217 #if CC_USE_BAKED_ANIMATION 218 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 219 mat4 getJointMatrix (float i) { 220 highp float x, y, invSize; 221 CCGetJointTextureCoords(3.0, i, x, y, invSize); 222 vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y)); 223 vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y)); 224 vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y)); 225 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 226 } 227 #else 228 mat4 getJointMatrix (float i) { 229 highp float x, y, invSize; 230 CCGetJointTextureCoords(12.0, i, x, y, invSize); 231 vec4 v1 = vec4( 232 decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))), 233 decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))), 234 decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))), 235 decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y))) 236 ); 237 vec4 v2 = vec4( 238 decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))), 239 decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))), 240 decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))), 241 decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y))) 242 ); 243 vec4 v3 = vec4( 244 decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))), 245 decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))), 246 decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))), 247 decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y))) 248 ); 249 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 250 } 251 #endif 252 #else 253 #if CC_USE_REAL_TIME_JOINT_TEXTURE 254 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 255 mat4 getJointMatrix (float i) { 256 float x = i; 257 vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0)); 258 vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0)); 259 vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0)); 260 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 261 } 262 #else 263 mat4 getJointMatrix (float i) { 264 float x = 4.0 * i; 265 vec4 v1 = vec4( 266 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))), 267 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))), 268 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))), 269 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0))) 270 ); 271 vec4 v2 = vec4( 272 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))), 273 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))), 274 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))), 275 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0))) 276 ); 277 vec4 v3 = vec4( 278 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))), 279 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))), 280 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))), 281 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0))) 282 ); 283 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 284 } 285 #endif 286 #else 287 mat4 getJointMatrix (float i) { 288 int idx = int(i); 289 vec4 v1 = cc_joints[idx * 3]; 290 vec4 v2 = cc_joints[idx * 3 + 1]; 291 vec4 v3 = cc_joints[idx * 3 + 2]; 292 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 293 } 294 #endif 295 #endif 296 mat4 skinMatrix () { 297 vec4 joints = vec4(a_joints); 298 return getJointMatrix(joints.x) * a_weights.x 299 + getJointMatrix(joints.y) * a_weights.y 300 + getJointMatrix(joints.z) * a_weights.z 301 + getJointMatrix(joints.w) * a_weights.w; 302 } 303 void CCSkin (inout vec4 position) { 304 mat4 m = skinMatrix(); 305 position = m * position; 306 } 307 void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) { 308 mat4 m = skinMatrix(); 309 position = m * position; 310 normal = (m * vec4(normal, 0.0)).xyz; 311 tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz; 312 } 313 #endif 314 void CCVertInput(inout vec4 In) 315 { 316 In = vec4(a_position, 1.0); 317 #if CC_USE_MORPH 318 applyMorph(In); 319 #endif 320 #if CC_USE_SKINNING 321 CCSkin(In); 322 #endif 323 } 324 layout(std140) uniform CCGlobal { 325 highp vec4 cc_time; 326 mediump vec4 cc_screenSize; 327 mediump vec4 cc_nativeSize; 328 mediump vec4 cc_debug_view_mode; 329 mediump vec4 cc_debug_view_composite_pack_1; 330 mediump vec4 cc_debug_view_composite_pack_2; 331 mediump vec4 cc_debug_view_composite_pack_3; 332 }; 333 layout(std140) uniform CCCamera { 334 highp mat4 cc_matView; 335 highp mat4 cc_matViewInv; 336 highp mat4 cc_matProj; 337 highp mat4 cc_matProjInv; 338 highp mat4 cc_matViewProj; 339 highp mat4 cc_matViewProjInv; 340 highp vec4 cc_cameraPos; 341 mediump vec4 cc_surfaceTransform; 342 mediump vec4 cc_screenScale; 343 mediump vec4 cc_exposure; 344 mediump vec4 cc_mainLitDir; 345 mediump vec4 cc_mainLitColor; 346 mediump vec4 cc_ambientSky; 347 mediump vec4 cc_ambientGround; 348 mediump vec4 cc_fogColor; 349 mediump vec4 cc_fogBase; 350 mediump vec4 cc_fogAdd; 351 mediump vec4 cc_nearFar; 352 mediump vec4 cc_viewPort; 353 }; 354 #if !USE_INSTANCING 355 #if USE_BATCHING 356 layout(std140) uniform CCLocalBatched { 357 highp mat4 cc_matWorlds[10]; 358 }; 359 #else 360 layout(std140) uniform CCLocal { 361 highp mat4 cc_matWorld; 362 highp mat4 cc_matWorldIT; 363 highp vec4 cc_lightingMapUVParam; 364 highp vec4 cc_localShadowBias; 365 }; 366 #endif 367 #endif 368 void CCGetWorldMatrix(out mat4 matWorld) 369 { 370 #if USE_INSTANCING 371 matWorld = mat4( 372 vec4(a_matWorld0.xyz, 0.0), 373 vec4(a_matWorld1.xyz, 0.0), 374 vec4(a_matWorld2.xyz, 0.0), 375 vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0) 376 ); 377 #elif USE_BATCHING 378 matWorld = cc_matWorlds[int(a_dyn_batch_id)]; 379 #else 380 matWorld = cc_matWorld; 381 #endif 382 } 383 layout(std140) uniform CCShadow { 384 highp mat4 cc_matLightView; 385 highp mat4 cc_matLightViewProj; 386 highp vec4 cc_shadowInvProjDepthInfo; 387 highp vec4 cc_shadowProjDepthInfo; 388 highp vec4 cc_shadowProjInfo; 389 mediump vec4 cc_shadowNFLSInfo; 390 mediump vec4 cc_shadowWHPBInfo; 391 mediump vec4 cc_shadowLPNNInfo; 392 lowp vec4 cc_shadowColor; 393 mediump vec4 cc_planarNDInfo; 394 }; 395 out float v_dist; 396 vec4 vert () { 397 vec4 position; 398 CCVertInput(position); 399 mat4 matWorld; 400 CCGetWorldMatrix(matWorld); 401 vec3 P = (matWorld * position).xyz; 402 vec3 L = cc_mainLitDir.xyz; 403 vec3 N = cc_planarNDInfo.xyz; 404 float d = cc_planarNDInfo.w + 0.001; 405 float dist = (-d - dot(P, N)) / (dot(L, N) + 0.0001); 406 vec3 shadowPos = P + L * dist; 407 vec3 view = normalize(cc_cameraPos.xyz - shadowPos); 408 float viewLength = length(cc_cameraPos.xyz - shadowPos); 409 shadowPos += view * min(1.0, 0.005 * viewLength); 410 position = cc_matProj * cc_matView * vec4(shadowPos, 1.0); 411 v_dist = dist; 412 return position; 413 } 414 void main() { gl_Position = vert(); }
VertexShader in 'pipeline/planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag|USE_INSTANCING1|CC_RECEIVE_SHADOW1' compilation failed.
Shader source dump:, 1 #define CC_DEVICE_SUPPORT_FLOAT_TEXTURE 1 2 #define CC_ENABLE_CLUSTERED_LIGHT_CULLING 0 3 #define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS 256 4 #define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS 224 5 #define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT 0 6 #define CC_PLATFORM_ANDROID_AND_WEBGL 1 7 #define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0 8 #define CC_JOINT_UNIFORM_CAPACITY 72 9 #define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS 128 10 #define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS 60 11 #define USE_INSTANCING 1 12 #define USE_BATCHING 0 13 #define CC_USE_SKINNING 0 14 #define CC_USE_BAKED_ANIMATION 0 15 #define CC_USE_LIGHTMAP 0 16 #define CC_RECEIVE_SHADOW 1 17 #define CC_USE_MORPH 0 18 #define CC_MORPH_TARGET_COUNT 2 19 #define CC_MORPH_TARGET_HAS_POSITION 0 20 #define CC_MORPH_TARGET_HAS_NORMAL 0 21 #define CC_MORPH_TARGET_HAS_TANGENT 0 22 #define CC_MORPH_PRECOMPUTED 0 23 #define CC_USE_REAL_TIME_JOINT_TEXTURE 0 24 25 precision highp float; 26 #define QUATER_PI 0.78539816340 27 #define HALF_PI 1.57079632679 28 #define PI 3.14159265359 29 #define PI2 6.28318530718 30 #define PI4 12.5663706144 31 #define INV_QUATER_PI 1.27323954474 32 #define INV_HALF_PI 0.63661977237 33 #define INV_PI 0.31830988618 34 #define INV_PI2 0.15915494309 35 #define INV_PI4 0.07957747155 36 #define EPSILON 1e-6 37 #define EPSILON_LOWP 1e-4 38 #define LOG2 1.442695 39 #define EXP_VALUE 2.71828183f 40 #define FP_MAX 65504.0 41 #define FP_SCALE 0.0009765625 42 #define FP_SCALE_INV 1024.0 43 #define GRAY_VECTOR vec3(0.299, 0.587, 0.114) 44 highp float decode32 (highp vec4 rgba) { 45 rgba = rgba * 255.0; 46 highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0; 47 highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0; 48 highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0; 49 return Sign * exp2(Exponent - 23.0) * Mantissa; 50 } 51 struct StandardVertInput { 52 highp vec4 position; 53 vec3 normal; 54 vec4 tangent; 55 }; 56 in vec3 a_position; 57 in vec3 a_normal; 58 in vec2 a_texCoord; 59 in vec4 a_tangent; 60 #if CC_USE_SKINNING 61 in vec4 a_joints; 62 in vec4 a_weights; 63 #endif 64 #if USE_INSTANCING 65 #if CC_USE_BAKED_ANIMATION 66 in highp vec4 a_jointAnimInfo; 67 #endif 68 in vec4 a_matWorld0; 69 in vec4 a_matWorld1; 70 in vec4 a_matWorld2; 71 #if CC_USE_LIGHTMAP 72 in vec4 a_lightingMapUVParam; 73 #endif 74 #if CC_RECEIVE_SHADOW 75 in vec2 a_localShadowBias; 76 #endif 77 #elif USE_BATCHING 78 in float a_dyn_batch_id; 79 #endif 80 #if CC_USE_MORPH 81 in float a_vertexId; 82 int getVertexId() { 83 return int(a_vertexId); 84 } 85 #endif 86 #if CC_USE_MORPH 87 layout(std140) uniform CCMorph { 88 vec4 cc_displacementWeights[15]; 89 vec4 cc_displacementTextureInfo; 90 }; 91 #if CC_MORPH_TARGET_HAS_POSITION 92 uniform sampler2D cc_PositionDisplacements; 93 #endif 94 #if CC_MORPH_TARGET_HAS_NORMAL 95 uniform sampler2D cc_NormalDisplacements; 96 #endif 97 #if CC_MORPH_TARGET_HAS_TANGENT 98 uniform sampler2D cc_TangentDisplacements; 99 #endif 100 vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) { 101 float pixelIndexF = float(pixelIndex); 102 float x = mod(pixelIndexF, textureResolution.x); 103 float y = floor(pixelIndexF / textureResolution.x); 104 return vec2(x, y); 105 } 106 vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) { 107 return (vec2(location.x, location.y) + .5) / textureResolution; 108 } 109 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 110 vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) { 111 ivec2 texSize = textureSize(tex, 0); 112 return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0); 113 } 114 #else 115 vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) { 116 int pixelIndex = elementIndex * 4; 117 vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex); 118 vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy); 119 vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy); 120 vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy); 121 return vec4( 122 decode32(texture(tex, x)), 123 decode32(texture(tex, y)), 124 decode32(texture(tex, z)), 125 1.0 126 ); 127 } 128 #endif 129 float getDisplacementWeight(int index) { 130 int quot = index / 4; 131 int remainder = index - quot * 4; 132 if (remainder == 0) { 133 return cc_displacementWeights[quot].x; 134 } else if (remainder == 1) { 135 return cc_displacementWeights[quot].y; 136 } else if (remainder == 2) { 137 return cc_displacementWeights[quot].z; 138 } else { 139 return cc_displacementWeights[quot].w; 140 } 141 } 142 vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) { 143 #if CC_MORPH_PRECOMPUTED 144 return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb; 145 #else 146 vec3 result = vec3(0, 0, 0); 147 int nVertices = int(cc_displacementTextureInfo.z); 148 for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) { 149 result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget)); 150 } 151 return result; 152 #endif 153 } 154 #if CC_MORPH_TARGET_HAS_POSITION 155 vec3 getPositionDisplacement(int vertexId) { 156 return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId); 157 } 158 #endif 159 #if CC_MORPH_TARGET_HAS_NORMAL 160 vec3 getNormalDisplacement(int vertexId) { 161 return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId); 162 } 163 #endif 164 #if CC_MORPH_TARGET_HAS_TANGENT 165 vec3 getTangentDisplacement(int vertexId) { 166 return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId); 167 } 168 #endif 169 void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) { 170 int vertexId = getVertexId(); 171 #if CC_MORPH_TARGET_HAS_POSITION 172 position.xyz = position.xyz + getPositionDisplacement(vertexId); 173 #endif 174 #if CC_MORPH_TARGET_HAS_NORMAL 175 normal.xyz = normal.xyz + getNormalDisplacement(vertexId); 176 #endif 177 #if CC_MORPH_TARGET_HAS_TANGENT 178 tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId); 179 #endif 180 } 181 void applyMorph (inout vec4 position) { 182 #if CC_MORPH_TARGET_HAS_POSITION 183 position.xyz = position.xyz + getPositionDisplacement(getVertexId()); 184 #endif 185 } 186 #endif 187 #if CC_USE_SKINNING 188 #if CC_USE_BAKED_ANIMATION 189 layout(std140) uniform CCSkinningTexture { 190 highp vec4 cc_jointTextureInfo; 191 }; 192 layout(std140) uniform CCSkinningAnimation { 193 highp vec4 cc_jointAnimInfo; 194 }; 195 uniform highp sampler2D cc_jointTexture; 196 void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize) 197 { 198 #if USE_INSTANCING 199 highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z; 200 #else 201 highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z; 202 #endif 203 invSize = cc_jointTextureInfo.w; 204 highp float tempY = floor(temp * invSize); 205 x = floor(temp - tempY * cc_jointTextureInfo.x); 206 y = (tempY + 0.5) * invSize; 207 } 208 #else 209 #if CC_USE_REAL_TIME_JOINT_TEXTURE 210 uniform highp sampler2D cc_realtimeJoint; 211 #else 212 layout(std140) uniform CCSkinning { 213 highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3]; 214 }; 215 #endif 216 #endif 217 #if CC_USE_BAKED_ANIMATION 218 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 219 mat4 getJointMatrix (float i) { 220 highp float x, y, invSize; 221 CCGetJointTextureCoords(3.0, i, x, y, invSize); 222 vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y)); 223 vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y)); 224 vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y)); 225 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 226 } 227 #else 228 mat4 getJointMatrix (float i) { 229 highp float x, y, invSize; 230 CCGetJointTextureCoords(12.0, i, x, y, invSize); 231 vec4 v1 = vec4( 232 decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))), 233 decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))), 234 decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))), 235 decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y))) 236 ); 237 vec4 v2 = vec4( 238 decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))), 239 decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))), 240 decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))), 241 decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y))) 242 ); 243 vec4 v3 = vec4( 244 decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))), 245 decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))), 246 decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))), 247 decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y))) 248 ); 249 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 250 } 251 #endif 252 #else 253 #if CC_USE_REAL_TIME_JOINT_TEXTURE 254 #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE 255 mat4 getJointMatrix (float i) { 256 float x = i; 257 vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0)); 258 vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0)); 259 vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0)); 260 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 261 } 262 #else 263 mat4 getJointMatrix (float i) { 264 float x = 4.0 * i; 265 vec4 v1 = vec4( 266 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))), 267 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))), 268 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))), 269 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0))) 270 ); 271 vec4 v2 = vec4( 272 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))), 273 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))), 274 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))), 275 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0))) 276 ); 277 vec4 v3 = vec4( 278 decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))), 279 decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))), 280 decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))), 281 decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0))) 282 ); 283 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 284 } 285 #endif 286 #else 287 mat4 getJointMatrix (float i) { 288 int idx = int(i); 289 vec4 v1 = cc_joints[idx * 3]; 290 vec4 v2 = cc_joints[idx * 3 + 1]; 291 vec4 v3 = cc_joints[idx * 3 + 2]; 292 return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0)); 293 } 294 #endif 295 #endif 296 mat4 skinMatrix () { 297 vec4 joints = vec4(a_joints); 298 return getJointMatrix(joints.x) * a_weights.x 299 + getJointMatrix(joints.y) * a_weights.y 300 + getJointMatrix(joints.z) * a_weights.z 301 + getJointMatrix(joints.w) * a_weights.w; 302 } 303 void CCSkin (inout vec4 position) { 304 mat4 m = skinMatrix(); 305 position = m * position; 306 } 307 void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) { 308 mat4 m = skinMatrix(); 309 position = m * position; 310 normal = (m * vec4(normal, 0.0)).xyz; 311 tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz; 312 } 313 #endif 314 void CCVertInput(inout vec4 In) 315 { 316 In = vec4(a_position, 1.0); 317 #if CC_USE_MORPH 318 applyMorph(In); 319 #endif 320 #if CC_USE_SKINNING 321 CCSkin(In); 322 #endif 323 } 324 layout(std140) uniform CCGlobal { 325 highp vec4 cc_time; 326 mediump vec4 cc_screenSize; 327 mediump vec4 cc_nativeSize; 328 mediump vec4 cc_debug_view_mode; 329 mediump vec4 cc_debug_view_composite_pack_1; 330 mediump vec4 cc_debug_view_composite_pack_2; 331 mediump vec4 cc_debug_view_composite_pack_3; 332 }; 333 layout(std140) uniform CCCamera { 334 highp mat4 cc_matView; 335 highp mat4 cc_matViewInv; 336 highp mat4 cc_matProj; 337 highp mat4 cc_matProjInv; 338 highp mat4 cc_matViewProj; 339 highp mat4 cc_matViewProjInv; 340 highp vec4 cc_cameraPos; 341 mediump vec4 cc_surfaceTransform; 342 mediump vec4 cc_screenScale; 343 mediump vec4 cc_exposure; 344 mediump vec4 cc_mainLitDir; 345 mediump vec4 cc_mainLitColor; 346 mediump vec4 cc_ambientSky; 347 mediump vec4 cc_ambientGround; 348 mediump vec4 cc_fogColor; 349 mediump vec4 cc_fogBase; 350 mediump vec4 cc_fogAdd; 351 mediump vec4 cc_nearFar; 352 mediump vec4 cc_viewPort; 353 }; 354 #if !USE_INSTANCING 355 #if USE_BATCHING 356 layout(std140) uniform CCLocalBatched { 357 highp mat4 cc_matWorlds[10]; 358 }; 359 #else 360 layout(std140) uniform CCLocal { 361 highp mat4 cc_matWorld; 362 highp mat4 cc_matWorldIT; 363 highp vec4 cc_lightingMapUVParam; 364 highp vec4 cc_localShadowBias; 365 }; 366 #endif 367 #endif 368 void CCGetWorldMatrix(out mat4 matWorld) 369 { 370 #if USE_INSTANCING 371 matWorld = mat4( 372 vec4(a_matWorld0.xyz, 0.0), 373 vec4(a_matWorld1.xyz, 0.0), 374 vec4(a_matWorld2.xyz, 0.0), 375 vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0) 376 ); 377 #elif USE_BATCHING 378 matWorld = cc_matWorlds[int(a_dyn_batch_id)]; 379 #else 380 matWorld = cc_matWorld; 381 #endif 382 } 383 layout(std140) uniform CCShadow { 384 highp mat4 cc_matLightView; 385 highp mat4 cc_matLightViewProj; 386 highp vec4 cc_shadowInvProjDepthInfo; 387 highp vec4 cc_shadowProjDepthInfo; 388 highp vec4 cc_shadowProjInfo; 389 mediump vec4 cc_shadowNFLSInfo; 390 mediump vec4 cc_shadowWHPBInfo; 391 mediump vec4 cc_shadowLPNNInfo; 392 lowp vec4 cc_shadowColor; 393 mediump vec4 cc_planarNDInfo; 394 }; 395 out float v_dist; 396 vec4 vert () { 397 vec4 position; 398 CCVertInput(position); 399 mat4 matWorld; 400 CCGetWorldMatrix(matWorld); 401 vec3 P = (matWorld * position).xyz; 402 vec3 L = cc_mainLitDir.xyz; 403 vec3 N = cc_planarNDInfo.xyz; 404 float d = cc_planarNDInfo.w + 0.001; 405 float dist = (-d - dot(P, N)) / (dot(L, N) + 0.0001); 406 vec3 shadowPos = P + L * dist; 407 vec3 view = normalize(cc_cameraPos.xyz - shadowPos); 408 float viewLength = length(cc_cameraPos.xyz - shadowPos); 409 shadowPos += view * min(1.0, 0.005 * viewLength); 410 position = cc_matProj * cc_matView * vec4(shadowPos, 1.0); 411 v_dist = dist; 412 return position; 413 } 414 void main() { gl_Position = vert(); }
onmozfullscreenchange is deprecated.
onmozfullscreenerror is deprecated.