Chase camera lighting + anisotropic filtering problem

I have 2 problems at the moment…

First, not massively important as worst case I just program the camera to move myself, but when chase camera is enabled this happens: (above with, below without - I tried to get a similar angle with the chase camera but the problem is visible)


I know the scenes are slightly different but it occurs without any code changes at constantly, it was not caused by being taken at a slightly different time.

flyCam.setEnabled(false);
ChaseCamera chaseCam = new ChaseCamera(cam, playerTeam.players[0].playerNode, inputManager);

Thats all I added and the lighting went mad.

Really important to me though is this anisotropic filtering. Using the info found here:

http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:anisotropic_filtering

I set it up and noticed it does not work on any materials I loaded. It was discussed here:

http://hub.jmonkeyengine.org/t/global-anisotropic-filtering/27054

But I found no solution. I have added a println(); to the code that sets the filtering and only the materials I create in code are triggering it. This is a massive bummer for me I have tonnes of j3m materials I load and some textures look horrible at certain angles.

Does anyone have another way to set the filtering?

I took another shot to try and make the lighting change caused by the chase cam a little clearer


Without the chase cam those odd light patterns do not exist (the triangles coming from the center)

Looks like you are above the roof or something.

Alternately, if you are using normal maps then maybe you need tangents generated… that’s the only other thing that I can think would cause random “lighting” changes as you move.

re: the anisotropy… we can’t see your code so we can’t say why it isn’t affecting all materials. Most likely cause is that you aren’t applying it to all materials.

1 Like

You are right, I never used the tangent generator which I need for chasecam. Thanks.

As for the anisotropy, this is the code I added hoping to get it:

AssetEventListener asl = new AssetEventListener() 
    {
        public void assetLoaded(AssetKey key) 
        {

        }

        public void assetRequested(AssetKey key) 
        {
            if (key.getExtension().equals("PNG") || key.getExtension().equals("jpg") || key.getExtension().equals("dds") || key.getExtension().equals("png")) 
            {
                TextureKey tkey = (TextureKey) key;
                tkey.setAnisotropy(8);
                System.out.println("set anisotropy: "+key.toString());
            }
        }
 
        public void assetDependencyNotFound(AssetKey parentKey, AssetKey dependentAssetKey) 
        {
            
        }
     };
     assetManager.addAssetEventListener(asl);

Taken straight from the wiki, with the println added. I load models and materials:

Material mat = Main.asset.loadMaterial("Materials/Arena/floors/floor.j3m");
floorModel.setMaterial(mat);

I load ~30 textures materials this way, but only get

set anisotropy: Interface/Fonts/Console.png (Flipped)
set anisotropy: Textures/Misc/hangingspotlightglow.PNG

As a printout - the ones for which I load a image not a material. How can I apply it to the materials textures?

NEVER MIND! I managed to solve it with

mat.getTextureParam(“DiffuseMap”).getTextureValue().setAnisotropicFilter(8);

Didn’t know I could do that, thanks for the help!

Er, just a quick side… with JME in full screen my screensaver still comes on (set to 1 minute), is this normal behavior? Doesn’t happen for my other full screen games would prefer it didn’t.

@Momoko_Fan we really need a setting for setting Anisotropic filtering globally…

2 Likes

Wouldnt a global setting already be possible via assetListener?

Linux by chance? At least some other games do the same for me there :stuck_out_tongue:

Not if you load the images through a j3m. that’s the issue @JESTERRRRRR was hitting

Nop windows 7 : /

My game is a simulation type game with little input at times so it comes on pretty much every time my game runs unless I remember to hurl the mouse around

You could try to tell windows using JNA or a powershell command to temporarly disable screensavers, kinda like vlc or mediaplayer does.

Alternatively you try to design a GameElement that requires some manual interaction every now and then.

Or you could try to use the Java robot class to move the mouse every x minutes 1 pixel if no other interaction happened.

1 Like

Which makes me wonder how/why this bypasses normal asset loading. It’s certainly counter-intuitive.

Isn’t it easier to just check if (key instanceof TextureKey)? You might be missing some extensions, like JpEg or something like that.

That’s how I do it.

    @Override
    public void assetRequested(AssetKey key) {
        if (graphicsConfig.getTextureAnisotropy() > 0 && key instanceof TextureKey) {
            final TextureKey textureKey = (TextureKey) key;
            LOGGER.debug("Setting anisotropic filtering to {} for texture {}", graphicsConfig.getTextureAnisotropy(), key.getName());
            textureKey.setAnisotropy(graphicsConfig.getTextureAnisotropy());
        }
    }

GraphicsConfig is my own POJO which holds graphics settings for me which the game saves and loads.