Transparent Quad and shadow

Hi guys,

Still working on getting a modified “forester” inside my project. I made some steps, I can now use the density maps and planting algorithm. I’m slowly getting there… :slight_smile:
I have an issue very similar to the one described here:
http://hub.jmonkeyengine.org/forum/topic/quad-with-alpha-texture-overlapping-shadows/#post-190974

…but it’s not quite the same.

I have transparent quads that display plants and shadows. I want the shadows to be displayed on the quad but only on the opaque area of the quad.

If I set up my material like so:

Material vegeMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
vegeMat.setTexture("DiffuseMap", getAssetManager().loadTexture("Textures/Vegetation/grass.png"));
vegeMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);

I get this:

If I follow the answer of the topic I mentioned:

Material vegeMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
vegeMat.setTexture("DiffuseMap", getAssetManager().loadTexture("Textures/Vegetation/grass.png"));
vegeMat.setFloat("AlphaDiscardThreshold", 0.1f);
vegeMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);

I get this:

What am I missing? :-?

I toyed with other material properties like UseAlpha, setAlphaTest, setAlphaFallOff, etc. I also searched the forum and documentation, but I can’t find an answer. Is that something that was done before? Do I have to modify the lighting mat shaders for this to work (Phew,I hope not…).

Thanks a lot for your help. :slight_smile:

I don’t know in what state the Forester was when it was abandoned, but there are some things to consider for shadows when using a custom material.

Are your trees using the stock lighting shader or a custom one?

Hi nehon!

I’m not using the whole forester, I’m stripping it down and implementing all the stuff one step at a time, modifying it along the way. In this case I am using the normal default lighting shader… Hey wait a minute! I was working on this at work on my lunch time. Now, I’m at home and just launched my project… It works now!?! That is so weird… I guess the video card must be related to this issue. I can’t find any other explanation as to why it would be okay at home and not at work.

Well… Alright then, I guess this is not an issue after all.

Thanks nehon! :slight_smile:

Oh, here is an image of what it looks like at home. (My home computer is much stronger than my work computer, you can see the frame rate isn’t the same at all. Not the same video card either, I guess that was the problem.)