1

我的应用程序在我尝试过的几乎每台机器上都能正常运行,但是我的一个用户在 google chrome 中报告了以下控制台错误(在 Firefox 中运行良好)。该应用程序只为他加载了一部分。

THREE.WebGLRenderer 58 Three58.js:18430
THREE.WebGLRenderer: Float textures not supported. Three58.js:25713
THREE.WebGLRenderer: Standard derivatives not supported. Three58.js:25719

我以前从未见过这种情况。我没有使用任何自定义着色器,只使用了three.js 提供的那些。我无法轻松调试此问题,因为我无法重现该问题。

有任何想法吗?

编辑

好的,所以我用以下内容覆盖了这些行:

_glExtensionTextureFloat = null;
_glExtensionStandardDerivatives = null;

我希望这能让我调试这种情况。错误的。即使将这些设置为 null,我也可以在我的机器上用 chrome 加载我的应用程序。在进一步查看 three.js 代码后,我在第 24836 行看到了这一点:

( parameters.bumpMap || parameters.normalMap ) ? "#extension GL_OES_standard_derivatives : enable" : "",

我确实在我的用户错误日志中看到了。我不使用bumpMaps,但是我使用normalMaps。在这样的新机器/显卡上,normalMaps 怎么会成为问题?我的意思是它们在我那破 5 年的笔记本电脑上工作得很好。这是他提供的控制台错误日志的其余部分:

WARNING: 0:2: 'GL_OES_standard_derivatives' : extension is not supported
ERROR: 0:150: 'dFdx' : no matching overloaded function found 
ERROR: 0:150: '=' :  cannot convert from 'const mediump float' to '3-component vector of float'
ERROR: 0:151: 'dFdy' : no matching overloaded function found 
ERROR: 0:151: '=' :  cannot convert from 'const mediump float' to '3-component vector of float'
ERROR: 0:152: 'dFdx' : no matching overloaded function found 
ERROR: 0:152: '=' :  cannot convert from 'const mediump float' to '2-component vector of float'
ERROR: 0:153: 'dFdy' : no matching overloaded function found 
ERROR: 0:153: '=' :  cannot convert from 'const mediump float' to '2-component vector of float'
 Three58.js:25038
1: precision highp float;
2: #extension GL_OES_standard_derivatives : enable
3: 
4: #define MAX_DIR_LIGHTS 1
5: #define MAX_POINT_LIGHTS 1
6: #define MAX_SPOT_LIGHTS 0
7: #define MAX_HEMI_LIGHTS 0
8: #define MAX_SHADOWS 1
9: #define ALPHATEST 0.5
10: 
11: 
12: 
13: #define USE_FOG
14: #define FOG_EXP2
15: #define USE_MAP
16: 
17: 
18: 
19: #define USE_NORMALMAP
20: 
21: 
22: 
23: #define PHONG_PER_PIXEL
24: 
25: 
26: 
27: #define USE_SHADOWMAP
28: #define SHADOWMAP_TYPE_PCF
29: 
30: 
31: uniform mat4 viewMatrix;
32: uniform vec3 cameraPosition;
33: uniform vec3 diffuse;
34: uniform float opacity;
35: uniform vec3 ambient;
36: uniform vec3 emissive;
37: uniform vec3 specular;
38: uniform float shininess;
39: #ifdef USE_COLOR
40: varying vec3 vColor;
41: #endif
42: #if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )
43: varying vec2 vUv;
44: #endif
45: #ifdef USE_MAP
46: uniform sampler2D map;
47: #endif
48: #ifdef USE_LIGHTMAP
49: varying vec2 vUv2;
50: uniform sampler2D lightMap;
51: #endif
52: #ifdef USE_ENVMAP
53: uniform float reflectivity;
54: uniform samplerCube envMap;
55: uniform float flipEnvMap;
56: uniform int combine;
57: #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
58: uniform bool useRefract;
59: uniform float refractionRatio;
60: #else
61: varying vec3 vReflect;
62: #endif
63: #endif
64: #ifdef USE_FOG
65: uniform vec3 fogColor;
66: #ifdef FOG_EXP2
67: uniform float fogDensity;
68: #else
69: uniform float fogNear;
70: uniform float fogFar;
71: #endif
72: #endif
73: uniform vec3 ambientLightColor;
74: #if MAX_DIR_LIGHTS > 0
75: uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
76: uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
77: #endif
78: #if MAX_HEMI_LIGHTS > 0
79: uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
80: uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
81: uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
82: #endif
83: #if MAX_POINT_LIGHTS > 0
84: uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
85: #ifdef PHONG_PER_PIXEL
86: uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
87: uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
88: #else
89: varying vec4 vPointLight[ MAX_POINT_LIGHTS ];
90: #endif
91: #endif
92: #if MAX_SPOT_LIGHTS > 0
93: uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
94: uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
95: uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
96: uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
97: uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
98: #ifdef PHONG_PER_PIXEL
99: uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
100: #else
101: varying vec4 vSpotLight[ MAX_SPOT_LIGHTS ];
102: #endif
103: #endif
104: #if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP )
105: varying vec3 vWorldPosition;
106: #endif
107: #ifdef WRAP_AROUND
108: uniform vec3 wrapRGB;
109: #endif
110: varying vec3 vViewPosition;
111: varying vec3 vNormal;
112: #ifdef USE_SHADOWMAP
113: uniform sampler2D shadowMap[ MAX_SHADOWS ];
114: uniform vec2 shadowMapSize[ MAX_SHADOWS ];
115: uniform float shadowDarkness[ MAX_SHADOWS ];
116: uniform float shadowBias[ MAX_SHADOWS ];
117: varying vec4 vShadowCoord[ MAX_SHADOWS ];
118: float unpackDepth( const in vec4 rgba_depth ) {
119: const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );
120: float depth = dot( rgba_depth, bit_shift );
121: return depth;
122: }
123: #endif
124: #ifdef USE_BUMPMAP
125: uniform sampler2D bumpMap;
126: uniform float bumpScale;
127: vec2 dHdxy_fwd() {
128: vec2 dSTdx = dFdx( vUv );
129: vec2 dSTdy = dFdy( vUv );
130: float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
131: float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
132: float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
133: return vec2( dBx, dBy );
134: }
135: vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
136: vec3 vSigmaX = dFdx( surf_pos );
137: vec3 vSigmaY = dFdy( surf_pos );
138: vec3 vN = surf_norm;
139: vec3 R1 = cross( vSigmaY, vN );
140: vec3 R2 = cross( vN, vSigmaX );
141: float fDet = dot( vSigmaX, R1 );
142: vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
143: return normalize( abs( fDet ) * surf_norm - vGrad );
144: }
145: #endif
146: #ifdef USE_NORMALMAP
147: uniform sampler2D normalMap;
148: uniform vec2 normalScale;
149: vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {
150: vec3 q0 = dFdx( eye_pos.xyz );
151: vec3 q1 = dFdy( eye_pos.xyz );
152: vec2 st0 = dFdx( vUv.st );
153: vec2 st1 = dFdy( vUv.st );
154: vec3 S = normalize(  q0 * st1.t - q1 * st0.t );
155: vec3 T = normalize( -q0 * st1.s + q1 * st0.s );
156: vec3 N = normalize( surf_norm );
157: vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
158: mapN.xy = normalScale * mapN.xy;
159: mat3 tsn = mat3( S, T, N );
160: return normalize( tsn * mapN );
161: }
162: #endif
163: #ifdef USE_SPECULARMAP
164: uniform sampler2D specularMap;
165: #endif
166: void main() {
167: gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
168: #ifdef USE_MAP
169: vec4 texelColor = texture2D( map, vUv );
170: #ifdef GAMMA_INPUT
171: texelColor.xyz *= texelColor.xyz;
172: #endif
173: gl_FragColor = gl_FragColor * texelColor;
174: #endif
175: #ifdef ALPHATEST
176: if ( gl_FragColor.a < ALPHATEST ) discard;
177: #endif
178: float specularStrength;
179: #ifdef USE_SPECULARMAP
180: vec4 texelSpecular = texture2D( specularMap, vUv );
181: specularStrength = texelSpecular.r;
182: #else
183: specularStrength = 1.0;
184: #endif
185: vec3 normal = normalize( vNormal );
186: vec3 viewPosition = normalize( vViewPosition );
187: #ifdef DOUBLE_SIDED
188: normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );
189: #endif
190: #ifdef USE_NORMALMAP
191: normal = perturbNormal2Arb( -vViewPosition, normal );
192: #elif defined( USE_BUMPMAP )
193: normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
194: #endif
195: #if MAX_POINT_LIGHTS > 0
196: vec3 pointDiffuse  = vec3( 0.0 );
197: vec3 pointSpecular = vec3( 0.0 );
198: for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
199: #ifdef PHONG_PER_PIXEL
200: vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
201: vec3 lVector = lPosition.xyz + vViewPosition.xyz;
202: float lDistance = 1.0;
203: if ( pointLightDistance[ i ] > 0.0 )
204: lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );
205: lVector = normalize( lVector );
206: #else
207: vec3 lVector = normalize( vPointLight[ i ].xyz );
208: float lDistance = vPointLight[ i ].w;
209: #endif
210: float dotProduct = dot( normal, lVector );
211: #ifdef WRAP_AROUND
212: float pointDiffuseWeightFull = max( dotProduct, 0.0 );
213: float pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
214: vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );
215: #else
216: float pointDiffuseWeight = max( dotProduct, 0.0 );
217: #endif
218: pointDiffuse  += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;
219: vec3 pointHalfVector = normalize( lVector + viewPosition );
220: float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );
221: float pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );
222: #ifdef PHYSICALLY_BASED_SHADING
223: float specularNormalization = ( shininess + 2.0001 ) / 8.0;
224: vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, pointHalfVector ), 5.0 );
225: pointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;
226: #else
227: pointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;
228: #endif
229: }
230: #endif
231: #if MAX_SPOT_LIGHTS > 0
232: vec3 spotDiffuse  = vec3( 0.0 );
233: vec3 spotSpecular = vec3( 0.0 );
234: for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
235: #ifdef PHONG_PER_PIXEL
236: vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );
237: vec3 lVector = lPosition.xyz + vViewPosition.xyz;
238: float lDistance = 1.0;
239: if ( spotLightDistance[ i ] > 0.0 )
240: lDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );
241: lVector = normalize( lVector );
242: #else
243: vec3 lVector = normalize( vSpotLight[ i ].xyz );
244: float lDistance = vSpotLight[ i ].w;
245: #endif
246: float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );
247: if ( spotEffect > spotLightAngleCos[ i ] ) {
248: spotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );
249: float dotProduct = dot( normal, lVector );
250: #ifdef WRAP_AROUND
251: float spotDiffuseWeightFull = max( dotProduct, 0.0 );
252: float spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
253: vec3 spotDiffuseWeight = mix( vec3 ( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );
254: #else
255: float spotDiffuseWeight = max( dotProduct, 0.0 );
256: #endif
257: spotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;
258: vec3 spotHalfVector = normalize( lVector + viewPosition );
259: float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );
260: float spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );
261: #ifdef PHYSICALLY_BASED_SHADING
262: float specularNormalization = ( shininess + 2.0001 ) / 8.0;
263: vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, spotHalfVector ), 5.0 );
264: spotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;
265: #else
266: spotSpecular += specular * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * spotEffect;
267: #endif
268: }
269: }
270: #endif
271: #if MAX_DIR_LIGHTS > 0
272: vec3 dirDiffuse  = vec3( 0.0 );
273: vec3 dirSpecular = vec3( 0.0 );
274: for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
275: vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
276: vec3 dirVector = normalize( lDirection.xyz );
277: float dotProduct = dot( normal, dirVector );
278: #ifdef WRAP_AROUND
279: float dirDiffuseWeightFull = max( dotProduct, 0.0 );
280: float dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
281: vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );
282: #else
283: float dirDiffuseWeight = max( dotProduct, 0.0 );
284: #endif
285: dirDiffuse  += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;
286: vec3 dirHalfVector = normalize( dirVector + viewPosition );
287: float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );
288: float dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );
289: #ifdef PHYSICALLY_BASED_SHADING
290: float specularNormalization = ( shininess + 2.0001 ) / 8.0;
291: vec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );
292: dirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;
293: #else
294: dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;
295: #endif
296: }
297: #endif
298: #if MAX_HEMI_LIGHTS > 0
299: vec3 hemiDiffuse  = vec3( 0.0 );
300: vec3 hemiSpecular = vec3( 0.0 );
301: for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
302: vec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );
303: vec3 lVector = normalize( lDirection.xyz );
304: float dotProduct = dot( normal, lVector );
305: float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
306: vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );
307: hemiDiffuse += diffuse * hemiColor;
308: vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );
309: float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;
310: float hemiSpecularWeightSky = specularStrength * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );
311: vec3 lVectorGround = -lVector;
312: vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );
313: float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;
314: float hemiSpecularWeightGround = specularStrength * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );
315: #ifdef PHYSICALLY_BASED_SHADING
316: float dotProductGround = dot( normal, lVectorGround );
317: float specularNormalization = ( shininess + 2.0001 ) / 8.0;
318: vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );
319: vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );
320: hemiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );
321: #else
322: hemiSpecular += specular * hemiColor * ( hemiSpecularWeightSky + hemiSpecularWeightGround ) * hemiDiffuseWeight;
323: #endif
324: }
325: #endif
326: vec3 totalDiffuse = vec3( 0.0 );
327: vec3 totalSpecular = vec3( 0.0 );
328: #if MAX_DIR_LIGHTS > 0
329: totalDiffuse += dirDiffuse;
330: totalSpecular += dirSpecular;
331: #endif
332: #if MAX_HEMI_LIGHTS > 0
333: totalDiffuse += hemiDiffuse;
334: totalSpecular += hemiSpecular;
335: #endif
336: #if MAX_POINT_LIGHTS > 0
337: totalDiffuse += pointDiffuse;
338: totalSpecular += pointSpecular;
339: #endif
340: #if MAX_SPOT_LIGHTS > 0
341: totalDiffuse += spotDiffuse;
342: totalSpecular += spotSpecular;
343: #endif
344: #ifdef METAL
345: gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );
346: #else
347: gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;
348: #endif
349: #ifdef USE_LIGHTMAP
350: gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
351: #endif
352: #ifdef USE_COLOR
353: gl_FragColor = gl_FragColor * vec4( vColor, opacity );
354: #endif
355: #ifdef USE_ENVMAP
356: vec3 reflectVec;
357: #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
358: vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
359: if ( useRefract ) {
360: reflectVec = refract( cameraToVertex, normal, refractionRatio );
361: } else { 
362: reflectVec = reflect( cameraToVertex, normal );
363: }
364: #else
365: reflectVec = vReflect;
366: #endif
367: #ifdef DOUBLE_SIDED
368: float flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );
369: vec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
370: #else
371: vec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
372: #endif
373: #ifdef GAMMA_INPUT
374: cubeColor.xyz *= cubeColor.xyz;
375: #endif
376: if ( combine == 1 ) {
377: gl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );
378: } else if ( combine == 2 ) {
379: gl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;
380: } else {
381: gl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );
382: }
383: #endif
384: #ifdef USE_SHADOWMAP
385: #ifdef SHADOWMAP_DEBUG
386: vec3 frustumColors[3];
387: frustumColors[0] = vec3( 1.0, 0.5, 0.0 );
388: frustumColors[1] = vec3( 0.0, 1.0, 0.8 );
389: frustumColors[2] = vec3( 0.0, 0.5, 1.0 );
390: #endif
391: #ifdef SHADOWMAP_CASCADE
392: int inFrustumCount = 0;
393: #endif
394: float fDepth;
395: vec3 shadowColor = vec3( 1.0 );
396: for( int i = 0; i < MAX_SHADOWS; i ++ ) {
397: vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;
398: bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
399: bool inFrustum = all( inFrustumVec );
400: #ifdef SHADOWMAP_CASCADE
401: inFrustumCount += int( inFrustum );
402: bvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );
403: #else
404: bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
405: #endif
406: bool frustumTest = all( frustumTestVec );
407: if ( frustumTest ) {
408: shadowCoord.z += shadowBias[ i ];
409: #if defined( SHADOWMAP_TYPE_PCF )
410: float shadow = 0.0;
411: const float shadowDelta = 1.0 / 9.0;
412: float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
413: float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
414: float dx0 = -1.25 * xPixelOffset;
415: float dy0 = -1.25 * yPixelOffset;
416: float dx1 = 1.25 * xPixelOffset;
417: float dy1 = 1.25 * yPixelOffset;
418: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
419: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
420: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
421: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
422: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
423: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
424: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
425: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
426: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
427: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
428: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
429: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
430: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
431: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
432: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
433: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
434: fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
435: if ( fDepth < shadowCoord.z ) shadow += shadowDelta;
436: shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
437: #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
438: float shadow = 0.0;
439: float xPixelOffset = 1.0 / shadowMapSize[ i ].x;
440: float yPixelOffset = 1.0 / shadowMapSize[ i ].y;
441: float dx0 = -1.0 * xPixelOffset;
442: float dy0 = -1.0 * yPixelOffset;
443: float dx1 = 1.0 * xPixelOffset;
444: float dy1 = 1.0 * yPixelOffset;
445: mat3 shadowKernel;
446: mat3 depthKernel;
447: depthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );
448: depthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );
449: depthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );
450: depthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );
451: depthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );
452: depthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );
453: depthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );
454: depthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );
455: depthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );
456: vec3 shadowZ = vec3( shadowCoord.z );
457: shadowKernel[0] = vec3(lessThan(depthKernel[0], shadowZ ));
458: shadowKernel[0] *= vec3(0.25);
459: shadowKernel[1] = vec3(lessThan(depthKernel[1], shadowZ ));
460: shadowKernel[1] *= vec3(0.25);
461: shadowKernel[2] = vec3(lessThan(depthKernel[2], shadowZ ));
462: shadowKernel[2] *= vec3(0.25);
463: vec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );
464: shadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );
465: shadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );
466: vec4 shadowValues;
467: shadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );
468: shadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );
469: shadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );
470: shadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );
471: shadow = dot( shadowValues, vec4( 1.0 ) );
472: shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );
473: #else
474: vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );
475: float fDepth = unpackDepth( rgbaDepth );
476: if ( fDepth < shadowCoord.z )
477: shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );
478: #endif
479: }
480: #ifdef SHADOWMAP_DEBUG
481: #ifdef SHADOWMAP_CASCADE
482: if ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];
483: #else
484: if ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];
485: #endif
486: #endif
487: }
488: #ifdef GAMMA_OUTPUT
489: shadowColor *= shadowColor;
490: #endif
491: gl_FragColor.xyz = gl_FragColor.xyz * shadowColor;
492: #endif
493: #ifdef GAMMA_OUTPUT
494: gl_FragColor.xyz = sqrt( gl_FragColor.xyz );
495: #endif
496: #ifdef USE_FOG
497: float depth = gl_FragCoord.z / gl_FragCoord.w;
498: #ifdef FOG_EXP2
499: const float LOG2 = 1.442695;
500: float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );
501: fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );
502: #else
503: float fogFactor = smoothstep( fogNear, fogFar, depth );
504: #endif
505: gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
506: #endif
507: } Three58.js:25039
WebGL: INVALID_VALUE: attachShader: no object or object deleted www.titansoftime.com/:1
4

2 回答 2

1

在 r58 版本中,如果您查看 three.js 第 26037 行,您将看到 three.js 检查是否OES_texture_float支持扩展。如果不是,则在第 26051 行给出错误消息。因此,在您的应用程序中,您可以在扩展程序到达 three.js 之前检查它并通知您的用户有关要求。

于 2013-06-11T08:19:58.730 回答
0

我正在使用 three.js 的 55 版并发现类似的问题。在一些非常旧的 chrome 电脑上,我看到了这个警告:

THREE.WebGLRenderer: Float textures not supported.
THREE.WebGLRenderer: Standard derivatives not supported.

它产生了问题,一些模型是不可见的。它是由 HemisphereLight 引起的。我使用了两个 HemisphereLights。如果 PC 不支持浮动纹理或标准衍生品,这将不起作用。所以我不得不从我的代码中删除第二盏灯来解决这个问题。

于 2014-06-17T12:47:48.440 回答