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

PBR Light Limits #8463

Closed
3 of 12 tasks
centerionware opened this issue Mar 24, 2016 · 3 comments
Closed
3 of 12 tasks

PBR Light Limits #8463

centerionware opened this issue Mar 24, 2016 · 3 comments

Comments

@centerionware
Copy link
Contributor

Description of the problem

When adding more point lights to the PBR Light demo VIA

            for (var i = 0; i < SOME_NUMBER; i++) {
                var bGeometry = new THREE.SphereGeometry(0.02, 16, 8);
                var bLight = new THREE.PointLight(0xffee88, 1, 100, 2);

                var bMat = new THREE.MeshStandardMaterial({
                    emissive: 0xffffee,
                    emissiveIntensity: 1,
                    color: 0x000000
                });
                bLight.add(new THREE.Mesh(bGeometry, bMat));
                bLight.position.set(0, 2, i);
                bLight.castShadow = true;
                bLight.power = bulbLuminousPowers[params.bulbPower];
                bMat.emissiveIntensity = bulbLight.intensity / Math.pow(0.02, 2.0)

                scene.add(bLight);
            }

If SOME_NUMBER is > 12 everything breaks all lighting with WEBGL complaining about running out of registers.
It may be an idea to check how many lights are on the current scene, and only render with up to the (13) (12+ the original one in the example) closest to the camera ones at any given time, or do multiple renders for the excess lights?

The exact error is:
THREE.WebGLProgram: shader error: 0 gl.VALIDATE_STATUS false gl.getProgramInfoLog Fragment shader sampler count exceeds MAX_TEXTURE_IMAGE_UNITS (16).

...

Three.js version
  • Dev
  • r75
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • Linux
  • Android
  • IOS
Hardware Requirements (graphics card, VR Device, ...)
@bhouston
Copy link
Contributor

See: #7060 for a potential solution.

@Nefsen402
Copy link

The exact issue you are suffering from is out of your power and even out of the power of the development team. There is nothing you can do in order to fix the problem unless you do some crazy atlas texture map that holds all the shadow information for all the lights. Even if you have a graphics card that has a very sophisticated glsl compiler where you can make a program that actually does that, performance is just going to make the whole effort pointless.

One thing you can do is to take advantage of the limitations of the human brain where it has a hard time seeing detail in some situations but you can almost instantly see something missing in other situations. On the dim lights that don't light up a lot of the space, just ditch the shadows and no one will probably notice any of the shadows missing. Only add shadows to lights that are very bright and light up a large amount of objects and cast a lot of shadows. Just play around with the values and see what looks good.

Another thing you can do is if you have a lot of lights that are spaced out very far from the camera, there is no need to render them because that specific light will not effect the local space (where the camera is).

A last ditch effort would be to remove shadows from all the lights, it might look like there is detail missing from the scene but depending on what you are trying to make, it might still be fine and playable.

@jespertheend
Copy link
Contributor

Is there any way to detect when there are too many lights in the scene and disable some if needed?

@mrdoob mrdoob closed this as completed Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants