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:
MyAbstractShadowRenderer: http://pastebin.com/cZTygfzV
MultiPointLightShadowRenderer: http://pastebin.com/gD2p8fhR

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:
LightingMS.j3md: http://pastebin.com/hsZ31ury

All is made only for GLSL150.

Step three - the shader:
PostShadowMS.j3md: http://pastebin.com/Nr97uS4h
PostShadowMS.vert: http://pastebin.com/DaARYeez
PostShadowMS.frag: http://pastebin.com/ewQ6pW8z
ShadowsMS15.glsllib: http://pastebin.com/dApM7xzw (because I just don’t remember if I made something in this file)

How it looks?
http://postimg.org/image/yl0ks0tbd/
http://postimg.org/image/iupihh5av/
http://postimg.org/image/oxk2h32ol/

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

2 Likes