Texture settings/properties on higher texture units

Hmm. I remember having experienced texture oddities regarding mipmap settings on higher texture units a while ago. That might well have been my fault. But this time, I suspect it's a bug either in my graphics card drivers, or maybe the Texture class…


    protected void simpleInitGame() {
        String shader =
            "uniform sampler2D tex0, tex1, tex2, tex3, tex4;" +
            " void main(){" +
                "vec2 tc0 = vec2(gl_TexCoord[1].x, gl_TexCoord[1].y);" +
                "vec2 tc1 = vec2(gl_TexCoord[0].x, gl_TexCoord[0].y);" +
                "vec4 result = texture2D(tex0,tc0);" +
                "vec4 col0 = texture2D(tex1, tc0);" +
                "vec4 alp0= texture2D(tex2, tc1);" +
                "result = mix(result, col0, alp0.r);" +
                "vec4 col1 = texture2D(tex3, tc0);" +
                "vec4 alp1= texture2D(tex4, tc1);" +
                "result = mix(result, col1, alp1.r);" +
                "gl_FragColor = result * gl_Color;" +
        GLSLShaderObjectsState so = display.getRenderer().createGLSLShaderObjectsState();
        so.load(null, shader);
        so.setUniform("tex0", 0);
        so.setUniform("tex1", 1);
        so.setUniform("tex2", 2);
        so.setUniform("tex3", 3);
        so.setUniform("tex4", 4);
        Quad mesh = new Quad("mesh", 10, 10);
        mesh.copyTextureCoords(0, 0, 1);
        TextureState ts = display.getRenderer().createTextureState();
        Texture t0 = TextureManager.loadTexture(
                Texture.MM_LINEAR_LINEAR, Texture.FM_NEAREST);
        ts.setTexture(t0, 0);
        Texture t1 = TextureManager.loadTexture(
                Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR);
        ts.setTexture(t1, 1);
        Texture t2 = TextureManager.loadTexture(
                Texture.MM_LINEAR_LINEAR, Texture.FM_NEAREST, 0, true);
        ts.setTexture(t2, 2);
        Texture t3 = TextureManager.loadTexture(
                Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR);
        ts.setTexture(t3, 3);
        Texture t4 = TextureManager.loadTexture(
                Texture.MM_LINEAR_LINEAR, Texture.FM_NEAREST, 0, false);
        ts.setTexture(t4, 4);

Yields the following result on my geForce 7400FX(mobile):

Note that the upper white pixels (it's an arrow, actually), are applied both sharp (FM_NEAREST), and clamped to the edge. (Yes, FM_NEAREST implies that, but it's also the case if i set FM_LINEAR)
The lower arrow, however, while applied with exactly the same settings (it's the "test.PNG" texture in texture unit 4), seems to use FM_LINEAR as well as WM_WRAP_S_WRAP_T. What's going on here? Is this my just punishment for tooling with glsl of which I know so little, or could it be actually a bug? If so, where? jME, lwjgl, graphics driver?
Could anybody please try the code, and tell me if they experience the same symptoms? All you need is the provided simpleInitGame() method, dropped into your everyday SimpleGame template :)

This is because of a limitation in LWJGLTextureState.  It currently only sets texture params on texture units that are < the reported # of fixed texture units.  I moved applyFilter outside of this and it worked fine…  I need to research which params are appropriate to set for units > fixed texture limit (unless someone here already knows the answer?)

Wow, that's the same incredible response time from the pre-NCsoft era :slight_smile: I hope that's a good sign though! Thank you for the answer, now I know there's a remedy to my troubles.

I've been starting to feel the same way…to even be manageable I feel like I have to check every few hours or it's just a scary number. :o

It's not so much NC as it is the deluge of traffic these days.  It's gotten so that I really don't have time to read every posting. :frowning:

Indeed, the "unread posts" page quickly gets intimidating. Lots of new people around in the last few weeks, if this is a trend, it might be reasonable to think of ways to keep the form manageable… I'll start a new thread to gather ideas for that. Here it is:


btw, I've checked in a change to the texturestate to go ahead and set the various texture properties on used textures in tex units that are > totalFixed but < totalMax.  See description in cvs commit notes.

Thanks, that works for me!