@Elecman : The wave will look as realistic as I can manage. Couldn’t say how good that is until its all done. I can say that the method I’m using (Fourier transform of the unified direction spectrum) is regarded as the most realistic method currently practical on today’s hardware.
@sadicus : Thanks. Will let you know if I need more testers.
@hippocoder : Yer shorelines have always been a issue. I have a few ideas. Will have to see if there practical.
So Ive spent that last few days structuring the code so it naturally supports multiple cameras. The ocean should work from the view of any camera added to the scene. Sounds like a no brainier but it takes a bit of work to get right. The projected grid needs to have its projection applied per camera as well as a few other per camera data like the ocean mask (see below).
Also been setting up the code so the underwater effects can be applied. This means generating a mask so the areas underwater can be identified in the post effect shader. I did mention the stencil buffer in last post but turns out its not quite as flexible as I needed. Just went with a conventional mask.
Also the ocean mesh needs to generate a depth map so it knows how deep objects are below its surface. This depth map can not include the ocean mesh itself or the meshes depth value will block everything else.
This image is of the camera looking down with the depth values of the objects below the camera being rendered as the color where the Fresnel value would allow you o see underwater.
This images is from below the water with the depth values being rendered as the color again. The image in the top corner is the ocean mask. The red is the ocean top side, the green the oceans under side and the blue is the ocean bottoms background.
Need to decide how to apply the underwater scattering now. Was thinking of something simple for now but will also be looking into a method similar to Brunetons precomputed atmospheric scattering but adapted to ocean water. Could be hard to do. Will have to see.
Also will be looking into what methods I could use for underwater god rays. Pretty sure I can modify the standard sun shafts shader for this. Was also thinking of true volumetric light shafts using this method which has source code for Unity available. Again could be hard to do.
Great stuff. I’m actually thinking it would probably be better to just get the basic ocean going with all its performance perks then add features over time? might be interesting. Scatter and things like that are great but I’d love it if they’re optional or tweakable for performance reasons… using PS4 here so I have fixed performance budgets, I guess!
For example in GTA 5 (on xbox 360), they never show below and above water at the same time, they just make the switch and disguise with a special effect. Likewise you could decide to make an opaque ocean option so pixels get discarded, saving fill for example the ocean in the distance probably wouldn’t need half these features and can gradually get more expensive to render the closer and more important it becomes, ie a practical answer for open world games.
Just thoughts, since I’m super interested in this solution.
Yep. I get what you mean. Don’t worry I’m not going to get to bogged down in detail at this point. If anything start taking to long I will just keep it basic and move on.
From my experience I’ve found it best to keep some of the more advanced features in Mind from the start even if you don’t end up implementing the full effect then. Nothing worse that trying to and something in later only to discover you have to completely restructure the code.
All features will be optional with quality options from ultra to low and a LOD for distant objects.
I wanted to make sure I set up a seamless transition from above the ocean to below from the start. Have a idea for a game that would need that to be supported.
For the lightshaft unity already have volumetric light shaft based from the same article that you mentioned above, maybe it can help you so you can adapt it to your ocean.
This looks amazing. What caught my eye was the underwater transition. Have not seen this in anything real-time. Looking forward to seeing more.
I have tried that volumetric lighting script and it looks amazing. Had to stop using it because it kept on throwing a C++ error and crashing Unity. Weird. If it could be worked on and adapted to this that would be amazing.
Wow this is looking fantastic, reminds me of what Roderick was done with Truesky.
Really hope these work together in the end, I can see these 2 being my go to for environmental assets.
Hope when you’re working on the wave generation you can implement a Beaufort system.
Would be great to have full sized waves for those nice stormy scenes.
@Baldinoboy : Thanks. The project I tried is this one. Worked in Unity fine for me. No errors. Even Upgraded to Unity5 with no issues.
@John-G : Thanks. Hoping to have a slider for the ocean conditions based on the Beaufort scale.
@longraodhwy: Thanks.
Havnt had much time this week with work but have managed to add some basic under water colors. This is just a place holder to make sure I have all the information I need in the shader (depths, grab, etc). The final underwater effect should look much better but still to decide exactly what method to use.
I think I have focused enough on the underwater stuff and will be adding foam/shore effects next. Will return to under water stuff later. Also need to make some nice islands to test the scenes with. This was just a quick one.
Very cool! I tried to get the first few builds working for our game but never could get them working with the waves large enough. Are you planning on some more complex foam in this version? We need a foam that generates at the peaks of the waves and then fades down the wave.
@CaptainMurphy_1 : Will be working on the foam next. With the other projects if you were using the indie one the waves heights were clamped to quite a small range. The project has been upgraded to Unity5 which now support float format textures so the clamping has been removed. Also its the wind speed that makes the waves larger and its not set up to be changed during run time. A value of 12 should do it, see Arainami’s post up above. You might want to give it another go, or you could just wait for this project to be finished which will have support for all those things.
Made a nicer looking coral atoll today to better show the underwater effects so far.
We tested every version that was released. We also tried to work with the version that was in your ProLand conversion but never could get it looking right, unfortunately. On your depth effects are you just using the depth render or does it actually correspond to the water depth at that x/z? I am using Suimono right now and one of the advantages is that a shoal area of water can have a different coloring based on the actual depth and not the shader depth so seeing a shoal area at a low angle is possible. Also, along that same vein, will the waves deform around those areas of shoal you are showing? Mitigating the larger waves and instead moving to beach waves?
That’s looking good, one thing I’ve not seen an ocean system do right is foam.
They all tend to generate foam a set distance around the camera, but if you move the camera to a height is very obvious that foam and even waves are not generated to the horizon.
This totally breaks the illusion of waves if used for example a flight sim.
@CaptainMurphy_1 : At moment I am using the depth buffer. The amount of water the light would go thought between the ocean surface to the object is calculated and a attenuation is applied based on that. You can still see objects from a fairly low angle but they will get darker the closer to the surface you get. Here’s a view from the height of the ships upper deck.
I see what you mean by using the actual objects depth at position x/y. The amount of attenuation would be independent of the view angle. The underwater stuff I have added so far is pretty basic and is not final. I will have a look at implementing the effect like you said. I dont think it would be to hard. I could easily have a mode setting to choose between which method you want to use.
In terms of the oceans waves moving to beach waves around the shore I have some ideas but wont know if its practical until I try.
@John-G : Thanks John. I will try and make it so the foam still looks good to the horizon. Where you live looks very cold
Haha yes no Caribbean waters for me, I’m on the west coat of Ireland. Wind and rain pretty much all year round. Spent much of my life on the seas, so I’ll be a hard customer to please
Planning on a ww2 naval /sub sim based in the Atlantic /Pacific so water will be the main feature along with Truesky that will be used for environmental.
Hey Scrawk, attached is my modification of your ocean shader (regular lighting) which I put in some shore foam and shore color using depth buffer. Maybe it can be useful for you in some way!
I hadn’t noticed this thread, about time! Your efforts should definitely be rewarded not just for your oceans but your entire blog, which i still visit often. You probably have more than enough testers by now but if an opportunity comes id love to take a look, got rather familiar with your oceans over a period of time, fell in love especially with the whitecaps project as you know. Good luck anyways, ill be be checking the thread
I think your ocean system would be well suited to use a depth render camera overhead to find where the water should change wave pattern since the wave is always sourced from the same spot and the camera would be at the same point as well. I have always wondered if the edge foam could be rendered from a depth render texture as well. Any of the ‘moving tile’ systems generally don’t behave well with a camera that snaps between points, there is always a frame or two of lag for the render texture to catch up after the tile shift where you get the foam and wave effects ‘snapping’ to the new tile location but keeping their old appearance. The biggest reason to have the shoreline wave system is more to stop the waves from showing in the middle of low lying land masses. Every ocean system except Suimono that I have tried will show the waves through the terrain and it is hard to depth mask huge areas sometimes.
For our project we boiled down the foam to 3 unique parts. The first is the peak foam that is created during the tip of the wave being curled from wind or wave angle, the second is the trailing foam that is created from the peak foam and is strong right after the peak creates it but fades as the waves moves along, the third is wind streaks which are created in the direction of the prevailing wind (which is not always the direction of the waves) due to the wind ‘breaking off’ the tips of the waves and blowing them out in lines. Using the old Community Ocean (this was my last variation that I did of it) I was able to get some realistic looking peak and trailing foam but never got to the point of the wind streaks.
It appears you already have buoyancy scripts in the system. Do they have any limitations?
Edited to clarify: limitations in distance from gameobject, camera frustum, or limits on how many can run and need to smear across frames.