DetailTexture shining without light?

I created a flashlight for players to explore in my game.After adding a detail texture to the terrain,I noticed that I could see the detail texture when the light is off.Is there a way to make the detail texture black when no light is on it?



My terrain building code is based on the code from flag rush.

The problem is in the flag-rush detail texture initialization:

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);
 
        t2.setApply(Texture.AM_COMBINE);
        t2.setCombineFuncRGB(Texture.ACF_ADD_SIGNED);
        t2.setCombineSrc0RGB(Texture.ACS_TEXTURE);
        t2.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
        t2.setCombineSrc1RGB(Texture.ACS_PREVIOUS);
        t2.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
        t2.setCombineScaleRGB(1.0f);


As you can see, the detail texture is added onto the premultiplied color and lighting texture, which means it will be visible when no lighting effects the area. When doing multitexturing with lighting, you must apply the lighting at the last texture unit. This doesn't work all too well in this case since if you place the combining of the detail texture first then you will have to use the texenv_crossbar extension so that you can access textures from the 2nd unit (you don't explicitly use it, it just needs to be available on the video card).
Momoko_Fan said:

The problem is in the flag-rush detail texture initialization:

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);
 
        t2.setApply(Texture.AM_COMBINE);
        t2.setCombineFuncRGB(Texture.ACF_ADD_SIGNED);
        t2.setCombineSrc0RGB(Texture.ACS_TEXTURE);
        t2.setCombineOp0RGB(Texture.ACO_SRC_COLOR);
        t2.setCombineSrc1RGB(Texture.ACS_PREVIOUS);
        t2.setCombineOp1RGB(Texture.ACO_SRC_COLOR);
        t2.setCombineScaleRGB(1.0f);


As you can see, the detail texture is added onto the premultiplied color and lighting texture, which means it will be visible when no lighting effects the area. When doing multitexturing with lighting, you must apply the lighting at the last texture unit. This doesn't work all too well in this case since if you place the combining of the detail texture first then you will have to use the texenv_crossbar extension so that you can access textures from the 2nd unit (you don't explicitly use it, it just needs to be available on the video card).


Is there a example of how to do this?

the red book has alot of texture combine info. check that out.