Several Issues regarding Projected Grid Water

I am using the projected grid water that was posted here:

http://hub.jmonkeyengine.org/forum/topic/projectedgrid-and-legacy-water-effects-from-jme-2/

To create some water for my game. However after complementing everything i have come across several issues.
Here is a video that outlines some of my issues since its easier to explain it that way:

You may read the description for more info or read below:

> Firstly you can see that the reflection is much to large, both for the Red Object and the sky.

> Secondly, you can see that the normal maps is returning a strange white look ontop of the water, instead of small wave shadows.

> And lastly, when i rotate the camera, the water shape seems to change.

1 Like

I have the same exact issues as you. But i’m not an expert on that topic so i couldn’t fix it.

1 Like

Hmmm. I’ve tried everything. I’ve looked where the cam object is referenced. For the last issue where everything changes when i rotate the camera. It is referenced a lot, so perhaps it changes something when the cam is rotated by accident. Ive also looked at the reflection code, but i cant find anything there :confused: As for the normals, i think this approach uses them as a specular sort of thing. But its not white enough.

The issue is most definitely in the Projected Grid Class:

I’ve narrowed it down to this section of the code:
I think the issue originates from here somewhere:

camloc.set(cam.getLocation());
camdir.set(cam.getDirection());

   height = cam.getLocation().getY();

    Camera camera = cam;
    ProjectedTextureUtil.camera = camera.clone();
    viewPortWidth = camera.getWidth();
    viewPortHeight = camera.getHeight();

    modelViewMatrix.set(camera.getViewMatrix().clone());
    modelViewMatrix.transposeLocal();

    projectionMatrix.set(camera.getProjectionMatrix().clone());
    projectionMatrix.transposeLocal();

    modelViewProjectionInverse.set(modelViewMatrix).multLocal(projectionMatrix);
    modelViewProjectionInverse.invertLocal();

    source.set(0.5f, 0.5f);
    getWorldIntersection(height, source, modelViewProjectionInverse, pointFinal);

    pointFinal.multLocal(1.0f / pointFinal.getW());
    realPoint.set(pointFinal.getX(), pointFinal.getY(), pointFinal.getZ());
    projectorLoc.set(cam.getLocation());
    realPoint.set(projectorLoc).addLocal(cam.getDirection());

I found the issue where it deforms everything when you rotate. Th eissue is caused by this line:

realPoint.set(projectorLoc).addLocal(cam.getDirection());

I think. This: .addLocal(cam.getDirection() causes the mesh to rotate with the camera, but when it roatetes with the camera, it somehow changes its appearance along the grid.

Check out http://hub.jmonkeyengine.org/forum/topic/projectedgrid-and-legacy-water-effects-from-jme-2/ for solution to the reflection issue.