Open fgnm opened 3 years ago
I've finally found the reason of this bug, and it's a my mistake plus a missing warning in Box2DLights docs. In my scenario diffuse lights can be enabled and disabled at runtime, this causes the issue because blurShader
depends on RayHandler.isDiffuse
value:
https://github.com/libgdx/box2dlights/blob/29a84c7d5cbcd183049e7d62c134f6ad9c842b7b/src/shaders/Gaussian.java#L13
This shader is created only once, in the constructor of LightMap
:
https://github.com/libgdx/box2dlights/blob/29a84c7d5cbcd183049e7d62c134f6ad9c842b7b/src/box2dLight/LightMap.java#L130
So if I try to change RayHandler.isDiffuse
after new RayHandler(world)
, shaders are messed up, on some GPUs works, on others not. So to fix this issue a possible workaround could be recreate the LightMap
object when isDiffuse
changes, in order to do that resizeFBO()
function could be called.
Changing RayHandler.isDiffuse
might not be a common situation, that's why this workaround could be enough without modify anything in box2dLights, so if this is not relevant please feel free to close this issue.
Thanks
I've noticed that on some hardware configurations Lights are not rendered when
RayHandler.useDiffuseLight(false);
and blur is enabled. This is what happens on the same laptop running the same code both on IGPU HD Graphics 620 and external Nividia GeForce MX150:MX150 with
RayHandler.useDiffuseLight(false);
andblurNum = 3
MX150 with
RayHandler.useDiffuseLight(false);
andblurNum = 0
IGPU HD Graphics 620 with
RayHandler.useDiffuseLight(false);
andblurNum = 3
Same withblurNum = 0
When
RayHandler.useDiffuseLight(true);
everything works as expected.I've noticed also that on OnePlus 6T (Adreno 630) I've got the same result that happens on MX150.