Comments (20)
Here ya go.
https://drive.google.com/open?id=1IAuIoYU7IUblOrZk8Ud9XS1pItWegEPd
BTW I am now on a new video card.
from crest.
Thanks for that. That confounds me. I will ponder this for a while!
from crest.
Will look into it as well. Might be something I changed on my side, only thing I can think of is the cull stuff. Will check.
from crest.
Ohhh i reckon i have fixed this just now:
When i moved the main scene content up i noticed the logo was not tracking the sea level and fixed it. I think you're using a small offset of sea level from y=0 which would explain why the logo is cutting in and out. If you get a chance could i get a retest?
from crest.
Crap I know what it is. I reset the render queue to output to 3000 instead of 2100. Sorry about that.
I was messing with that because of this issue. I can see islands etc far off in the distance. Not sure why that happens except that it appears that the zorder rendering of the ocean is sometimes higher then that land. That has no override or setting its just using the standard shader btw. Which i would have expected 2100 to work.
Above 2501+
from crest.
Ok tracked it down. So this issue is caused by having Post Processing (v2) on with Deferred Fog Enabled (I am running in deferred rendering mode). For now I will leave my settings on the ocean material to render at 2501 which fixes that flicker issue.
from crest.
Ok, that's a fun issue. It seems unity flips the order it renders things at 2500 which sounds like a trigger for your issue, but I'm not sure why yet. https://docs.unity3d.com/Manual/SL-SubShaderTags.html
I could probably have a pretty good run at the problem given a renderdoc capture. Same deal as the last time - full debug info in shader please. The capture will include your assets so you may want to send it via email if you like.
from crest.
Would be happy to do that if it would be a time saver for you but also just FYI you can also setup your main scene by adding the post process layer to the camera, camera to deferred and turn on deferred fog in the post processing layer settings.
In lighting turn on fog and use linear with something like 200 and 600
from crest.
Ah ok.. but do you think you could send me captures of the working and not working cases anyway?
If I recall you have turned backface culling off. Now in addition to that the above change will make unity render the ocean tiles from back to front. I can think of a worst case where some of your pixels will end up shading 14 layers of ocean, or more. If I'm right, then for a heavy shader like the ocean material this is a performance apocalypse, and I think it's worth digging deeper.
from crest.
Ok sorry I'm replying on my phone so I'm delayed.. I'll see if I can repro it myself, thanks
from crest.
Np. That does sound nasty. So is it a combo of the backface culling off with deferred AND fog or just deferred with back face culling off. Will try changing that just to see. Oh and I guess putting it into alpha test at 2501 which would have additional overhead.
from crest.
okkkkk so i went down a very deep, very dark rabbit hole and have emerged with some results. for starters, i believe the following is true:
- unity knows the the ocean surface is not deferred rendered, probably due to the LightMode=ForwardBase tag which is required (weirdness ensues if its omitted - #19).
- therefore it copies out the depth before rendering the ocean, and its this depth that is associated with the gbuffer and used for any postprocessing
- the ocean does write depth, and we could possibly recopy out the depth after the ocean finishes rendering, and then compute fog from that. that would look ok.
- BUT - consider for a moment another post proc effect: SSAO. if the ocean surface depth was taken into account, there would be dark creases where the water meets land (had this on a previous project, it sucked). if on the other hand we leave it as it is now, any crevices under the water will trigger SSAO - same kind of error as what we're getting with fog. we're screwed either way.
- conclusion - we need to do this the proper way - put it in geometry+501 (2501). unity docs refer to water being put here as well
back to the problem - potentially bad worst case cost due to back to front sorting that unity applies to this queue. here i think the well defined lod/tile structure can come to the rescue.. it looks like i can manually set the sorting order on the tiles so they always draw front to back! i just confirmed now that it seems to work in renderdoc..
i need to check it all again when im much less tired but i'm hopeful that this is the solution for us!
from crest.
Gotcha. Ok that all makes sense. Thanks for digging into this.
from crest.
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.
from crest.
Cool. Checked again this morning and it looks good to me on both forward and deferred so I pushed it! This is good.
Regarding alpha, ill move it to its own issue.
from crest.
I keep thinking about you guys turning off culling and if it can be avoided. Perhaps you can use this to switch culling between back/front at runtime:
https://docs.unity3d.com/ScriptReference/Material.SetOverrideTag.html
So do something like this when the camera goes underwater:
_oceanMaterial.SetOverrideTag("Cull", "Front");
I have not tested it but it looks legit from the docs..
It will likely introduce a hitch so you'll want to prime it by setting it to front and then back at loading/init time if you can..
from crest.
Will give that a try and let you know what happens. Thanks.
from crest.
Tag did not work but this did.
Add this to properties
_Cull ("Culling", Float) = 0
Add this to the subshader uner tags
Cull [_Cull]
In your script when you want to render underwater
OceanMaterial.SetInt("_Cull", (int)CullMode.Front);
and above water
OceanMaterial.SetInt("_Cull", (int)CullMode.Back);
Worked like a charm on mine.
Not sure what it did for perf but should go lighter on the GPU now.
from crest.
Waaaa what is that dark magic - you're feeding a shader param directly into a rasterizer state!? Do you have a link/ref or did you just try it and it worked out? Just curious how "official" it is, and by extension how platform friendly it is.
Anyway i tried it myself and it worked great for me, and i plussed it slightly with the Enum attribute i found. Commit referenced above. Let me know if it looks fine to you.
Thanks - glad we worked this through!
from crest.
So I based this on the standard shader. Downloaded those and took a look. You can see examples of them doing the same thing in the subshader for
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
I had modified the standard shader before for some tree effects and noticed this. Figured if it works for that why not culling. However I am NOT a shader expert just starting to dip my toes in that area so have no idea as to how platform friendly it is but if they do it in the standard shader I would hope. However they do not do it for cullling which might be a different beast. Honestly you are so far ahead of me on this if you don't know well then... I did some research but so far found very little to nothing except a reddit post which basically says the same thing I said above.
https://www.reddit.com/r/Unity3D/comments/5bu1gw/can_i_change_a_shaders_pass_attributes_at_runtime/
from crest.
Related Issues (20)
- URP reflection error when using two cameras after build. HOT 3
- Updating ShapeFFT parameters runtime, generates a lot of garbage HOT 5
- HDRP underwater volumetric lights not working properly HOT 2
- Local / movable spectrums or crest shapes HOT 3
- Foam / wake vibration when approaching whirlpools HOT 20
- Pressing the Windows Key in the editor disables underwater rendering HOT 3
- Wake / foam artifacts when moving the camera quickly HOT 11
- Delayed LOD / tile enabling when using large clipping areas HOT 5
- Depth Cache not populated - Exported Image is Black HOT 8
- Water interaction is not visible when moving camera away from the sea level HOT 1
- Underwater broken with XR multi-pass rendering HOT 1
- No caustics, no shadow data and/or constant shadowing on iOS
- Error of Does not exist some Classes. HOT 1
- Sporadic gaps / precision errors in tiles. HOT 35
- SphereWaterInteraction and RegisterDynamicWavesInput do not work correctly inside a flow area HOT 11
- Activating flow in the material when oceanrenderer is running does only work in editor HOT 2
- FindObjectsSortMode HOT 3
- Enable Shader API does not function without changing underwater appearance HOT 20
- Enable Shader API causes artifacts HOT 4
- Planar Reflections issue with non-standard shaders using transparency HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crest.