[SOLVED] Error: Fragment shader texture image units count exceeds MAX_TEXTURE_IMAGE_UNITS(16)

Hi I’m making an online multiplayer game and I have it working on my Chromebook but when I try to run it on my desktop everything is the camera clear colour except UI.
Either that or sometimes it just crashes out right.
Is there any way I can make the versions match?

Update: I have found a few more details on the chromebook there are 0 errors while on desktop it says “Error: Fragment shader texture image units count exceeds MAX_TEXTURE_IMAGE_UNITS(16)” if anyone knows what that means please tell.

Hi @WilliamBoersma31,

That error means there are too many textures being passed to the GPU at the same time. This usually occurs when you have too many realtime lights. Try disabling a few of them and see if that improves anything.

1 Like

ok thanks for the feed back although I have 1 question. Why would the Chromebook be able to handle it when the Desktop has about 10 the specs?

I can’t say for sure. Different hardware and browsers can have different settings for what they allow to be passed to the GPU

Lowering the amount of lights fixed it is there any way I can have the lights only activate while withing a specific range?

Hey I’m making a game that has a big map and I need the lights to switch between details when within a radius I have this for the code https://playcanvas.com/editor/code/843141?tabs=59580428 but its not working does anyone know how to fix it?

Update: I got it working but it causes a massive lag spike especially when there are lots of lights. Is there any way to optimise it to help with lag?

Hi @WilliamBoersma31,

If you use more than 2-3 lights then that’s expected.

Consider using cluster lighting for that:

https://playcanvas.github.io/#/graphics/clustered-lighting

1 Like

With clustered lights, you can have many lights a lot cheaper with less / no spikes. Those spikes are caused by shaders having to recompile when you enable / disable lights.

But note that clustered lights are not fully featured yet, it’s a pre-release of the tech. But seems to work well for some projects already.

1 Like

Hey just wondering if i can have a little help implementing cluster lights

Sure. Lest start with details on what light set up you use / need please, to make sure clustered lights can help out here.

1 Like

I just need something like the basic cluster-lighting example

in that case just look at the example … and grab few relevant lines

1 Like

if you don’t need shadows nor cooking for omni and spot lights, set these to false as well - makes shaders smaller / faster

1 Like

How would I setup the first one I tried copying it into my project but it didn’t work

should I just copy the highlighted part?

yes - create a script, maybe call it clustered-lights.js, copy those lines to initialize function, and attach it to a root of your scene or something similar … so those lines execute just one time.

Thanks I got it working with no additional setup

1 Like

Update: The game now crashes when I change scenes. How do I fix that?
When it crashes it leaves this error " [playcanvas.dbg.js?version=1.49.1:22062]: Uncaught TypeError: Cannot read properties of undefined (reading ‘depthBuffer’)"