Hello, I would like to ask about using static point light
Whenever I set the light to static, the light just gone, I try to refresh but it still not showing.
There’s a current issue on this here:
04:48PM - 14 May 20 UTC
This was quite a head-scratcher for me recently.
Marking lights as Static makes
… them not have an effect on the scene at all.
It seems static lights only affect geometry marked static as well.
ok, it’s currently unreolved issue?
is there any workaround for this?
or i have to set to dynamic light for the time being?
Sounds like it was by design that static lights only affect models that are also marked as static.
If your models are not static, then the lights shouldn’t be static for now.
I tried changing my model to dynamic (static unchecked), and use static light, it does not work either.
Btw Directional Light static is working, unlike point light and spot light.
Are you saying that the static light does not fork for you whether the geometry is static or not?
If you are using non static models, lights should be non static too at the moment
I tried some settings
non static mesh + dynamic light = it works
static mesh + dynamic light = it works
non static mesh + static light = does not work
static mesh + static light = it works → This is what I’m looking for… Static lights to works…
I’m trying this on a new project. https://playcanvas.com/editor/scene/1194475
So, currently the key is, if you want to use static light, use static mesh?
Wait… will try on my current project hope it will works…
Still on that new project
it does not work again…
static mesh + static light
I have refresh my page also, but still the light disappeared…
It was prevously worked when I tried wrote my previous comment
Trying in the play mode…
The static light does not appear in the editor but seems to be ligting properly in the play mode…
I confirm that point light and spot light works in static mesh in play mode, but it does not appear in the editor, in both of my project.
I build and see that the static light also works. It just doesn’t show up in the editor.
I assume it is safe to use static light and static mesh, you just don’t see accurate result in the editor for the time being… am I correct?
This is because static lights are currently not working when a scene is destroyed and reloaded. There is an issue open for this here:
Issue with Static Lights - #27 by mvaligursky
Refreshing your editor should bring them back, but even changing away from the scene and back again in the editor will break the static lights. Hopefully, we will see a fix soon.
The longer term goal is to switch to clustered lighting. First version is out already, but does not support shadows … so if you don’t need shadows, you could use this maybe:
02:19PM - 19 Mar 21 UTC
This is an initial implementation of clustered lighting for local lights without
… shadows (omni and spot, with punctual shape - so no area lights). There will be further improvements later to allow these lights to support shadows by rendering them into a shadow atlas. Note that in this implementation, the clustering is done in the World Space instead in more commonly used Camera Space to improve performance, and allow the clustering structure to be used by multiple cameras (for example rendering to texture). It also allows us in the future to avoid rebuilds of this structure if lights don't change).
The difference compared to the current local lights implementation is that while current implementation uses all dynamic lights on all objects in the scene, clustered implementation places these lights into a 3d grid structure with specified size, and when a pixel is rendered, lights it needs are fetched from this 3d grid. Thus it works the best if the overlap of lights is not large. Example being a large level with many local lights with small range in various places inside the level. The test case (see screenshot) replicates this. The level is represented by a large cylinder and many other meshes (spheres and cones), which all get lit by the lights. Both omni and spot lights are separated with low density to minimize amount of lights a pixel needs to use.
_There is a limitation at the moment in that only diffuse part of lighting is evaluated for clustered lights, and specular is not. This will be addressed in the future._
constructor of LayerComposition now takes additional parameter, which is a GraphicsDevice. Not passing this parameter is ok for an application using single instance of Application.
**New API (all private at this point, as it might be subject to change):**
- **WorldClusters.enabled** - enables clustered lighting (disabled by default). Needs to be called before rendering, and cannot be changed after.
- **LayerComposition.clusteredLightingCells** - specifies Vec3 with number of cells of the clustering 3d grid
- **LayerComposition.clusteredLightingMaxLights** - maximum number of lights a cell can stored. Ideally with small overlap of lights this could be set to a small number, for example 8.
**Example of API use:**
// enabled clustered lighting. This is a temporary API and will change in the future
pc.WorldClusters.enabled = true;
// adjust default clusterered lighting parameters to handle many lights:
// 1) subdivide space with lights into this many cells:
app.scene.layers.clusteredLightingCells = new pc.Vec3(12, 16, 12);
// 2) and allow this many lights per cell:
app.scene.layers.clusteredLightingMaxLights = 48;
- some refactor to layer composition in how the shadow casters are updated
- mostly non functional change, apart from processing each layer only one time (slight optimization)
- optimized light management in the layer by using a Set of lights
- refactored ShadowCasters into LightCompositionData (mostly rename)
(on very old Huawei phone and MacBook Pro). Note that this depends on light overlap, grid size and similar and are only representative or "common" expected scenario. This also confirmed minimal negative impact when zero or small number of lights are used.
Also note that API allows to move the cost both ways between CPU and GPU. When you use large number of cells (clusteredLightingCells), CPU update is more costly, but GPU is cheaper as light overlap is more precise. On the other hand it small number of cells is used, CPU update is fast, but GPU needs to use many lights for each pixel.
huawei 0 lights
- clustered: 0.5ms
- normal: 0.5ms
PC 0 lights
- clustered: 0.2ms
- normal: 0.2ms
huawei 5 lights
- clustered: 2.1ms
- normal: 2.8ms
huawei 50 lights
- clustered: 14.6ms
- normal: 36ms
PC 50 lights
- clustered: 3ms
- normal: 32ms
**Example** (link valid when released)
This uses clustered lighting, with a grid size of 12, 16, 12, with the maximum number of lights per cell being 48, and rendering 30 point lights and 16 spot lights. In addition there is one shadowing directional light as well.
![Screen Shot 2021-04-19 at 2 12 13 PM](https://user-images.githubusercontent.com/59932779/115241915-43485400-a119-11eb-88fc-39c70c6a793d.png)
I’ve started on the shadows for this as well, but there are few other things that need to be done before I can finish that, so likely not for few more months:
WIP rendering to shadow atlas for point and spot lights by mvaligursky · Pull Request #3235 · playcanvas/engine · GitHub
So if you just need many lights without shadows, you could use it. See example here:
No, refreshing my editor does not bring my static light back…
I think for the time being, I will use dynamic lights to preview, and before I test play and build, I will change all of my light to static… So far this technique seems to work