Shadow and Transparency (16 posts)

  • Profile picture of ogerlord ogerlord7p said 3 months, 1 week ago:

    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)

  • Profile picture of nehon nehon590p said 3 months, 1 week ago:

    place your tree in the translucent bucket instead of the transparent bucket

  • Profile picture of ogerlord ogerlord7p said 3 months, 1 week ago:

    I use the PssmShadowRenderer and changing the bucket does not have an effect.

  • Profile picture of survivor survivor106p said 3 months, 1 week ago:

    Check out TestTransparentShadow.java from JME3 Tests.

  • Profile picture of ogerlord ogerlord7p said 3 months, 1 week ago:

    Same Problem. Is there no possibility that a tree can cast and receive shadows?

  • Profile picture of survivor survivor106p said 3 months, 1 week ago:
       teaGeom.setQueueBucket(Bucket.Translucent);
       teaGeom.setShadowMode(ShadowMode.CastAndReceive);
    

    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?).

       geom.setQueueBucket(Bucket.Transparent);
       teaGeom.setQueueBucket(Bucket.Translucent);
       teaGeom.setShadowMode(ShadowMode.CastAndReceive);
    
  • Profile picture of nehon nehon590p said 3 months, 1 week ago:

    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

  • Profile picture of survivor survivor106p said 3 months, 1 week ago:

    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?

  • Profile picture of nehon nehon590p said 3 months, 1 week ago:

    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

  • Profile picture of nehon nehon590p said 3 months, 1 week ago:

    @survivor that’s strange i don’t have these issues

    http://i.imgur.com/pSqeR.jpg

  • Profile picture of survivor survivor106p said 3 months, 1 week ago:

    You did not activate self shadowing (“teaGeom.setShadowMode(ShadowMode.CastAndReceive);”).

            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); // <<<
    

    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.

  • Profile picture of H H2p said 3 months, 1 week ago:

    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);
    ShadowMode.CastAndReceive

    teaGeom.setShadowMode(ShadowMode.Cast);
    ShadowMode.Cast

    Hope this help

  • Profile picture of survivor survivor106p said 3 months, 1 week ago:

    I think you mean it the other way round (pic1 = Cast, pic2 = CastAndReceive).

  • Profile picture of H H2p said 3 months, 1 week ago:

    @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.

  • Profile picture of nehon nehon590p said 3 months, 1 week ago:

    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…