Using MultiTexturing produces less detail

Basing my stuff on the flagTut code for adding detail textures to terrain meshes. I am using a quad rather than a terrain mesh, but other than the DetailTexture call, it seems similar.



When applied as single textures in the stack, both textures render fine. But when combined, my quad just turns into a single color. If I animate the one of the textures, the color of the quad changes as if something is happening, so they are interacting somehow. I don't know anything about OpenGL texture compositing, I just cut-n-pasted, but I know basic color math for 2D compositing such as over and under.

Is there some flag I have to set that forces better interpolation? Maybe it is just averaging the verts of my quad?

Here's the code. It seems simple enough.

red.png is a 24bit 256x256 image. oceancolor.png is a 1024x1024 24bit png. both made in photoshop, checked in the gimp, but I don;t know if I trust that they are really 24bit, but they render fine on their own.


        Quad sea = new Quad("sea", horizU, horizU);
        sea.setLocalRotation( new Quaternion(new float[] {FastMath.DEG_TO_RAD*90f,0f,0f} ) );
        sea.setLocalTranslation(new Vector3f(horizU/2.f,0,horizU/2.f) );
       
       
        // assign the texture to the terrain
        TextureState ts = display.getRenderer().createTextureState();
        Texture t1 = TextureManager.loadTexture(
                BASEPATH+"res/oceancolor.png",
                Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR);
       
       
        //load a detail texture and set the combine modes for the two terrain textures.
        rippleTexture = TextureManager.loadTexture(
                BASEPATH+"res/red.png",
                Texture.MM_LINEAR_LINEAR,
                Texture.FM_LINEAR);
       
        //ts.setTexture(rippleTexture, 0);
        //ts.setTexture(t1, 1);
       
//also tried the other way
        ts.setTexture(rippleTexture, 1);
        ts.setTexture(t1, 0);

        rippleTexture.setScale(new Vector3f(24,24,24));
        rippleTexture.setTranslation(new Vector3f(0,0,0));
        rippleTexture.setWrap(Texture.WM_WRAP_S_WRAP_T);
       
        t1.setApply(Texture.AM_COMBINE);
        t1.setCombineFuncRGB(Texture.ACF_MODULATE);
        t1.setCombineSrc0RGB(Texture.ACS_TEXTURE);
        t1.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
        t1.setCombineSrc1RGB(Texture.ACS_PRIMARY_COLOR);
        t1.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
        t1.setCombineScaleRGB(1.0f);

        rippleTexture.setApply(Texture.AM_COMBINE);
        rippleTexture.setCombineFuncRGB(Texture.ACF_ADD_SIGNED);
        rippleTexture.setCombineSrc0RGB(Texture.ACS_TEXTURE);
        rippleTexture.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
        rippleTexture.setCombineSrc1RGB(Texture.ACS_PREVIOUS);
        rippleTexture.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
        rippleTexture.setCombineScaleRGB(1.0f);
       
        sea.setRenderState(ts);
       
        sea.setModelBound(new BoundingBox());
        sea.updateModelBound();
       
        scene.attachChild(sea);

The initial problem is that you need texture coordinates for the 2nd texture channel.  You can simply copy the texture coords from the 1st channel like so:


sea.copyTextureCoords(0, 1);



I'm not in a good position to check your combine settings, so you may need to make changes there too.  If so, have a look at TestMultitexture for a good example of what you are doing (albeit, on a cube)
I am using a quad rather than a terrain mesh, but other than the DetailTexture call, it seems similar.


you said it yourself...that's exactly what the detailtexture method does, sets up the texturecoords for the second layer...

I'll give copying the coords a try - I misunderstood DetailTexture, I thought it was a convenience function for setting the texture scaling. I'll check the  TestMultitexture for examples too.