Error when I have more than 10 lights in my scene

Hi,

I am getting errors when I have more than 10 lights in my scene. Am I doing anything wrong?

Thanks in advance.

Have you read about the light limitations? Lights - Babylon.js Documentation

Yes.
As per the documentation,

  1. You can have any number of lights.
  2. You can even set material.maxSimultaneousLights

So, the problem is somewhere else.

can you repro in the playground?

I will try.

Here is the error
BJS - [22:38:01]: Trying next fallback.
BJS - [22:38:02]: Uniforms: world, view, viewProjection, vEyePosition, vLightsType, vAmbientColor, vDiffuseColor, vSpecularColor, vEmissiveColor, visibility, vFogInfos, vFogColor, pointSize, vDiffuseInfos, vAmbientInfos, vOpacityInfos, vReflectionInfos, vEmissiveInfos, vSpecularInfos, vBumpInfos, vLightmapInfos, vRefractionInfos, mBones, vClipPlane, vClipPlane2, vClipPlane3, vClipPlane4, diffuseMatrix, ambientMatrix, opacityMatrix, reflectionMatrix, emissiveMatrix, specularMatrix, bumpMatrix, normalMatrix, lightmapMatrix, refractionMatrix, diffuseLeftColor, diffuseRightColor, opacityParts, reflectionLeftColor, reflectionRightColor, emissiveLeftColor, emissiveRightColor, refractionLeftColor, refractionRightColor, vReflectionPosition, vReflectionSize, logarithmicDepthConstant, vTangentSpaceParams, alphaCutOff, boneTextureWidth, vLightData0, vLightDiffuse0, vLightSpecular0, vLightDirection0, vLightFalloff0, vLightGround0, lightMatrix0, shadowsInfo0, depthValues0, vLightData1, vLightDiffuse1, vLightSpecular1, vLightDirection1, vLightFalloff1, vLightGround1, lightMatrix1, shadowsInfo1, depthValues1, vLightData2, vLightDiffuse2, vLightSpecular2, vLightDirection2, vLightFalloff2, vLightGround2, lightMatrix2, shadowsInfo2, depthValues2, vLightData3, vLightDiffuse3, vLightSpecular3, vLightDirection3, vLightFalloff3, vLightGround3, lightMatrix3, shadowsInfo3, depthValues3, vLightData4, vLightDiffuse4, vLightSpecular4, vLightDirection4, vLightFalloff4, vLightGround4, lightMatrix4, shadowsInfo4, depthValues4, vLightData5, vLightDiffuse5, vLightSpecular5, vLightDirection5, vLightFalloff5, vLightGround5, lightMatrix5, shadowsInfo5, depthValues5, vLightData6, vLightDiffuse6, vLightSpecular6, vLightDirection6, vLightFalloff6, vLightGround6, lightMatrix6, shadowsInfo6, depthValues6, vLightData7, vLightDiffuse7, vLightSpecular7, vLightDirection7, vLightFalloff7, vLightGround7, lightMatrix7, shadowsInfo7, depthValues7, vLightData8, vLightDiffuse8, vLightSpecular8, vLightDirection8, vLightFalloff8, vLightGround8, lightMatrix8, shadowsInfo8, depthValues8, vLightData9, vLightDiffuse9, vLightSpecular9, vLightDirection9, vLightFalloff9, vLightGround9, lightMatrix9, shadowsInfo9, depthValues9, vLightData10, vLightDiffuse10, vLightSpecular10, vLightDirection10, vLightFalloff10, vLightGround10, lightMatrix10, shadowsInfo10, depthValues10, vLightData11, vLightDiffuse11, vLightSpecular11, vLightDirection11, vLightFalloff11, vLightGround11, lightMatrix11, shadowsInfo11, depthValues11, vLightData12, vLightDiffuse12, vLightSpecular12, vLightDirection12, vLightFalloff12, vLightGround12, lightMatrix12, shadowsInfo12, depthValues12, vLightData13, vLightDiffuse13, vLightSpecular13, vLightDirection13, vLightFalloff13, vLightGround13, lightMatrix13, shadowsInfo13, depthValues13, vLightData14, vLightDiffuse14, vLightSpecular14, vLightDirection14, vLightFalloff14, vLightGround14, lightMatrix14, shadowsInfo14, depthValues14, vLightData15, vLightDiffuse15, vLightSpecular15, vLightDirection15, vLightFalloff15, vLightGround15, lightMatrix15, shadowsInfo15, depthValues15, vLightData16, vLightDiffuse16, vLightSpecular16, vLightDirection16, vLightFalloff16, vLightGround16, lightMatrix16, shadowsInfo16, depthValues16, vLightData17, vLightDiffuse17, vLightSpecular17, vLightDirection17, vLightFalloff17, vLightGround17, lightMatrix17, shadowsInfo17, depthValues17, vLightData18, vLightDiffuse18, vLightSpecular18, vLightDirection18, vLightFalloff18, vLightGround18, lightMatrix18, shadowsInfo18, depthValues18, vLightData19, vLightDiffuse19, vLightSpecular19, vLightDirection19, vLightFalloff19, vLightGround19, lightMatrix19, shadowsInfo19, depthValues19, vLightData20, vLightDiffuse20, vLightSpecular20, vLightDirection20, vLightFalloff20, vLightGround20, lightMatrix20, shadowsInfo20, depthValues20, vLightData21, vLightDiffuse21, vLightSpecular21, vLightDirection21, vLightFalloff21, vLightGround21, lightMatrix21, shadowsInfo21, depthValues21, vLightData22, vLightDiffuse22, vLightSpecular22, vLightDirection22, vLightFalloff22, vLightGround22, lightMatrix22, shadowsInfo22, depthValues22, vLightData23, vLightDiffuse23, vLightSpecular23, vLightDirection23, vLightFalloff23, vLightGround23, lightMatrix23, shadowsInfo23, depthValues23, vLightData24, vLightDiffuse24, vLightSpecular24, vLightDirection24, vLightFalloff24, vLightGround24, lightMatrix24, shadowsInfo24, depthValues24, vLightData25, vLightDiffuse25, vLightSpecular25, vLightDirection25, vLightFalloff25, vLightGround25, lightMatrix25, shadowsInfo25, depthValues25, vLightData26, vLightDiffuse26, vLightSpecular26, vLightDirection26, vLightFalloff26, vLightGround26, lightMatrix26, shadowsInfo26, depthValues26, vLightData27, vLightDiffuse27, vLightSpecular27, vLightDirection27, vLightFalloff27, vLightGround27, lightMatrix27, shadowsInfo27, depthValues27, vLightData28, vLightDiffuse28, vLightSpecular28, vLightDirection28, vLightFalloff28, vLightGround28, lightMatrix28, shadowsInfo28, depthValues28, vLightData29, vLi

