Shadow questions

Hi,

I know that JME can render shadows, but as far as I know, it can only render directional shadows, which should me manually aligned with the directional light that illuminates the scene. Shadows are also just simple transparent black shapes.

I wonder if it would be possible to create a system that can automatically render shadows for every light in the scene, for directional lights, but also for point lights and spot lights (Not ambient lights for obvious reasons). Looking at the fps of my game, modern hardware should be able to do this at a fast enough speed for use in games (as long as you don’t use too many lights, or use point lights with a short range as shadows can be ignored for faces out of the range of lights). Is this possible in JME?

The second thing I wonder is if it is possible to not make shadows render transparent black shapes, but that the shadows are used as input for the fragment shaders, so that with per-pixel lighting calculations if a pixel is in the shadow of a light, that light can be ignored in the fragment shader, acting as if the light was blocked. This would allow a lot more realistic shadows and lighting. However, I don’t know if this is even possible on current graphic cards, and if it’s possible, then I don’t know how slow it will be, trough the slowdown might not be that bad considering you have to do less lighting calculations.

I just want to know if those two things are possible in JME in a way that they can be used in games. And if it’s possible, I could use some documentation about how shadows work, how I can use those as input in fragment shaders and how to implement this all into JME.

The shadow renderers in jME can render shadows for all light types. @nehon added support for the other lights in a fairly recent update. It is certainly possible to have shadows for all lights in a scene, but it is going to be slow since “all” geometry has to be rendered multiple times… I think jME is only doing shadow camera frustum culling for spatials and not culling by light range as you mentioned, there are however work being done in the lighting-department (I look at you issue 510).

Doing shadow mapping as you suggest, render shadow maps and use them as input to the lighting shaders is certainly possible and is a common way of render shadows. jME is deferring shadowing to a separate pass, which is a bit easier to maintain I guess (the lighting shader is kind of complex as is). I can not say why it is implemented like it is now, but some of the devs might give us an explanation =)

What @kwando said, but just to confirm (or un confirm), for shadows there is some culling performed with the light range/radius to render the shadow maps.

As for feeding the lighting shader with the shadow maps, there is no way to do it easily right now.
You have to modify the shadowRenderer and the lighting material.