PssmShadowRenderer in combination with BitmapText

Hey I’m having a problem with displaying text on the guiNode in combination with a PssmShadowRenderer. When I add a BitmapText to the guiNode the geometries that recieve shadows will have strange boxes of shadows all over them.

This is what it looks like:

However if I add a material to the BitmapText, it all looks good apart from the fact that the text can’t be read:

These are the bits of code I have for the shadows and for the BitmapText:


defaultFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

P1ScoreText = new BitmapText(defaultFont);


P1ScoreText.setLocalTranslation(1, 100, 0);


P1ScoreText.setText(“someText some more text, wow this is a lot of text… nNeed mo’? Here you go! The more the merrier, you know? Now, it’s time to go with the flow! Or like santa says… Ho! Ho! Ho!”);


// Material txtMat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

// txtMat.setColor(“Color”, ColorRGBA.Black);

// P1ScoreText.setMaterial(txtMat);


PssmShadowRenderer bsr = new PssmShadowRenderer(assetManager, 2048, 4);

bsr.setDirection(new Vector3f(-0.1f,-0.2f,-0.1f));



If I set the CullHint on the BitmapText to always, the strange shadow-blocks are also gone… However changing the shadowMode doesn’t help either…

Note: I’m not using Nightly


I really don’t get how this can happen. GuiNode is in another viewport and rendered over the main viewport…

I’d need a testcase…

There are bitmapText in TestPssmShadows and it works fine.

Are you doing something fancy with the viewports?

Btw, that’s not related to your issue, but considering the view angle (and assuming it doesn’t change during play time) you don’t need 4 splits for your shadows. try with 1 split, it should be the same but faster.

Thanks for the fast reply… Well I just made a testcase but it didn’t give me the same problem so it’s probably useless to post it here… Going back to the project where the problem did occur; It also happens when I add this code to the project:

bsr.setShadowZExtend(12f); (Where bsr is the PssmShadowRenderer)

Besides that the only thing I was doing with the viewPort was changing the background color.

About using 4 splits for my shadows - My view angle does change during play, and if I try to use less splits then 4 I can’t see any shadows.

Edit: When both the bsr.setShadowZExtend(12f) and the BitmapText is enabled on the guiNode the problem doesn’t occur when the balls location is < 1/4th of the screen. As soon as it rolls to the right, approx past the left goal-lines, the problem is back again…

Edit2: When I remove the texture of the ball, the shadows are also casted the way they should be…

Ok it’s all a bit strange… I don’t know if the fault is either happening in my laptop or in jME3’s code but I’ve been able to ‘fix’ it with a workaround…

At this moment the fault occurs in my foosball simulation when -all- of the following conditions are true:

  • PssmShadowRenderer.setShadowZExtend(float) has been set -OR- BitmapText has been added to guiNode
  • Ball has a lighting material
  • Ball has a texture (m_DiffuseMap)
  • Ball’s shadowmode is set to CastAndReceive
  • (in case the 2 conditions on the first line are both true) Ball’s position x coördinate is between +/- 1/4th of the field and 4/4th of the field.

    The workaround I’m using right now is simply to set the ball’s shadowmode to Cast only - I could even set it on Receive only instead and then create a second ball that I place inside of the current ball (probably with a slightly smaller scale) and set shadowMode.Cast on this ball.

    Here’s a testcase showing the fault (at least for me) - if it doesn’t show the fault for you, you can try uncommenting the out-commented pieces. For the texture, just place any texture in /assets/Textures and name it Texture.jpg. Here’s the testcase:

    package mygame;


    import com.jme3.font.BitmapFont;

    import com.jme3.font.BitmapText;

    import com.jme3.font.LineWrapMode;

    import com.jme3.light.DirectionalLight;

    import com.jme3.material.Material;

    import com.jme3.math.ColorRGBA;

    import com.jme3.math.Vector3f;

    import com.jme3.renderer.RenderManager;

    import com.jme3.renderer.queue.RenderQueue.ShadowMode;

    import com.jme3.scene.Geometry;

    import com.jme3.scene.shape.Box;

    import com.jme3.shadow.PssmShadowRenderer;

    import com.jme3.system.AppSettings;

    import com.jme3.texture.Texture;

    public class Main extends SimpleApplication {

    public Main()


    AppSettings newSetting = new AppSettings(true);




    newSetting.setResolution(1366, 768);




    public static void main(String[] args) {

    Main app = new Main();




    public void simpleInitApp() {

    Box b = new Box(Vector3f.ZERO, 10, 1, 10);

    Geometry geom = new Geometry(“Box”, b);

    geom.setLocalTranslation(0, -6, -3);

    Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

    mat.setColor(“Color”, ColorRGBA.Blue);




    Box b2 = new Box(Vector3f.ZERO, 10, 1, 10);

    Geometry geom2 = new Geometry(“Box”, b2);

    geom2.setLocalTranslation(0, -1, -3);

    Material mat2 = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);




    DirectionalLight sun = new DirectionalLight();


    sun.setDirection(new Vector3f(-.5f, -.5f, -.5f).normalizeLocal());


    PssmShadowRenderer pssm = new PssmShadowRenderer(assetManager, 2048, 4);

    pssm.setDirection(new Vector3f(-.1f,-.2f,-.1f)); // light direction



    // pssm.setShadowZExtend(120f);

    // Texture tex = assetManager.loadTexture(“Textures/Texture.jpg”);

    // mat2.setTexture(“m_DiffuseMap”, tex);

    // BitmapFont optionsFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

    // BitmapText P1OptionsText = new BitmapText(optionsFont);

    // P1OptionsText.setColor(ColorRGBA.White);

    // P1OptionsText.setLineWrapMode(LineWrapMode.Word);

    // P1OptionsText.setSize(optionsFont.getCharSet().getRenderedSize());

    // P1OptionsText.setLocalTranslation(100, 100, 0);

    // guiNode.attachChild(P1OptionsText);

    // P1OptionsText.setText(“This is the text I’d like to have on my screen…”);

    // P1OptionsText.setSize(24);



    public void simpleUpdate(float tpf) {

    //TODO: add update code



    public void simpleRender(RenderManager rm) {

    //TODO: add render code



    Edit: Adding this in the main method makes the shadows cast the right way, if the out-commented parts are still commented:


1 Like

Thanks for the testcase, i’ll look into it.

I had this problem as well, and could never figure it out. For me though, the problem only existed at certain angles, and only from certain distances from the camera. I hope this gets fixed/figured out!

Ok i looked into it and i don’t have any issue with this test case.

But…according to the code i guess you are using a very old version of JME (you still have the “m_” prefix to material parameters that was removed before beta)

Could you please try to update to RC2 and see i you still have the issue?

1 Like

Hmm yeah I was using the beta, I wonder how I could’ve missed the RC2 version though since I only started programming with jME3 about 6-7 weeks ago o.O However, updating to RC2 didn’t resolve the problem for me. I also tried changing m_DiffuseMap to DiffuseMap but that didn’t do the trick either (quite obvious since it was commented out in first place). At least thanks for the tip to update, this’ll probably be a lot better for my future :slight_smile:

Maybe a driver issue?

1 Like

Updating my driver did fix the problem, however it also made my pc very slow =.= even the testcase won’t run at more then 40fps since the update but that’s between me and my pc - I suppose a format would do the trick :stuck_out_tongue: Thanks for the help!