How to have shadows influenced by many lights

I’ve made an decision to share my code with the community.
First of all - this is a CUSTOM, it was made just to meet my own specific needs, so in some other environment it may look just ugly. It works ONLY with PointLights.

The shadows in JME are cast by the light and ignores the presence of other lights. In the result we may have a shadow just next to another light source. The trick is to pass nearest (in my solution it is 6) lights to the PostShadow pass and light up the shadows that are close to these light sources.

Step one - the renderer:

In my solution all lights are placed in one Node, that node needs to be passed to MultiPointLightShadowRenderer. I don’t know if it is an optimal way, or maybe it’s better to get these lights in some other way. 6 are chosen and passed into the shader, the selection is made only by their x,z coordinates (again, it’s a custom).

Step two - the material definition:

All is made only for GLSL150.

Step three - the shader:
ShadowsMS15.glsllib: (because I just don’t remember if I made something in this file)

How it looks?

There is still ‘something’ wrong, sometimes the FPS is falling down, the formula needs to be tuned up…
So, if you want to use it, then use it under one condition: you’ll post here all your fixes and upgrades.

EDIT: shaders are cleaned, most of calculations are moved to .vert

1 Like