wave-harmonic / crest Goto Github PK
View Code? Open in Web Editor NEWA class-leading water system implemented in Unity
License: MIT License
A class-leading water system implemented in Unity
License: MIT License
Shader error in 'Ocean/Ocean Surface Alpha': undeclared identifier 'ComputeLodAlpha' at line 62 (on d3d11)
Google "ComputeLodAlpha", nothing.... any clues
Find all "ComputeLodAlpha", Find Results 1, Entire Solution, ""
D:\Mirror\Unity-Projects-Folder\Cresty\Assets\Crest\Shaders\OceanSurfaceAlpha.shader(62): float lodAlpha = ComputeLodAlpha(worldPos, _InstanceData.x);
Matching lines: 1 Matching files: 1 Total files searched: 43
So.. what is it? Built-in? I'm using the wrong version? something?
I've got a wave interaction object on our character to create waves while running or swimming through water. I'm finding that once I get something which looks pretty good, it can go crazy when something gives the player an uncommonly high velocity (like falling from a high location, getting knocked back, falling from a fast-moving object, etc).
I feel like I need some way to clamp the velocity for the simulation on a per-object basis. Because for small objects, the dynamics is mostly just for aesthetics, so we don't ever want the waves to get big enough to have a significant impact on the simulation.
Thanks!
The CopyTo here seems to be the bulk of the cpu time being used in Update. Not the read back. If you browse the ECS/Job forums at Unity there have been some memcpy based solutions posted there using unsafe code. Or you could just move the copy into a job.
Potentially add scattered light based on wave height, or some smarter scheme.
Originated from discussion in #33
Hi, I grabbed the latest data to evaluate, and tried to get it working inside our existing project. Most things were working as expected, but when I added the Render Ocean Depth component to our terrain (which is a Unity Terrain object, rather than a regular mesh), I get the following errors spammed in the log:
ArgumentNullException: Argument cannot be null. Parameter name: renderer UnityEngine.Rendering.CommandBuffer.DrawRenderer (UnityEngine.Renderer renderer, UnityEngine.Material material, Int32 submeshIndex, Int32 shaderPass) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/RenderingCommandBufferBindings.gen.cs:362) UnityEngine.Rendering.CommandBuffer.DrawRenderer (UnityEngine.Renderer renderer, UnityEngine.Material material) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/RenderingCommandBufferBindings.gen.cs:356) Crest.WaveDataCam.UpdateCmdBufOceanFloorDepth () (at Assets/Crest/Scripts/WaveDataCam.cs:168) Crest.WaveDataCam.Update () (at Assets/Crest/Scripts/WaveDataCam.cs:62)
I tried just creating a regular cube mesh, and the component worked on that fine, so I suspect it's something specific with Unity Terrains?
This isn't an issue, or necessarily a feature request, I just thought it might be worth putting here.
You may already be aware of this, but I just came across this cool looking work presented at SIGGRAPH 2018.
https://www.youtube.com/watch?v=6I6BV0-BVxI
I know you've already been experimenting with similar stuff in the local_sim branch, so I thought this might be helpful? Things I found particularly cool were the pre-computed boundaries, wake reflecting, and the ability to paint in flow directions, either for currents or things like whirlpools (which would be very useful in our project).
The video description has links to the project page for the actual papers and whatnot.
From @holdingjason :
Oh not sure if this is something that can really be done since I believe this is just not possible but alpha transparent shaded object under the water will not be rendered if you view them from on top of the water. So think of a semi transparent jellyfish or bottle floating on the surface. Those would not show up or only the parts sticking about the water.
when i change wave share to WaveParticle, the surface won't wave. it doesn't working right now?
Hi! This isn't a post about any specific issue, just been a while since I commented and was curious about what you've been focusing on lately in Crest. I see you've mostly been working on the local_sim3 branch, is this mostly focused on dynamic waves and such? I saw some mentions of changing the foam too, so yeah, keen to hear how it's all going!
I've just grabbed the latest data, and I'm seeing something strange with the transparency. It sort of looks like the depth mask is inverted or something? I've recorded a clip of the issue here. I've seen this in the scene view in the past, but this is happening in the Game window.
I'm using Unity 2017.3.1p4. I've just downloaded the project from GitHub and opened the Unity folder as a project.
Any ideas what this could be?
Hi,
first of all, excellent work so far, I'm really liking what I'm seeing. I've been playing around with some of the examples and noticed in the profiler that a lot of garbage is being produced. I'm sure you are already aware of this. I just wanted to know if you plan on optimizing this any time soon?
Keep up the good work!
Best regards
I was just skipping through a demo presentation at Unite Berlin on Unity's new Lightweight Render Pipeline, and they had a section (timestamped link here) where they briefly show how they apply some fake caustics on geometry under the water.
Would it be possible to have an option for something like this in Crest? I think it'd work well with the shoreline foam to really sell the effect.
EDIT: I tried to throw the Enhancement label on this, but I assume that's something only you can do?
Hi again. I've just been looking at your latest changes with transparency, subsurface scattering and wave attenuation. It looks awesome!
I'm curious about the way you're handling lighting in general. From what I can see, the ocean surface doesn't appear to react to the light colour, intensity or direction. Is this an intentional choice, or just something you haven't gotten to changing yet?
Also, regarding your recent improvements, would it be possible to have some way to adjust these settings in the material? E.g. the transparency depth, subsurface colour, shallow colour, etc.
In our project, the time of day is dynamic (my reason for asking about the lighting), and we also adjust various environmental properties for different biomes (why we might like to change the surface/subsurface colours, etc).
Again, awesome work!
Just wondering if theres a reason why you dont use tesselation as a LOD solution
Hi, you mention that the dynamics branch features reflections and refraction, but I don't see either. Is there something specific which needs to be done to enable these?
Thanks.
This is an odd one, and it's been happening since we first brought Crest into our project. I haven't mentioned it because I thought it was related to the old version of the Unity Post Processing stack we were using, but it turns out that isn't the case.
Basically, the ocean will occasionally go completely black, with powerful bloom around the edges (which is why I thought it was the Post Processing stack). However, it seems to be view dependent, in that if you move the camera to another location, it will pop back to normal. I've attached some screenshots.
Example 2 ('Add Directional Light' disabled)
Example 3 ('Add Directional Light' + 'Sub-Surface Scattering' disabled)
Since it makes the bloom go crazy, I wonder if it's some value that isn't being clamped? We're using deferred rendering and have HDR enabled. I'm not exactly sure what other info to give you, but I'll let you know if I can isolate the issue further. We're using what is currently the latest data on GitHub.
At the moment, the chop value is a shared value across the whole of the simulation. I'm finding that at some wave frequencies, I'd like to have a different choppiness to others. Is that feasible at all?
Maybe a checkbox next to each level of the wave spectrum to let you override the chop from the global value to a user-defined one? It'd also be nice to set it to values greater than 1 like what your debug GUI allows for.
Also, a sidenote, it seems odd that the chop is currently specified in a different section to the actual wave spectrum. Is that intentional?
Thanks!
Hi @huwb !
Looks like Wave sim/Foam sim intensity are very related to framerate.
I have tested this on 3 diferent machines:
On machine 1, there is a lot of foam just after starting accelerating the ship a little, and after get some speed, the generated wave is way higher (in height) than desired.
On machine 2, is also noticeable there is a lot more foam than normal, and that waves go too up as well, but not as much as on machine 1.
On machine 3, there is almost no foam (unless you go pretty fast and turning), and wave sim is way smaller, not getting as high as any of the other machines.
I've just double checked this on latest d4d8536 commit from master.
I think that some time-dependent values are not multiplied by Time.deltaTime
, or maybe we are mixing fixed time step with regular time steps. I'll try to figure out what is causing this.
Thank you!
It appears as though the force applied to the ocean continues to accumulate if Unity's timescale is set to zero. We use the numpad for setting the time scale for debug purposes (5 = %50, 1 = 10%, etc), and we noticed that if we're interacting with the water and pause the game by setting the speed to 0, the ocean will explode with tidal waves when we unpause.
A simple way to replicate this is in the threeboats scene, press play, and while running, open the Time Editor (Edit > Project Settings > Time) and set the time scale to 0. Wait a few seconds, then set it back to 1. You should see all the wake from the boats go a bit crazy. The longer it's paused, the crazier it'll be.
On a related note, I have also noticed similar behaviour if there are hitches in the framerate while playing, where the dynamics will suddenly be very strong after a breif (e.g. 0.5 sec) hiccup. I assume this is the same issue?
I'm sure your well aware that this doesn't work on the lightweight render pipeline but do you have any plans to support it?
Hi! First of all, It's so good! But I have some questions about this, could you help me?
Could i get a screenshot or in the best case video demoing this? I couldn't repro this - i looked out for it while reimporting/creating new projects trying to repro #51 .
Thanks!
Was testing against azure sky, and the water is blocking it's scattering and fog. Anywhere water is rendered scattering/fog is gone. Any geometry above the water gets scattering/fog applied correctly.
Any educated guess on what might be going on there?
Hello,
what a great library :) I was wondering I was wondering whether there is a way to cheaply approximate the water height on the cpu? Maybe even stateless (like gerstner waves). I would love to use this in a client/server game. Currently I'm using gerstner waves which can be evaluated at discrete points on the server.
Following on from discussion in #18 with @Midda-C - i have a prototype implementation which generates displacements on top of the dynamic wave sim by offsetting the wave surface horizontally proportionally to the gradient.
The insight here is that gerstner waves displacement has this basic form
X = ...cos(...)
Y = ...sin(...)
The height follows a sinusoid, but the distinctive gerstner shape comes from the horizontal displacement coming from the cos() term, which is the derivative/gradient of the height function.
This prototype introduces horizontal displacement proportional to the gradient of the water heights coming from the dynamic wave sim. For a travelling sinusoidal wave this will produce gerstner waves. For more general shapes it seems to perform gracefully and sharpens the wave shape, and produces plausible horizontal motion.
I have pushed the prototype to the feature/wave_sim_disps branch. The wave sim settings have two new parameters that scale and clamp the generated displacement respectively (see tooltips).
I also turned off the custom foam generation from the dynamic waves - since the dynamic waves now have displacement, the foam is generated directly from the water surface the same as the gerstner waves. This hints at a unified path for foam which would allow me to remove some foam generation code that is currently highly unstable. This would be great!
If anyone has a chance to try it, please let me know if you have thoughts/feedback here.
Pause the game, wait awhile, ocean goes nuts when unpausing (that is not a word). Settles down after a few.
Right now we are setting the skybox in the shader. This works fine for static skyboxes but curious how this would work with something more dynamic like AzureSky (which we use) that is set and adjust on the fly in the skybox material under lighting. Since the skybox is updates constantly, ie sun moving across the sky, clouds etc would be interesting to have this effect the ocean as well. I will try and do some research into this as I have seen this same type of question pop up in other ocean packages.
(I need to update the readme with all the latest changes, apologies its lagging)
@fatboxSoftware asked on twitter if there is an easy way to adjust the amount of foam on the ocean and wave crests.
Yes there is - on the ocean prefab, there is an OceanBuilder script. This has a field called SimSettingsFoam where an asset can be plugged in to tweak the settings (if none is provided, it will create default settings).
To define your own settings, select Asset -> Create -> Crest -> Foam Sim Settings, which will generate an asset with a number of settings which have tooltips. I think Wave Foam Strength and Wave Foam Coverage are most relevant to your question, but its worth playing with the others too. Let me know if you have any questions, or if that gets you what you need?
Cheers!
This issue is to track improvement of lighting on the foam. It currently looks flat right now. Some kind of 3D lighting would probably improve it a lot.
From @Midda-C during conversation on #4 :
I don't know if this is a bit out-of-scope, but I was thinking about why the foam looks too saturated at sunset/sunrise. After just looking at some sunset beach images, I think it might be related to the entire foam surface being uniformly affected. Because real foam has some height, you get a bit of shading on it.
You get bright saturated colours on the sides facing the light, but shadows/ambient on the opposite side. Maybe a normal map (and some PBR roughness) for the foam might help give some more believable shading?
The three boats demo scene worked fine for us, but when we tried the same dynamic sim in our game, the highest detail lods vanished.
After tracking things down it seems _SimDeltaTimePrev is 0 on the first game turn for us
I'm guessing some update order has our scene running a game turn with a zero value
this line float v = (ft - ftm) / _SimDeltaTimePrev;
generate's NAN's and because the sim is a feedback system Nan's propagate forever..
adding
_SimDeltaTimePrev = max(_SimDeltaTimePrev, 0.0001f);
before its used to ShapeSimWave.shader fixed it for us.
We are finding with bigger (steeper) waves the lag on the CPU sample height causes a visual issue with boat physics and objects floating, the bigger issue is objects appearing to hover above the water as the wave goes by rather than the object going underwater as the wave approaches.
Thats when running at 30 fps.
Guys could you give me a bit more detail on what you see? Is it reporting that prefabs are "missing" in the threeboats scene? Which prefabs exactly?
So far i've tried the following to repro without success:
Note that i copy the meta files along with the folders - so Crest.meta and Crest-Examples.meta.
I'm on 2018.2.1f1. I'm happy to upgrade forward if you guys are on a new version.
Hi,
First of all, thanks for maintaining such a great project. 👍
It is possible to use dynamic planar reflections on the ocean renderer instead of the static skybox? So dynamic/static objects in the scene can get reflected on the water. I think it can increase the realism of the simulation.
Any ideas on how to do this?
Thank you.
I believe this used to be a mask setting so we could pick multiple layers to apply this to.
It appears we now would create multiple ocean cache object for each layer we want to apply this to. Seems like the old way made a bit more sense but maybe there is a good reason to do it this way. Just curious.
Thanks
Would it be possible to support GPU instancing for the meshes at each LOD level? Or do they each have unique mesh grids? Any thoughts on challenges around this? It would greatly improve the time wasted pushing the verts to the GPU.
Hey! I can contribute on your project in field of graphic. If you need a logo design we can talk about design decisions and I can put here my first experiments. I can show my portfolio if you interested. My main aim is make my portfolio better with supporting open source projects. I am waiting your feedback, have a nice day!
I really hate posting issues but I just noticed ocean is black in objects with PBR materials. It's no biggie for me but I thought I must notify developer about this. I also tried changing ocean material properties but alas no luck.
EDIT: Zero fesnel kinda fixes the ocean but it's zero fresnel so... nope, scratch that.
Shorelines only show up for mountains. Adding other objects doesn't generate any new shorelines, even duplicating mountains model doesn't help. Also, deactivating the mountains doesn't remove the shoreline.
Unity 5.6.5, 2017.3, 2018.1
Since we are always asking for stuff I figured it would be nice to show you what we are doing with your fantastic system.
You can make the ocean shader work underwater by simply adding
Cull Off
The floating objects use physics force projections based around water density. The boat uses a modified version of https://assetstore.unity.com/packages/tools/physics/dynamic-water-physics-89928
Video
https://drive.google.com/open?id=13MiePsUzK98vzDywiVFXvuXGYZ_jXxOg
Is there away to control the speed of the waves or frequency between them? Right now I can play with the equalizer but the wave frequency speed stays the same between them. I am talking between generated waves at the same level. I see that I can turn off or lower waves in the equalizer that would create gaps but that only works with larger waves following smaller waves which is not what I want.
Think a shore shot with lazy small waves drifting in slowly with large gaps between them.
So we've got things up and running in our project now. to get started, I began getting the foam back on the ocean surface, but I have a few questions.
Could you clarify what exactly the Strength and Coverage settings do? I can see changes when I adjust them, but I'm not entirely sure what their differences are.
What is the intention with the additional Coverage parameter on the material (also, I think it's inverted now? It seems to remove foam the higher you set it, I think it used to be the other way around)
Am I correct to assume that, like the wave shapes, it's okay to run several foam sims with different settings as long as they're not doubling-up on the same wavelengths?
I may be mistaken, but was there previously an overall fade/alpha parameter for the foam on the ocean material? I don't know if I'm imagining that or not, but either way, that would be helpful.
With the old foam, we were able to get some nice stylised (i.e. not realistic, but appropriate for our art-style) foam on the peaks of the higher-frequency waves. I'm having a hard time replicating this with the foam sim, could you give some guidance on how something similar might be achieved? Here's an example of how we had it configured on the previous release.
Thanks!
I might do it myself but I havent looked at all the lod camera stuff yet, I guess first you have to work out which lod camera the point is in then sample its depth texture at the right position, then duplicate the maths in the shader.
Probably want to give us two different settings for this. In our project we want to control shore foam separate from the waves. We like a little foam near the shore but always showing where the waves might have a bit more or less going on depending.
I think maybe there is away to do this with two different foam sims but so far no luck on that. Though to be honest I dont think I fully understand what the res elements totally do. Are they related to distance from the camera? Wave Spectrums? Maybe a little more info on how those work. Will look through the rest of this and see if I can find the details.
Thanks
Are you sick of me yet? ;)
So I was trying to figure out why the foam appeared so different in your project on GitHub compared to the same assets and scene in our own project. Turns out the issue is due to our project using linear colour space, and the Crest project using gamma space. The resulting changes from simply changing the colour space are very pronounced. The following image is the exact same location, on the same frame (I used the 'freeze time' option on the ocean prefab), with the only difference being the colour space.
As you can see from the image, everything seems to be impacted to some degree—the colour, the foam, the transparency, and possibly the fresnel.
We're using linear space as it is the preferred workflow for PBR assets. Even though Unity themselves recommend a linear space workflow, Unity still, for whatever reason, seems to default to gamma (It's changed in Edit > Project Settings > Player > Other Settings)
At the moment, I don't know how to get the foam to behave correctly in linear colour space, is it seems to mostly just cover the surface of the water in a repeating pattern with little regard to what the wave behaviour is set to.
I think the way the actual assets are authored plays into this as well? It's not something I'm super knowledgeable on. Not sure if the impact on all of the other aspects (colour, opacity, etc) is something that needs to be considered also.
Latest master branch. Previous master as of July 26 worked fine (before the new sim foam 2.0)
Clean install. Default scene following setup instructions up to and including adding foam.
2018.2.1f1 (latest). I believe I saw this in 2018.1.3 but not positive.
https://drive.google.com/file/d/15RRMw3X6lNeOhyZeYsPh2mSA_LGJrHcR/view?usp=sharing
Most of this white foam is added by the flicker.
Should look like this. Caught this one between flickers.
Number of layers required is a bit much. The demo requires 4 (Terrain is not mentioned that I could find in the docs). This actually used up all remaining layers in my project. Layers tend to be at a premium in large games.
So there have been a number of instances where sections of the ocean have been out of direct sight of the sun, and it appears to glow when this is contrasted against some rocks or landmass which is receiving shadows (or just the regular NdL shading). I've attached an example.
I understand this is a common issue with transparent objects, so I'm not sure much can really be done, but I thought I may as well see if you could think of any ways to approach this? I suppose screen-space reflections might reduce the issue on the fresnel, but I'm not sure about the subsurface lighting.
Not a pressing issue by any means, but I figured I'd at least get it recorded. :)
While our terrain is on its own layer, we have many environmental objects in our game which reside on the Default layer. Many of these are in the water, so we'd like to include them in the ocean depth cache, but when the default layer is added, we get this result (replicated in a blank Crest project)
It seems as though the entirety of the depth cache region is marked as being below the shorline.
We're already short on layers, so it'd be a challenge to move all of these objects off the default layer, where they are otherwise fine.
Is this a bug, or is the default layer intended to be avoided in this case?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.