www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on March 19, 2026, 07:25:22 AM

Title: Shadow Shader
Post by: AGP on March 19, 2026, 07:25:22 AM
I'd love for you to include this shader in jpct. This is an example of how to call it:
//In the game loop:
           shadows.setCenter(batman.model.get(0).getTransformedCenter());
           shadows.updateShadowMap(theWorld, buffer, camera);
//The setup:
    private void setupShadows() {
       shadows = new ShadowMapper(1024);
       shadows.setLightDirection(new SimpleVector(.2f, .4f, -.3f));

       shadows.setShadowArea(360f);//120f
       shadows.setShadowBias(0.00f);
       shadows.setShadowDarkness(0.50f);
       shadows.setCenter(batman.model.get(0).getTransformedCenter());

       // ALL visible objects must be casters
       for (Object3D part : batman.model)
           shadows.addCaster(part);
       shadows.addCaster(batman.cape);

       for (Object3D part : joker.model)
           shadows.addCaster(part);

       shadows.addCaster(catwoman);

       shadows.addCaster(batmobile.hull);
       shadows.addCaster(grappleTarget);

       shadows.addReceiver(ground);

       for (Object3D obj : cityObjects)
           shadows.addReceiver(obj);
    }
Title: Re: Shadow Shader
Post by: EgonOlsen on March 19, 2026, 01:21:31 PM
Looks a lot like a shader based variant of the ShadowHelper to me. Is it supposed to work like that or is it something different?
Title: Re: Shadow Shader
Post by: AGP on March 19, 2026, 06:31:21 PM
The shadows look better. And it's meant to work like ShadowHelper.
Title: Re: Shadow Shader
Post by: EgonOlsen on March 20, 2026, 02:26:38 PM
Maybe I can combine the two then into one. I never bothered with shader based shadows in the desktop version. The android version of course uses them, but it uses shaders across the board anyway (because OpenGL ES has no fixed function pipeline anymore). But I never ported that over to the desktop.