BJS - [22:38:02]: Error: ERROR: 0:39650: ‘vPositionFromLight1’ : undeclared identifier
ERROR: 0:39650: ‘lightMatrix1’ : undeclared identifier
ERROR: 0:39650: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39650: ‘=’ : dimension mismatch
ERROR: 0:39650: ‘assign’ : cannot convert from ‘highp 4-component vector of float’ to ‘const highp float’
ERROR: 0:39651: ‘vDepthMetric1’ : undeclared identifier
ERROR: 0:39651: ‘vPositionFromLight1’ : undeclared identifier
ERROR: 0:39651: ‘z’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39651: ‘light1’ : undeclared identifier
ERROR: 0:39651: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39651: ‘x’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39651: ‘light1’ : undeclared identifier
ERROR: 0:39651: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39651: ‘y’ : field selection requires structure, vector, or interface block on left hand side
WARNING: 0:39651: ‘/’ : Zero divided by zero during constant folding generated NaN
ERROR: 0:39651: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39656: ‘vPositionFromLight2’ : undeclared identifier
ERROR: 0:39656: ‘lightMatrix2’ : undeclared identifier
ERROR: 0:39656: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39656: ‘=’ : dimension mismatch
ERROR: 0:39656: ‘assign’ : cannot convert from ‘highp 4-component vector of float’ to ‘const highp float’
ERROR: 0:39657: ‘vDepthMetric2’ : undeclared identifier
ERROR: 0:39657: ‘vPositionFromLight2’ : undeclared identifier
ERROR: 0:39657: ‘z’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39657: ‘light2’ : undeclared identifier
ERROR: 0:39657: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39657: ‘x’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39657: ‘light2’ : undeclared identifier
ERROR: 0:39657: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39657: ‘y’ : field selection requires structure, vector, or interface block on left hand side
WARNING: 0:39657: ‘/’ : Zero divided by zero during constant folding generated NaN
ERROR: 0:39657: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39662: ‘vPositionFromLight3’ : undeclared identifier
ERROR: 0:39662: ‘lightMatrix3’ : undeclared identifier
ERROR: 0:39662: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39662: ‘=’ : dimension mismatch
ERROR: 0:39662: ‘assign’ : cannot convert from ‘highp 4-component vector of float’ to ‘const highp float’
ERROR: 0:39663: ‘vDepthMetric3’ : undeclared identifier
ERROR: 0:39663: ‘vPositionFromLight3’ : undeclared identifier
ERROR: 0:39663: ‘z’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39663: ‘light3’ : undeclared identifier
ERROR: 0:39663: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39663: ‘x’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39663: ‘light3’ : undeclared identifier
ERROR: 0:39663: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39663: ‘y’ : field selection requires structure, vector, or interface block on left hand side
WARNING: 0:39663: ‘/’ : Zero divided by zero during constant folding generated NaN
ERROR: 0:39663: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39668: ‘vPositionFromLight4’ : undeclared identifier
ERROR: 0:39668: ‘lightMatrix4’ : undeclared identifier
ERROR: 0:39668: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39668: ‘=’ : dimension mismatch
ERROR: 0:39668: ‘assign’ : cannot convert from ‘highp 4-component vector of float’ to ‘const highp float’
ERROR: 0:39669: ‘vDepthMetric4’ : undeclared identifier
ERROR: 0:39669: ‘vPositionFromLight4’ : undeclared identifier
ERROR: 0:39669: ‘z’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39669: ‘light4’ : undeclared identifier
ERROR: 0:39669: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39669: ‘x’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39669: ‘light4’ : undeclared identifier
ERROR: 0:39669: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39669: ‘y’ : field selection requires structure, vector, or interface block on left hand side
WARNING: 0:39669: ‘/’ : Zero divided by zero during constant folding generated NaN
ERROR: 0:39669: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39674: ‘vPositionFromLight5’ : undeclared identifier
ERROR: 0:39674: ‘lightMatrix5’ : undeclared identifier
ERROR: 0:39674: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:39674: ‘=’ : dimension mismatch
ERROR: 0:39674: ‘assign’ : cannot convert from ‘highp 4-component vector of float’ to ‘const highp float’
ERROR: 0:39675: ‘vDepthMetric5’ : undeclared identifier
ERROR: 0:39675: ‘vPositionFromLight5’ : undeclared identifier
ERROR: 0:39675: ‘z’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39675: ‘light5’ : undeclared identifier
ERROR: 0:39675: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39675: ‘x’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39675: ‘light5’ : undeclared identifier
ERROR: 0:39675: ‘depthValues’ : field selection requires structure, vector, or interface block on left hand side
ERROR: 0:39675: ‘y’ : field selection requires structure, vector, or interface block on left hand side
WARNING: 0:39675: ‘/’ : Zero divided by zero during constant folding generated NaN
ERROR: 0:39675: ‘assign’ : l-value required (can’t modify a const)

This is the playground Babylon.js Playground

Here is a playground with lights https://www.babylonjs-playground.com/#IRVAX#0

This is some information on using the playground https://doc.babylonjs.com/babylon101/first#the-playground

Deltakosh is asking can you put some code in the playground and reproduce the problem.

Yeah I got it.

I am getting errors if I set material.maxSimultaneousLights to a value greater than 10.

Here is the PG:
https://www.babylonjs-playground.com/#IRVAX#67

Seems OK https://www.babylonjs-playground.com/#IRVAX#68

Can you put the code you are using in a playground.

Why seems OK? It is giving errors right?

Sorry you are right perhaps @Deltakosh can help

Unfortunately you are hitting a constraint of WebGL2 itself:

The best option could be to disable uniform buffers (it will give you more room but the rendering could be a bit slower):
https://www.babylonjs-playground.com/#IRVAX#69 (see line #4)

2 Likes