Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limited number of lightsources ? #4234

Closed
DjangoCharango opened this issue Jan 6, 2020 · 5 comments · Fixed by #4239 or #7337
Closed

Limited number of lightsources ? #4234

DjangoCharango opened this issue Jan 6, 2020 · 5 comments · Fixed by #4239 or #7337

Comments

@DjangoCharango
Copy link

Is the numbers of lightsources (pointlight, directional ...) you can add to a 3-dimensional scene limited in some way?

I am trying to figure out, why some lightsources in my scene are being rendered, while others are not.

@welcome
Copy link

welcome bot commented Jan 6, 2020

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

@stalgiag
Copy link
Contributor

stalgiag commented Jan 6, 2020

Hi @DjangoCharango yes there is a limit to the number of lighting uniforms that mobile devices and browsers support. So the hard limit is 5 per type at any one time.

Thanks for pointing this out. It is clear that this should be documented better.

I am going to add a help wanted label. The todo is to add a note in the inline reference for each of the lighting functions that explains that a sketch only supports a maximum of five lights of each type.

This should be done with:

@DjangoCharango
Copy link
Author

Thanks a lot for your answer. My Tests show, that I can have 9 pointLights in Chrome. Do you know, where I could find more information, on how many light sources, browsers support ?

@stalgiag
Copy link
Contributor

stalgiag commented Jan 6, 2020

If you are using a version <= 10.2 of p5 then you will have an upper limit of 8. Not sure how you are getting 9.

Version 1.0 will have a limit of 5 lights. This is because the number of uniforms is limited to 64 in iOS. We do not adjust the number of uniforms based on the browser/device, so these limitations will apply to all sketches made with p5. You can view this PR for more info.. Also here is the relevant shader.

If you are targeting a specific hardware/browser combo that allows more uniforms (such as desktop or android) and you need a large number of lights, you can change the array lengths in the shader and build p5 from source.

@blackboxlogic
Copy link
Contributor

blackboxlogic commented Oct 29, 2024

I came here to report the same problem five years later, found this issue marked done, found the merged PR... but the documentation for directionalLight doesn't mention the 5-per-type limit. maybe I should open a new issue?

blackboxlogic added a commit to blackboxlogic/p5.js that referenced this issue Oct 29, 2024
Documentation for other light source types already says this. I found the limit by experimentation. Fixes processing#4234
processing#4234
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants