Transparency and shadows

I used transparency for some models and in billboards which worked fine. Now I tried to add shadows and all models and billboards are opaque. The game is inherited from BaseGame.



It's setup like that: I add a BasicPassManager, a ShadowedRenderPass and a RenderPass. I replaced all the custom renderer.draw(Spatial) with pManager.renderPasses() and added rootNode to ShadowedRenderPass (using add()). Currently only one model is added as an occluder and the shadow works fine. The problem with transparency is with some models and billboards which are children of rootNode. The RenderPass is used for some GUI nodes (JMEDesktop, hud node, etc.).



What do I have to do to keep the transparency on rootNode which worked before I added the pass manager?

Hmm, not sure, but one thing to keep in mind is that shadows can not respect transparent objects/textures, etc.  So you are going to get shadowing on the object all the way to any geometry edges which may have the look of making it opaque (or close to)

The transparent objects are not occluders, they are just attached to the rootNode. I don't (yet) expect correct shadows cast from transparent objects but I would like to keep them the way they were :slight_smile:

Are you using additive shadows?  If so, the scene is being rendered multiple times and blended together, which might also cause the transparency headaches.  You might try setting it to MODULATIVE instead.  (you'll need to set the ambient light color of your shadow casting light to have an alpha that is between 0 and 1 (which determines shadow darknessā€¦)

Bingo! I did what you suggested and now I have working shadows AND transparency on the billboards and models.



Thanks Renanse.

happy to help :slight_smile:

Now I have another problem with shadows:

The occluders (houses in my case) get self-shadowed which is fine generally but it seems to fail roughly in one of two cases. It looks like z-buffer fighting but setting the frustum to a quite narrow range didn't help. The effect is that those parts inside the shadow are rendered lit, shadowed or a mixture of both depending on the camera angle. Even with small camera motions it flickers randomly. I use the settings mentioned above.

It looks like the occluders are rendered twice at the same location - once without shadows and once with shadows.



Is there anything I can do?

are you also rendering them in another pass perhaps?

Sounds right.  I was thinking perhaps you had another RenderPass or something in there.  Have you tried kicking the stencil bits to 8?

I tried that now but I cannot see a significant difference.