Only show Shadows of an Object

Hello everybody,

I'm new to jMonkeyEngine and I'm about to code my first application. While playing around with jme and the shadowrenderer I tried to figure out how to only render the shadows, but not the objects that cast them. That's what I need for my project so I'd like to ask you if you have an idea how that could work. To be precice: I have a wall and a few boxes infront of this wall. I have a point light which is located between the kamera and the floating boxes, so that the boxes cast shadows on the wall. I now want the boxes to be invisible, but I still want the shadows to be seen on the wall.

Thanks a lot for your answers.


PS: I was wondering if that effect can be achieved by using the alphastate renderstate. But I can't quite get the hang of the blending modes there…

You could choose not to attach the objects which are casting the shadows to the root node, this should keep from rendering them. I'm not sure of your setup. I think you could just add them as occluders to the shadow pass and thats it. Have you tried that?

That was the first thing I tried. But if you don't connect the the objects to the root node, the shadow also doesn't seem to be rendered… But thanks anyway for quick suggestion.

I'll try some stuff when I get off work(3hrs), unless someone knows how before then.

Thanks a lot.

In the meantime I have another question about shadows. The Spotlight I use doesn't seem to cast any shadows. If I use a PointLight instead there are shadows. Kind of strange because SpotLight subclasses PointLight… Anybody know anything about this? And is there a way to change the brightness of a PointLight? It seems I need a SpotLight to be able to change the strength of the light.

Thanks again in advance for your help.

Btw. I'm using a cvs version of jme which is about 4 weeks old.

The Dude said:

Btw. I'm using a cvs version of jme which is about 4 weeks old.

A lot of new stuff went in recently so I'd certainly recommend updating.

As for your problem, isn't the standard way of doing shadows to use a lower poly version of the model to cast the shadows?  Therefore having to normally render the model to make it cast a shadow seems like a major oversight, which frankly I don't see the Dev's making  :)

So it must be possible, as for how to do it; I got no clue  :P

- Chris

You give us too much credit :wink:

Still, yes, it is certainly possible.  Just make sure your non-rendering occluder is being given the LightState with the shadow casting light(s).  That is how the shadow pass knows the occluder should cast shadows for that particular light.  With the way self shadowing works, it looks a little funny in mid air where the caster should be…  but it's possible that is a bug in shadows regarding end caps.

Ok thanks. I’ve got invisible occluders now that cast shadows. But there’s a new problem now. In my scene I have, in this order, along the z-achses my camera, the light, the occluder and right at the end the box where the shadow falls. The problem now is, that where the occluder should be the shadow is not rendered (See attached image). Is there a way of making the shadow renderer render that area as well?

That's what I was refering to at the end of my last post.

OK I see. I'll probably have to do quite a bit of coding then.