Finally got my priorities right and ported the waterstuff to jME, putting things like marriage, vacation and my daughter on hold s
Alot of time went into making the watereffect handle arbitrary up axis, using a plane as equation for solving camera vector reflection etc etc. Also did alot of decoupling of the water and the mesh to apply the effect to.
Changes made while i ported:
- The water effect is a stand alone render pass, and has no hardcoded connection to what kind of mesh it uses for rendering
- You register the mesh you want to use as water-surface to the water effect pass. so now you can use a quad or a grid or anything you like with simple changes
- The projected grid is a stand alone trimesh extension, and can be used to whatever you wish, not just water rendering. could be moved to jme's shape package
- The projected grid uses a height generator class to generate it's heights, so you can plugin whatever nice water movement algorithms you wish.
A first try at explaining what's in the cvs checkin at the moment:
jmex.effects.water package:
- WaterRenderPass
The actual renderpass. Renders reflection, refraction and depth maps based on all settings and sets up shaders to use.
- Projected grid
A trimesh implementing parts of the projected grid thesis. A grid that is displaced in projective space based on the camera frustum.
- HeightGenerator / WaterHeightGenerator(sample implementation of the interface)
Returns heights based on x/z coordinates and time. Used by the projected grid to animate/displace the grid.
- ImprovedNoise
Perlin noise implementation by Ken Perlin, used by the sample heightgenerator implementation.
jmetest.effects.water package:
- TestProjectedGrid
Simple test of the projected grid mesh itself
- TestProjectedWater
Test for the waterrenderpass with a projected grid mesh as watersurface
- TestQuadWater
Test for the waterrenderpass with a quad as watersurface. The quad is automatically moved along with the camera to simulate an infinite waterplane.
- TestSimpleQuadWater
Test for the waterrenderpass with a simple quad that uses the z-axis as up vector. To show how to use another plane equation than default y-up.
Basic usage:
- Use a pass-enabled type of program(eg. extend the SimplePassGame)
- Create a WaterRenderPass and add to the pass manager before the main scene renderpass. Choose what type of watershader to use and if you want refraction or not.
- Create the mesh to use as watersurface and register it to the waterrenderpass with setWaterEffectOnSpatial()
- Create and register a node containing all objects that should be reflected/refracted in the water with setReflectedScene()
- Create and register a skybox to the waterrenderpass with setSkybox(). (this will later be extended for skydome usage etc)
- Try out all waterrenderpass settings (or projected grid settings)
Some of the TODO's:
- The watersurface mesh needs to have correctly hardcoded vertices and normals, no rotation/translation of the mesh is allowed. This was done to ease the burden of the shaders but i'll have a go at making a version where you supply a modelmatrix and so on.
- The projected grid i y-axis up only at the moment. This is a limitation of the projected grid mesh and not of the waterrenderpass. There are many things to polish on the grid implementation that will allow for arbitrary up-axis and remove alot of artifacts(also allowing for lower resolution grids)
- Make the water easier to use and understand (and add documentation)
- Extract alot of settings and magic numbers from the shaders so they can be set by the user.
- Add specular lighting
- Make the normalmap and dudvmap used by the water user definable. To allow for other characteristics of the water part from just changing colors etc
- Make a water editor similar to renanse's renparticleeditor
- Find a way to get rid of some surface-object edge artifacts
That's it for the moment. The source will be updated pretty much but i felt it was better to get it in the cvs now so that you can help me improve and test it
Gimme feedback on what sucks!