(solved) Strange quad texture problem

My viking boat racing game has multiple quality levels for water, the highest one using the fabulous projected grid water, and the lowest just setting up a large quad with a moving alpha texture on top.



This low quality water needs to be the be-all solution for low end computers that can’t do fancy shader water. It looks good and runs like you’d expect on my machine:







My laptop has a Geforce8600m, and of course, this water setting is meant for machines with low-end or integrated video cards. Unfortunately, the two other machines I’ve tried the game out on do not display this simple quad water correctly. The water for them has a white “sheen” most of the time and will occasionally “snap” into the correct texture color and brightness, and then snap back into this strange white-overblown mode. The texture is still visible and alpha is working fine, it just all looks white instead of blue!



It looks like this:





Here is the code I’m using to set this quad up. I add a point light to the water’s renderstate because I had problems with it being too dark before. I have tried not adding that light and the white-water problem still remains.


waterQuad.setLocalTranslation(0f, waterPlaneLevel, 0f);
          waterQuad.setLocalScale(10000f);
          Matrix3f rotMatrix = new Matrix3f();
           rotMatrix.fromAngleAxis(3*FastMath.PI/2, new Vector3f(1,0,0)); //y-axis
           waterQuad.setLocalRotation(rotMatrix);
          
          TextureState waterTS = display.getRenderer().createTextureState();
           waterTS.setEnabled(true);
           URL waterTextureFile = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, "water1.png");
           waterTexture = TextureManager.loadTexture(waterTextureFile,Texture.MM_LINEAR_LINEAR,Texture.FM_LINEAR);
           waterTexture.setWrap(Texture.WM_WRAP_S_WRAP_T);
           waterTexture.setScale(new Vector3f(60f,60f,0));
           waterTexture.setTranslation(new Vector3f(0f,0,0));
           waterTS.setTexture(waterTexture);
           waterQuad.setRenderState(waterTS);
          
           // set alphastate
           AlphaState as = display.getRenderer().createAlphaState();
          as.setBlendEnabled(true);
          as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
          as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
          as.setTestEnabled(true);
          as.setTestFunction(AlphaState.TF_GREATER);
            waterQuad.setRenderState(as);
           
           
            // set up special water light
            PointLight waterLight = new PointLight();
            waterLight.setEnabled(true);
            waterLight.setLocation(new Vector3f(0f,100f,0f));
            waterLight.setAmbient(new ColorRGBA(1.0f, 0.5f, 1.0f, 1.0f));
            //waterLight.setAttenuate(false);
        
            LightState waterLightState = display.getRenderer().createLightState();
            waterLightState.setEnabled(true);
            waterLightState.attach(waterLight);
            waterQuad.setRenderState(waterLightState);
           
            waterQuad.updateRenderState();
            waterQuad.updateGeometricState(0, true);



Here is what I do to the quad's texture during SimpleUpdate()

 else if(waterQuality == 1){
           
           //float waterTextureX = waterTexture.getTranslation().x;
           float waterTextureY = waterTexture.getTranslation().y;
           waterTextureY += .0002;
           // reset so float value never becomes too huge
           if(waterTextureY > 1){
              waterTextureY = 0;
           }
           waterTexture.setTranslation(new Vector3f(0f,waterTextureY,0f));
        }



As always, I really appreciate your help!

Also, if anyone has example code that generates really simple quad water that works well on low-end machines, please let me know! Thanks!

- John

No, I haven't messed with material states at all in jme yet, so the quad I'm working with has whatever the "default" is. I'll check it out and see if its the specular that's doing it.

This might not be directly related to your question, but I think the water already has a fallback to a transparent texture. Try running flat water (not the projected water) on older cards.

I think the water already has a fallback to a transparent texture. Try running flat water (not the projected water) on older cards.


So, the strange thing is that one of the computers I tried the simpleQuadWater on did this same "white sheen" thing that its doing with my quad water. Its one of the reasons I went and made my own quad water (which of course seems to have the same problem ;) )

Do you know if there is an easy way to force the WaterRenderPass to use the fallback option? Some machines that can display the fancy water run it pretty slowly, so I want to make sure they can turn it off if they want.

Thanks!

Have you tried setting a materialstate on it to go along with your lighting?  You could then tweak a few things like specular and diffuse colors.

Solved, sorta:



I was just making a huge quad to make sure that  it gave enough water for my level. It was a (1,1) quad scaled with a value of 10,000. huge



The smaller the quad, the more normal it rendered on crappy computers. I've settled now for a 3,500 scaled quad and can get that number down even further with some tweaking.



I played around with a materialState and it had no effect as long as the quad was gianormous.

Try to create a quad without scaling, e.g using the constructor Quad(String,int,int) and specifying the size there.