Its an uphill battle, but after much article perusing and many unsuccessful shader attempts. I've gathered together my best attempts. What I have now is what I call the "Beach Zone" and it will be the area where the surfing action will take place. These two videos just give a glimpse of the already broken waves in the form of incoming "foamies".
The surfer has to paddle out through these "foamies" in order to gain access to "backline" where he will meet up with the breaking wave which he will catch to ride back to shore.
(This post was last modified: 10-06-2014 03:00 PM by 3DRaddict.)
The last couple of weeks I've headed out beyond the "Beach Zone" and past the "Surfing Zone" to the scary "Ocean Zone"
A few technical details:
The scene shown is a 128x128 vertex mesh, 512x512 metre tile.
I have to keep the vertex resolution low because I'm planning on having a few such tiles.Also, I'm limited to a max of 32768 vertices per tile.
The waves are Gerstner waves and are all generated in my custom vertex shader, together with the foam, and other effects. I am getting some artifacting whilst animating the normals in the pixel shader, and not too sure why at this stage (could be the low resolution?)
I can tell you that the sure way to learn anything is to do it yourself and plug away at it until you are satisfied with the result. You might curse, swear and lose a few hairs in the process, but its all worthwhile!
Having the GUI is a godsend as far as changing shader parameters is concerned.
That is probably why I've never concentrated too much on shaders in previous engines...I always used to make my shader changes in code, run the program, see the result, stop, edit, run and so on, and so on....
Anyway, the big job now, as far as this project goes, is to make one complete seamless scene, combining "Beach Zone", "Surfing Zone" and "Ocean Zone"
And I'm now getting one massive headache just thinking about it !
With many thanks to Esenthel for sorting out my shader problem, I was able to progress a little further in this project.
I now have 4 'Beach Zone' tiles, 4 'Surf Zone' tiles and 4 'Ocean Zone' tiles postioned within a 1024m x 1024m terrain mesh.
Each tile has the maximum number of 32768 vertices, and it all runs at a steady 60fps. I am not using the World Editor... just laid out everything in code, with no programmed LOD or frustum culling. Each Zone has its own set of particular characteristics which can be adjusting by means of its shader parameters.
However, merging and matching the tiles seamlessly is proving problematic. Gerstner waves are tileable, but one has to get their wavelengths and phases exactly right, which can be time-consuming and restrictive. I am now thinking of having one big 1024m x 1024m ocean mesh with the Zones controlled by masking within its shader. With this in mind, I am now reading up on adaptive meshes which incorporate frustum culling and distance tesselation.
Once I have all this ocean background stuff in place, the real work of adding the actual surfable waves will begin.
Here's the latest video showing all tiles in place:
Just replaced all the tiles with one big 2048mx1024m ocean mesh... 100% improvement.
The mesh vertex resolution is 256x128, (8m cell size) but even though this resolution is low, I cannot discern any noticeable anomolies. I still use a single shader to make the Gerstner waves, foam ,shore transparency and decrease the amplitude at the beach. This is really a big relief for me... no more fiddling around with lining up tiles!
I can now get on with the job of adding the high resolution surfing waves!
The beginnings of a new 'World' playground for this project. No breaking waves or ocean yet... just a plain old textured plane placeholder (that's a mouthfull, eh? )
Learning as I go, and beginning to enjoy using the World Editor
Nice results, a nice normal map for the sand would add to the scene also but i guess it's still early. How did you do the terrain? Looking forward to more pics.
Also how is the waves generation going? I've read something about having difficulties matching different tiles of sea meshes so you went back to a single big tile. I wanted to ask you if you have knowledge on the part on how good Gerstner waves would look if they were only limited to Z axis calculation. I've read that some people would mix like 8-40 waves iterations to get good results.
Isn't this a bit too much for a vertex shader considering an ocean would require a good number of vertexes at least in the close distance? Or not i don't know.
Have you considered mixing sliding textures or is it hard to get good results also though i guess you wanted to have waves splashing etc so Z only wont be enough. Anyway always interested to hear more so let us know.
The terrain was derived from a heightmap obtained from satellite SRTM data of the area surrounding my hometown.You can read up my technique on my website page http://www.3draddict.com/my-hometown-walkthrough.html
I imported it into Esenthel and used Esenthel to paint the various textures.
I'll be concentrating on the detail ground, shrubs,bushes,trees etc at a later stage (once I get my waves sorted out)
Your questions regarding the waves are very relevent, and have been buzzing around in my head for years.
Refer to my website page http://www.3draddict.com/surfing-simulation.html for background on this obssesive project of mine.
I have folders and folders of articles and techniques on this subject (projected grid, radial grid, adaptive LOD, tessellation techniques). I can't count the number of iterations and failed attempts I've gone through over the years. This might prove to be another of those, although I am decidedly more hopeful.
The surfing action is only going to take place in one 1000mx1000m region so that is where my camera's main focus will be. Also, I am only concerned with the actual wave that the surfer will be catching and riding, so that I can restrict the high resolution stuff to the immediate vicinity of the surfer.
I'm afraid this is 'try as I go', but I'll only post up the more successful and promising attempts.