Hi,
I have got different Problems with shadows and transparency, for example:
http://img6.imagebanana.com/img/gg9lyvzj/shadow.jpg
Is there a way to fix that a shadow can be seen on a transparent texture?
Besides I added a UI Picture which shows a ViewPort with a transparent background to the screen and than all shadows behind this picture were removed. (So I used nifty and now everything works fine)
place your tree in the translucent bucket instead of the transparent bucket
I use the PssmShadowRenderer and changing the bucket does not have an effect.
Same Problem. Is there no possibility that a tree can cast and receive shadows?
[java]
teaGeom.setQueueBucket(Bucket.Translucent);
teaGeom.setShadowMode(ShadowMode.CastAndReceive);
[/java]
It makes the tree receive it’s own shadows, but if you look through the leaves from above, the floor doesn’t receive a shadow anymore. I don’t think this problem is easily solvable.
Edit: It works like below, but then there’s a problem with the fire (transparent vs. translucent vs. geometry sorting?).
[java]
geom.setQueueBucket(Bucket.Transparent);
teaGeom.setQueueBucket(Bucket.Translucent);
teaGeom.setShadowMode(ShadowMode.CastAndReceive);
[/java]
Are you using the FilterPostProcessor? if you do you have to add a translucentBucketFilter at the end of your filter stack in order this to work.
If this does not work post some code so we an look into it
I refer to TestTransparentShadow.java. The fire is a ParticleEmitter. If I play around with the shadow mode and buckets of the geometry (tree, floor, fire), there’s always at least one thing that looks ugly. Is correct self shadowing of the tree while also seeing the remaining shadow in the floor possible?
Wait i totally misled you…
Forget about the translucent bucket.
You have to set the alphaDiscardThreshold parameter of your leaves material to something above 0. 0.1 or 0.2 should work
look at leaves.j3m material used for the transparent shadows on the tree
http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/test-data/Models/Tree/Leaves.j3m
sorry about the confusion
You did not activate self shadowing (“teaGeom.setShadowMode(ShadowMode.CastAndReceive);”).
[java]
Spatial teaGeom = assetManager.loadModel(“Models/Tree/Tree.mesh.j3o”);
Spatial leaves = ((Node)teaGeom).getChild(“Tree-geom-2”);
Material leavesMat = assetManager.loadMaterial(“Models/Tree/Leaves.j3m”);
leavesMat.setFloat(“AlphaDiscardThreshold”, 0.15f); // <<< ???
leaves.setMaterial(leavesMat);
teaGeom.setQueueBucket(Bucket.Transparent);
teaGeom.setShadowMode(ShadowMode.CastAndReceive); // <<<
[/java]
Guys, y' know…that…that…it doesn't work for me. I gotta have more cowbell!
I'll leave it to the OP to find out if and how correct self shadowing works in this example. But I'd be interested in the solution.
Update: I have set the imagen in the correct way.
If I change teaGeom.setShadowMode(ShadowMode.CastAndReceive); to teaGeom.setShadowMode(ShadowMode.Cast); on TestTransparentShadow, I get the same result that @survivor mentions:
teaGeom.setShadowMode(ShadowMode.CastAndReceive);
teaGeom.setShadowMode(ShadowMode.Cast);
ShadowMode.Cast
Hope this help
I think you mean it the other way round (pic1 = Cast, pic2 = CastAndReceive).
@survivor: Yes, you are right! Sorry! I will fix that.
Also, if you set the shadowMode to CastAndReceive and move the camera around the tree, you will see that from one side of a leaf (displayed as a plane), “transparency” is working fine, but for the other side, the “transparecy” is wrong. The side of the plane that is wrong is the side that receive the shadow.
Guys you’re killing me…
This transparency thing is hardcore…
maybe the problem is that the post shadow material does not discard the transparent pixels…I’ll look into it…
What’s new? Everytime i test my application I see the ugly trees and every update I hope it will contain the fix.