Author Topic: ShadowHelper - shadows cast close to receiver  (Read 418 times)

Offline dcfingerprint

  • byte
  • *
  • Posts: 7
    • View Profile
ShadowHelper - shadows cast close to receiver
« on: October 27, 2016, 09:53:33 pm »
Hi there,

Been trying out ShadowHelper in the new JPCT-AE along with some animated characters. 
Generally works great!  However, I have noticed some artifacts where shadows do not appear to render properly on the receiver when the casting object (in this case a bones character) is very close. 

In particular, you can see in the images below, the feet of the characters result in a "hole" in the shadow when the feet are near or on the floor.   I've tried experimenting with raising the object further up off the floor - and then it looks OK at some point (no "holes"), however then the scene of course doesn't look right since the character appears floating above the floor, instead of standing on it. 

All objects/meshes from the character are added as casters, and the floor is the single receiver.

Code: [Select]
                ShadowHelper.setShadowMode(GLSLShadowInjector.PCF_FILTERED_SHADOWS);

                Projector projector = new Projector();
                sh = new ShadowHelper(mRenderer.mFrameBuffer, projector, 1024);

                projector.setClippingPlanes(1f, 1000f);
                projector.setFOVLimits(0, 999);
                float fov = projector.convertDEGAngleIntoFOV((float) fieldOfView);
                projector.setFOV(fov);
                projector.setYFOV(fov);

                projector.setPosition(sv);
                projector.lookAt(caster.getTransformedCenter());

                sh.setLightSource(projector);

                int intColor = Utils.parseColor(shadowColor);
                int red = Color.red(intColor);
                int green = Color.green(intColor);
                int blue = Color.blue(intColor);
                sh.setAmbientLight(new RGBColor(red, green, blue));
                sh.addCaster(caster);

                AnimatedGroup group = getGroup(casterName);
                if (group != null) {
                    for (Animated3D a : group) {
                        sh.addCaster(a);
                    }
                }

                sh.addReceiver(receiver);
Any ideas for config or anything else I may be doing wrong?  Example image attached.

Thanks!

Offline dcfingerprint

  • byte
  • *
  • Posts: 7
    • View Profile
Re: ShadowHelper - shadows cast close to receiver
« Reply #1 on: October 27, 2016, 11:06:53 pm »
More examples attached.  See area around foot nearest floor.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: ShadowHelper - shadows cast close to receiver
« Reply #2 on: October 27, 2016, 11:10:41 pm »
That's caused by a bias that's applied to the depth to prevent other artifacts. You can play around with it by using the ShadowHelper constructor that actually takes the bias as an additional parameter. You might want to try to change the culling mode of the ShadowHelper as well to see if that does any good.
« Last Edit: October 28, 2016, 08:27:26 am by EgonOlsen »

Offline dcfingerprint

  • byte
  • *
  • Posts: 7
    • View Profile
Re: ShadowHelper - shadows cast close to receiver
« Reply #3 on: October 28, 2016, 01:48:45 am »
Thanks!  A combination of reducing the bias and using setCullingMode(false) addressed the issue for this case.   Much appreciated.