Camera FOV is changed by WaterRenderPass

Hello. Here is a problem that occurs if you set your camera fov to anything but 45

Momoko_Fan said:

I guess the Water pass is not copying the camera settings correctly, should be easy to fix.


Glad to hear it! :)

I tried setting a 55

I guess the Water pass is not copying the camera settings correctly, should be easy to fix.

It seems the problem is in the projection grid. Setting a camera having FOV equal to scene camera FOV in ProjectedGrid.java, line 200, method update(), the water seems in place:



But:


  • How can I know in update() method what is the fov of the scene camera? (scene camera is referenced by ProjectGrid attribute cam)

  • Notice the empty spaces at the borders of the grid. How do I make the grid a little bigger?



I hope someone has an idea of this. Meanwhile, I've switched to 45

the projected grid should use the methods from projectedtextureutil (or do similar to them) to restore the matrices to their previous values, not to screw things up…then it wouldnt have to restore the matrix to a fov 45 like it does…in addition it should have a better way of creating a projection matrix for the grid that are always 10 degrees or so higher than the camera fov, to make sure the grid edges is not seen in view…



i'll see when i can find time to fix it

Thank you for a job well done, MrCoder! :slight_smile:

well if i had done the job well the first time we wouldnt have this issue S  XD


Hello,

I think there is a problem with the method used to compute the projection matrix in the ProjectedGrid class (and in ProjectedTextureUtil) :

float h = FastMath.tan( fovY * FastMath.DEG_TO_RAD ) * near * .5f;



should be:

float h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near;



There was the same issue in the AbstractCamera (http://www.jmonkeyengine.com/jmeforum/index.php?topic=6531.0).

Also, in the update() method, the camera projection is computed using the camera FOV + 10

I'll get to fixing this up now. The fov+10 is to make sure the edges of the water is not seen due to height changes in the mesh(with flat water plane it wouldnt be an issue).



Thanks for the input!

Fixed and checked into jME 2.0